From dc67e9ac63494b9e9d753b06ad33e22b4724b7f4 Mon Sep 17 00:00:00 2001 From: zhengzhouheng Date: Wed, 7 Apr 2021 14:09:39 +0800 Subject: [PATCH] add the Stack op --- include/tim/vx/ops/stack.h | 44 ++++++++++++++++++++++++++++++++++++++ src/tim/vx/ops/README.md | 2 +- src/tim/vx/ops/stack.cc | 40 ++++++++++++++++++++++++++++++++++ 3 files changed, 85 insertions(+), 1 deletion(-) create mode 100755 include/tim/vx/ops/stack.h create mode 100755 src/tim/vx/ops/stack.cc diff --git a/include/tim/vx/ops/stack.h b/include/tim/vx/ops/stack.h new file mode 100755 index 0000000..2c2d92d --- /dev/null +++ b/include/tim/vx/ops/stack.h @@ -0,0 +1,44 @@ +/**************************************************************************** +* +* Copyright (c) 2020 Vivante Corporation +* +* Permission is hereby granted, free of charge, to any person obtaining a +* copy of this software and associated documentation files (the "Software"), +* to deal in the Software without restriction, including without limitation +* the rights to use, copy, modify, merge, publish, distribute, sublicense, +* and/or sell copies of the Software, and to permit persons to whom the +* Software is furnished to do so, subject to the following conditions: +* +* The above copyright notice and this permission notice shall be included in +* all copies or substantial portions of the Software. +* +* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +* DEALINGS IN THE SOFTWARE. +* +*****************************************************************************/ +#ifndef TIM_VX_OPS_STACK_H_ +#define TIM_VX_OPS_STACK_H_ +#include "tim/vx/operation.h" + +namespace tim { +namespace vx { +namespace ops { + +class Stack : public Operation { + public: + Stack(Graph* graph, uint32_t axis, int input_cnt); + + protected: + uint32_t axis_; +}; + +} // namespace ops +} // namespace vx +} // namespace tim + +#endif /* TIM_VX_OPS_STACK_H_ */ \ No newline at end of file diff --git a/src/tim/vx/ops/README.md b/src/tim/vx/ops/README.md index 89ca76c..58440ee 100644 --- a/src/tim/vx/ops/README.md +++ b/src/tim/vx/ops/README.md @@ -83,7 +83,7 @@ Select|SELECT|Mapped ||LSTMUNIT_OVXLIB|Unmapped ||TENSOR_ADD_MEAN_STDDEV_NORM|Unmapped Relu1|RELU1|Mapped -||STACK|Unmapped +Stack|STACK|Mapped ||FLOOR|Unmapped Square|SQUARE|Mapped Neg|NEG|Mapped diff --git a/src/tim/vx/ops/stack.cc b/src/tim/vx/ops/stack.cc new file mode 100755 index 0000000..6d4d825 --- /dev/null +++ b/src/tim/vx/ops/stack.cc @@ -0,0 +1,40 @@ +/**************************************************************************** +* +* Copyright (c) 2020 Vivante Corporation +* +* Permission is hereby granted, free of charge, to any person obtaining a +* copy of this software and associated documentation files (the "Software"), +* to deal in the Software without restriction, including without limitation +* the rights to use, copy, modify, merge, publish, distribute, sublicense, +* and/or sell copies of the Software, and to permit persons to whom the +* Software is furnished to do so, subject to the following conditions: +* +* The above copyright notice and this permission notice shall be included in +* all copies or substantial portions of the Software. +* +* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +* DEALINGS IN THE SOFTWARE. +* +*****************************************************************************/ +#include "tim/vx/ops/stack.h" + +#include "operation_private.h" +#include "vsi_nn_pub.h" + +namespace tim { +namespace vx { +namespace ops { + +Stack::Stack(Graph* graph, uint32_t axis, int input_cnt) + : Operation(graph, VSI_NN_OP_STACK, input_cnt, 1), axis_(axis) { + this->impl()->node()->nn_param.stack.axis = axis_; +} + +} // namespace ops +} // namespace vx +} // namespace tim \ No newline at end of file