Merge pull request #1 from liyuenan2333/main

Map [NNRT-824]LeakyRelu/[NNRT-817]LogicalOr/And/[NNRT-831]GatherNd
This commit is contained in:
hawk081 2021-01-19 16:53:31 +08:00 committed by GitHub
commit 92e62e78fc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
15 changed files with 270 additions and 7 deletions

View File

@ -53,6 +53,14 @@ class Prelu : public Operation {
int axis_;
};
class LeakyRelu : public Operation {
public:
LeakyRelu(Graph* graph, float alpha);
protected:
float alpha_;
};
} // namespace ops
} // namespace vx
} // namespace tim

View File

@ -27,7 +27,6 @@
namespace tim {
namespace vx {
namespace ops {
class DepthToSpace : public Operation {

View File

@ -27,7 +27,6 @@
namespace tim {
namespace vx {
namespace ops {
class Gather : public Operation {

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.
*
*****************************************************************************/
#ifndef TIM_VX_OPS_GATHERND_H_
#define TIM_VX_OPS_GATHERND_H_
#include "tim/vx/operation.h"
namespace tim {
namespace vx {
namespace ops {
class GatherNd : public Operation {
public:
GatherNd(Graph* Graph);
};
} // namespace ops
} // namespace vx
} // namespace tim
#endif /* TIM_VX_OPS_GATHERND_H_ */

View File

@ -0,0 +1,47 @@
/****************************************************************************
*
* 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_LOGICAL_H_
#define TIM_VX_OPS_LOGICAL_H_
#include "tim/vx/operation.h"
namespace tim {
namespace vx {
namespace ops {
#define DELCATE_LOGICAL_OP(NAME) \
class Logical##NAME : public Operation { \
public: \
Logical##NAME(Graph* graph); \
};
DELCATE_LOGICAL_OP(And);
DELCATE_LOGICAL_OP(Or);
#undef DELCATE_LOGICAL_OP
} // namespace ops
} // namespace vx
} // namespace tim
#endif /* TIM_VX_OPS_ACTIVATIONS_H_ */

View File

@ -46,7 +46,7 @@ DELCATE_REDUCE_OP(Any);
DELCATE_REDUCE_OP(Prod);
DELCATE_REDUCE_OP(Mean);
#undef DEFINE_REDUCE_OP
#undef DELCATE_REDUCE_OP
} // namespace ops
} // namespace vx

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_REVERSE_H_
#define TIM_VX_OPS_REVERSE_H_
#include "tim/vx/operation.h"
namespace tim {
namespace vx {
namespace ops {
class Reverse : public Operation {
public:
Reverse(Graph* graph, int32_t* axis, uint32_t axis_num);
protected:
int32_t* axis_;
uint32_t axis_num_;
};
} // namespace ops
} // namespace vx
} // namespace tim
#endif /* TIM_VX_OPS_REVERSE_H_ */

View File

@ -27,7 +27,6 @@
namespace tim {
namespace vx {
namespace ops {
class SpaceToDepth : public Operation {

View File

@ -56,6 +56,11 @@ Tanh::Tanh(Graph* graph) : Operation(graph, VSI_NN_OP_TANH) {
this->impl()->node()->nn_param.tanh.scale_b = 1.0;
}
LeakyRelu::LeakyRelu(Graph* graph, float alpha)
: Operation(graph, VSI_NN_OP_LEAKY_RELU), alpha_(alpha) {
this->impl()->node()->nn_param.activation.leaky_ratio = alpha_;
}
} // namespace ops
} // namespace vx
} // namespace tim

View File

@ -28,7 +28,6 @@
namespace tim {
namespace vx {
namespace ops {
DepthToSpace::DepthToSpace(Graph* graph, int block_size)

View File

@ -28,7 +28,6 @@
namespace tim {
namespace vx {
namespace ops {
Gather::Gather(Graph* graph, int axis)

View File

@ -0,0 +1,36 @@
/****************************************************************************
*
* 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/gathernd.h"
#include "operation_private.h"
#include "vsi_nn_pub.h"
namespace tim {
namespace vx {
namespace ops {
GatherNd::GatherNd(Graph* graph) : Operation(graph, VSI_NN_OP_GATHER_ND) {}
} // namespace ops
} // namespace vx
} // namespace tim

47
src/tim/vx/ops/logical.cc Normal file
View File

@ -0,0 +1,47 @@
/****************************************************************************
*
* 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/logical.h"
#include "operation_private.h"
#include "vsi_nn_pub.h"
namespace tim {
namespace vx {
namespace ops {
#define DEFINE_LOGICAL_OP(NAME, VSI_OP_CODE) \
Logical##NAME::Logical##NAME(Graph* graph) \
: Operation(graph, VSI_NN_OP_LOGICAL_OPS) { \
this->impl()->node()->nn_param.relational_ops.op = \
VSI_NN_LOGICAL_##VSI_OP_CODE; \
}
DEFINE_LOGICAL_OP(And, AND);
DEFINE_LOGICAL_OP(Or, OR);
#undef DEFINE_LOGICAL_OP
} // namespace ops
} // namespace vx
} // namespace tim

40
src/tim/vx/ops/reverse.cc Normal file
View File

@ -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/reverse.h"
#include "operation_private.h"
#include "vsi_nn_pub.h"
namespace tim {
namespace vx {
namespace ops {
Reverse::Reverse(Graph* graph, int32_t* axis, uint32_t axis_num)
: Operation(graph, VSI_NN_OP_REVERSE), axis_(axis), axis_num_(axis_num) {
this->impl()->node()->nn_param.reverse.axis = axis_;
this->impl()->node()->nn_param.reverse.axis_num = axis_num_;
}
} // namespace ops
} // namespace vx
} // namespace tim

View File

@ -28,7 +28,6 @@
namespace tim {
namespace vx {
namespace ops {
SpaceToDepth::SpaceToDepth(Graph* graph, std::vector<int> block_size)