Add the Squeeze op

Signed-off-by: yuenan.li <yuenan.li@verisilicon.com>
This commit is contained in:
yuenan.li 2021-04-13 19:48:03 +08:00 committed by Kainan Cha
parent 11480f18f3
commit c9d3416c6b
3 changed files with 87 additions and 1 deletions

View File

@ -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 <vector>
#include "tim/vx/operation.h"
namespace tim {
namespace vx {
namespace ops {
class Squeeze : public Operation {
public:
Squeeze(Graph* graph, std::vector<uint32_t> axis);
protected:
std::vector<uint32_t> axis_;
};
} // namespace ops
} // namespace vx
} // namespace tim
#endif /* TIM_VX_OPS_SQUEEZE_H_ */

View File

@ -135,7 +135,7 @@ GatherNd|GATHER_ND|Mapped
||LINEAR|Unmapped ||LINEAR|Unmapped
||BATCHNORM_SINGLE|Unmapped ||BATCHNORM_SINGLE|Unmapped
||MOMENTS|Unmapped ||MOMENTS|Unmapped
||SQUEEZE|Unmapped Squeeze|SQUEEZE|Mapped
HardSigmoid|HARD_SIGMOID|Unmapped HardSigmoid|HARD_SIGMOID|Unmapped
Mish|MISH|Unmapped Mish|MISH|Unmapped
||EXPAND_BROADCAST|Unmapped ||EXPAND_BROADCAST|Unmapped

41
src/tim/vx/ops/squeeze.cc Normal file
View File

@ -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<uint32_t> 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