From c9d3416c6be228916b524c1c33631b631ca0774c Mon Sep 17 00:00:00 2001 From: "yuenan.li" Date: Tue, 13 Apr 2021 19:48:03 +0800 Subject: [PATCH] Add the Squeeze op Signed-off-by: yuenan.li --- include/tim/vx/ops/squeeze.h | 45 ++++++++++++++++++++++++++++++++++++ src/tim/vx/ops/README.md | 2 +- src/tim/vx/ops/squeeze.cc | 41 ++++++++++++++++++++++++++++++++ 3 files changed, 87 insertions(+), 1 deletion(-) create mode 100644 include/tim/vx/ops/squeeze.h create mode 100644 src/tim/vx/ops/squeeze.cc diff --git a/include/tim/vx/ops/squeeze.h b/include/tim/vx/ops/squeeze.h new file mode 100644 index 0000000..2166353 --- /dev/null +++ b/include/tim/vx/ops/squeeze.h @@ -0,0 +1,45 @@ +/**************************************************************************** +* +* 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_SQUEEZE_H_ +#define TIM_VX_OPS_SQUEEZE_H_ +#include +#include "tim/vx/operation.h" + +namespace tim { +namespace vx { +namespace ops { + +class Squeeze : public Operation { + public: + Squeeze(Graph* graph, std::vector axis); + + protected: + std::vector axis_; +}; + +} // namespace ops +} // namespace vx +} // namespace tim + +#endif /* TIM_VX_OPS_SQUEEZE_H_ */ diff --git a/src/tim/vx/ops/README.md b/src/tim/vx/ops/README.md index 58440ee..2804930 100644 --- a/src/tim/vx/ops/README.md +++ b/src/tim/vx/ops/README.md @@ -135,7 +135,7 @@ GatherNd|GATHER_ND|Mapped ||LINEAR|Unmapped ||BATCHNORM_SINGLE|Unmapped ||MOMENTS|Unmapped -||SQUEEZE|Unmapped +Squeeze|SQUEEZE|Mapped HardSigmoid|HARD_SIGMOID|Unmapped Mish|MISH|Unmapped ||EXPAND_BROADCAST|Unmapped diff --git a/src/tim/vx/ops/squeeze.cc b/src/tim/vx/ops/squeeze.cc new file mode 100644 index 0000000..e6de83b --- /dev/null +++ b/src/tim/vx/ops/squeeze.cc @@ -0,0 +1,41 @@ +/**************************************************************************** +* +* 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/squeeze.h" + +#include "operation_private.h" +#include "vsi_nn_pub.h" + +namespace tim { +namespace vx { +namespace ops { + +Squeeze::Squeeze(Graph* graph, std::vector axis) + : Operation(graph, VSI_NN_OP_SQUEEZE), axis_(axis) { + this->impl()->node()->nn_param.squeeze.axis = axis_.data(); + this->impl()->node()->nn_param.squeeze.axis_num = axis_.size(); +} + +} // namespace ops +} // namespace vx +} // namespace tim