diff --git a/include/tim/vx/ops/activations.h b/include/tim/vx/ops/activations.h index 9fb9dda..b45f446 100644 --- a/include/tim/vx/ops/activations.h +++ b/include/tim/vx/ops/activations.h @@ -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 diff --git a/include/tim/vx/ops/depth2space.h b/include/tim/vx/ops/depth2space.h index 6aea69b..eef90e6 100644 --- a/include/tim/vx/ops/depth2space.h +++ b/include/tim/vx/ops/depth2space.h @@ -27,7 +27,6 @@ namespace tim { namespace vx { - namespace ops { class DepthToSpace : public Operation { diff --git a/include/tim/vx/ops/gather.h b/include/tim/vx/ops/gather.h index b819447..c788075 100644 --- a/include/tim/vx/ops/gather.h +++ b/include/tim/vx/ops/gather.h @@ -27,7 +27,6 @@ namespace tim { namespace vx { - namespace ops { class Gather : public Operation { diff --git a/include/tim/vx/ops/gathernd.h b/include/tim/vx/ops/gathernd.h new file mode 100644 index 0000000..0759fe2 --- /dev/null +++ b/include/tim/vx/ops/gathernd.h @@ -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_ */ diff --git a/include/tim/vx/ops/logical.h b/include/tim/vx/ops/logical.h new file mode 100644 index 0000000..57fb6cc --- /dev/null +++ b/include/tim/vx/ops/logical.h @@ -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_ */ \ No newline at end of file diff --git a/include/tim/vx/ops/reduce.h b/include/tim/vx/ops/reduce.h index 1885733..db6c310 100644 --- a/include/tim/vx/ops/reduce.h +++ b/include/tim/vx/ops/reduce.h @@ -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 diff --git a/include/tim/vx/ops/reverse.h b/include/tim/vx/ops/reverse.h new file mode 100644 index 0000000..7cf6c77 --- /dev/null +++ b/include/tim/vx/ops/reverse.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_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_ */ diff --git a/include/tim/vx/ops/space2depth.h b/include/tim/vx/ops/space2depth.h index e86dc01..fe5b4b7 100644 --- a/include/tim/vx/ops/space2depth.h +++ b/include/tim/vx/ops/space2depth.h @@ -27,7 +27,6 @@ namespace tim { namespace vx { - namespace ops { class SpaceToDepth : public Operation { diff --git a/src/tim/vx/ops/activations.cc b/src/tim/vx/ops/activations.cc index f3a7e39..7de2273 100644 --- a/src/tim/vx/ops/activations.cc +++ b/src/tim/vx/ops/activations.cc @@ -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 diff --git a/src/tim/vx/ops/depth2space.cc b/src/tim/vx/ops/depth2space.cc index b2d5abf..7a84d79 100644 --- a/src/tim/vx/ops/depth2space.cc +++ b/src/tim/vx/ops/depth2space.cc @@ -28,7 +28,6 @@ namespace tim { namespace vx { - namespace ops { DepthToSpace::DepthToSpace(Graph* graph, int block_size) diff --git a/src/tim/vx/ops/gather.cc b/src/tim/vx/ops/gather.cc index 302b2c1..e1d9e6f 100644 --- a/src/tim/vx/ops/gather.cc +++ b/src/tim/vx/ops/gather.cc @@ -28,7 +28,6 @@ namespace tim { namespace vx { - namespace ops { Gather::Gather(Graph* graph, int axis) diff --git a/src/tim/vx/ops/gathernd.cc b/src/tim/vx/ops/gathernd.cc new file mode 100644 index 0000000..8457e06 --- /dev/null +++ b/src/tim/vx/ops/gathernd.cc @@ -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 \ No newline at end of file diff --git a/src/tim/vx/ops/logical.cc b/src/tim/vx/ops/logical.cc new file mode 100644 index 0000000..0924570 --- /dev/null +++ b/src/tim/vx/ops/logical.cc @@ -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 \ No newline at end of file diff --git a/src/tim/vx/ops/reverse.cc b/src/tim/vx/ops/reverse.cc new file mode 100644 index 0000000..e61e541 --- /dev/null +++ b/src/tim/vx/ops/reverse.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/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 \ No newline at end of file diff --git a/src/tim/vx/ops/space2depth.cc b/src/tim/vx/ops/space2depth.cc index 5009ef8..4ad0303 100644 --- a/src/tim/vx/ops/space2depth.cc +++ b/src/tim/vx/ops/space2depth.cc @@ -28,7 +28,6 @@ namespace tim { namespace vx { - namespace ops { SpaceToDepth::SpaceToDepth(Graph* graph, std::vector block_size)