diff options
Diffstat (limited to 'runtimes/pure_arm_compute/src/internal/op')
86 files changed, 5741 insertions, 730 deletions
diff --git a/runtimes/pure_arm_compute/src/internal/op/Abs.cc b/runtimes/pure_arm_compute/src/internal/op/Abs.cc new file mode 100644 index 000000000..e23a9538c --- /dev/null +++ b/runtimes/pure_arm_compute/src/internal/op/Abs.cc @@ -0,0 +1,59 @@ +/* + * Copyright (c) 2018 Samsung Electronics Co., Ltd. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "internal/op/Abs.h" +#include "internal/op/NodeVisitor.h" + +#include <cassert> + +namespace internal +{ +namespace tflite +{ +namespace op +{ +namespace Abs +{ + +void Node::accept(NodeVisitor &&v) const { v.visit(*this); } + +} // namespace Abs +} // namespace op +} // namespace tflite +} // namespace internal + +namespace internal +{ +namespace tflite +{ +namespace op +{ +namespace Abs +{ + +Param::Param(uint32_t inputCount, const uint32_t *inputs, uint32_t outputCount, + const uint32_t *outputs) +{ + assert(inputCount == 1 && outputCount == 1); + + output_index = outputs[0]; + input_index = inputs[0]; +} + +} // namespace Abs +} // namespace op +} // namespace tflite +} // namespace internal diff --git a/runtimes/pure_arm_compute/src/internal/op/Abs.h b/runtimes/pure_arm_compute/src/internal/op/Abs.h new file mode 100644 index 000000000..0be8b0205 --- /dev/null +++ b/runtimes/pure_arm_compute/src/internal/op/Abs.h @@ -0,0 +1,68 @@ +/* + * Copyright (c) 2018 Samsung Electronics Co., Ltd. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef __INTERNAL_OP_ABS_H__ +#define __INTERNAL_OP_ABS_H__ + +#include "internal/op/Node.h" + +#include <cstdint> + +namespace internal +{ +namespace tflite +{ +namespace op +{ +namespace Abs +{ + +struct Param +{ + int32_t output_index; + int32_t input_index; + + Param() = default; + Param(uint32_t inputCount, const uint32_t *inputs, uint32_t outputCount, const uint32_t *outputs); +}; + +class Node final : public op::Node +{ +public: + Node(const Param ¶m) : _param(param) + { + // DO NOTHING + } + +public: + virtual ~Node() = default; + +public: + const Param ¶m(void) const { return _param; } + +public: + void accept(NodeVisitor &&) const override; + +private: + const Param _param; +}; + +} // namespace Abs +} // namespace op +} // namespace tflite +} // namespace internal + +#endif // __INTERNAL_OP_ABS_H__ diff --git a/runtimes/pure_arm_compute/src/internal/op/Add.h b/runtimes/pure_arm_compute/src/internal/op/Add.h index 42ed5b976..a7804a569 100644 --- a/runtimes/pure_arm_compute/src/internal/op/Add.h +++ b/runtimes/pure_arm_compute/src/internal/op/Add.h @@ -14,6 +14,12 @@ * limitations under the License. */ +/** + * @file Add.h + * @brief This file contains accept function and params for Add operation + * @ingroup COM_AI_RUNTIME + */ + #ifndef __INTERNAL_OP_ADD_H__ #define __INTERNAL_OP_ADD_H__ @@ -30,33 +36,66 @@ namespace op namespace Add { +/** + * @brief Struct of Add operation's param + */ struct Param { - int32_t ofm_index; + int32_t ofm_index; /**< Output format index */ - int32_t lhs_index; - int32_t rhs_index; - int32_t activation_index; + int32_t lhs_index; /**< Left hand side index */ + int32_t rhs_index; /**< Right hand side index */ + int32_t activation_index; /**< Activation index */ + /** + * @brief Construct a new Param object for Add as default + */ Param() = default; + + /** + * @brief Construct a new Param object for Add with params + * @param [in] inputCount The number of input + * @param [in] inputs Array containing inputs + * @param [in] outputCount The number of output + * @param [in] outputs Array containing outputs + */ Param(uint32_t inputCount, const uint32_t *inputs, uint32_t outputCount, const uint32_t *outputs); }; +/** + * @brief Class to define operation node for Add + */ class Node final : public op::Node { public: + /** + * @brief Construct a new Node object for Add with param + * @param [in] param Parameters for Node + */ Node(const Param ¶m) : _param(param) { // DO NOTHING } public: + /** + * @brief Destroy the Node object for Add + */ virtual ~Node() = default; public: + /** + * @brief Get parameters for Add + * @return Parameters of Add + */ const Param ¶m(void) const { return _param; } public: + /** + * @brief Function for accepting node for Add + * @param [in] v Node visitor for invoking visit function of Add + * @return N/A + */ void accept(NodeVisitor &&) const override; private: diff --git a/runtimes/pure_arm_compute/src/internal/op/ArgMax.cc b/runtimes/pure_arm_compute/src/internal/op/ArgMax.cc new file mode 100644 index 000000000..485430377 --- /dev/null +++ b/runtimes/pure_arm_compute/src/internal/op/ArgMax.cc @@ -0,0 +1,64 @@ +/* + * Copyright (c) 2018 Samsung Electronics Co., Ltd. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#include "internal/op/ArgMax.h" +#include "internal/op/NodeVisitor.h" + +#include <cassert> + +namespace internal +{ +namespace tflite +{ +namespace op +{ +namespace ArgMax +{ + +void Node::accept(NodeVisitor &&v) const { v.visit(*this); } + +} // namespace ArgMax +} // namespace op +} // namespace tflite +} // namespace internal + +namespace internal +{ +namespace tflite +{ +namespace op +{ +namespace ArgMax +{ + +Param::Param(uint32_t inputCount, const uint32_t *inputs, uint32_t outputCount, + const uint32_t *outputs) +{ + assert(inputCount == 2 && outputCount == 1); + + ofm_index = outputs[0]; + + // Each input should be interpreted as follows: + // + // 0 -> Input Tensor Index + // 1 -> Axis Tensor Index + ifm_index = inputs[0]; + axis_index = inputs[1]; +} + +} // namespace ArgMax +} // namespace op +} // namespace tflite +} // namespace internal diff --git a/runtimes/pure_arm_compute/src/internal/op/ArgMax.h b/runtimes/pure_arm_compute/src/internal/op/ArgMax.h new file mode 100644 index 000000000..780af2232 --- /dev/null +++ b/runtimes/pure_arm_compute/src/internal/op/ArgMax.h @@ -0,0 +1,70 @@ +/* + * Copyright (c) 2018 Samsung Electronics Co., Ltd. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef __INTERNAL_OP_ARGMAX_H__ +#define __INTERNAL_OP_ARGMAX_H__ + +#include "internal/op/Node.h" + +#include <cstdint> + +namespace internal +{ +namespace tflite +{ +namespace op +{ +namespace ArgMax +{ + +struct Param +{ + int32_t ofm_index; + + int32_t ifm_index; + int32_t axis_index; + + Param() = default; + Param(uint32_t inputCount, const uint32_t *inputs, uint32_t outputCount, const uint32_t *outputs); +}; + +class Node final : public op::Node +{ +public: + Node(const Param ¶m) : _param(param) + { + // DO NOTHING + } + +public: + virtual ~Node() = default; + +public: + const Param ¶m(void) const { return _param; } + +public: + void accept(NodeVisitor &&) const override; + +private: + const Param _param; +}; + +} // namespace ArgMax +} // namespace op +} // namespace tflite +} // namespace internal + +#endif // __INTERNAL_OP_ARGMAX_H__ diff --git a/runtimes/pure_arm_compute/src/internal/op/AvgPool2D.h b/runtimes/pure_arm_compute/src/internal/op/AvgPool2D.h index 729f6043c..cf9061ca9 100644 --- a/runtimes/pure_arm_compute/src/internal/op/AvgPool2D.h +++ b/runtimes/pure_arm_compute/src/internal/op/AvgPool2D.h @@ -14,6 +14,12 @@ * limitations under the License. */ +/** + * @file AvgPool2D.h + * @ingroup COM_AI_RUNTIME + * @brief This file defines internal::tflite::op::AvgPool2D Param structs + * and internal::tflite::op::AvgPool2D Node classes + */ #ifndef __INTERNAL_OP_AVG_POOL_2D_H__ #define __INTERNAL_OP_AVG_POOL_2D_H__ @@ -32,44 +38,75 @@ namespace AvgPool2D namespace Explicit { +/** + * @brief Struct to have indexes for operation parameter + */ struct Param { - int32_t ofm_index; + int32_t ofm_index; /**< Index of output feature map */ - int32_t ifm_index; + int32_t ifm_index; /**< Index of input feature map */ - int32_t kw_index; - int32_t kh_index; + int32_t kw_index; /**< Index of kernel width */ + int32_t kh_index; /**< Index of kernel height */ - int32_t hstride_index; - int32_t vstride_index; + int32_t hstride_index; /**< Index of horizontal stride */ + int32_t vstride_index; /**< Index of vertical stride */ - int32_t padding_left_index; - int32_t padding_right_index; - int32_t padding_top_index; - int32_t padding_bottom_index; - - int32_t activation_index; + int32_t padding_left_index; /**< Index of padding left */ + int32_t padding_right_index; /**< Index of padding right */ + int32_t padding_top_index; /**< Index of padding top */ + int32_t padding_bottom_index; /**< Index of padding bottom */ + int32_t activation_index; /**< Index of activation */ + /** + * @brief Construct as default + */ Param() = default; + /** + * @brief Construct a new Param object with params + * @param[in] inputCount Count of inputs + * @param[in] inputs Pointer of inputs + * @param[in] outputCount Count of outputs + * @param[in] outputs Pointer of outputs + */ Param(uint32_t inputCount, const uint32_t *inputs, uint32_t outputCount, const uint32_t *outputs); }; +/** + * @brief Class to represent an operation of data structure + */ class Node final : public op::Node { public: + /** + * @brief Construct a new Node object with param + * @param[in] param Param object that makes up a Node + */ Node(const Param ¶m) : _param(param) { // DO NOTHING } public: + /** + * @brief Destruct as default + */ virtual ~Node() = default; public: + /** + * @brief Get a reference of Param object + * @return Reference of Param object + */ const Param ¶m(void) const { return _param; } public: + /** + * @brief Visit this Node by NodeVisitor + * @param[in] v Visitor + * @return N/A + */ void accept(NodeVisitor &&) const override; private: @@ -81,40 +118,71 @@ private: namespace Implicit { +/** + * @brief Struct to have indexes for operation parameter + */ struct Param { - int32_t ofm_index; - - int32_t ifm_index; + int32_t ofm_index; /**< Index of output feature map */ - int32_t kw_index; - int32_t kh_index; + int32_t ifm_index; /**< Index of input feature map */ - int32_t hstride_index; - int32_t vstride_index; + int32_t kw_index; /**< Index of kernel width */ + int32_t kh_index; /**< Index of kernel height */ - int32_t padding_index; - int32_t activation_index; + int32_t hstride_index; /**< Index of horizontal stride */ + int32_t vstride_index; /**< Index of vertical stride */ + int32_t padding_index; /**< Index of padding */ + int32_t activation_index; /**< Index of activation */ + /** + * @brief Construct as default + */ Param() = default; + /** + * @brief Construct a new Param object with params + * @param[in] inputCount Count of inputs + * @param[in] inputs Pointer of inputs + * @param[in] outputCount Count of outputs + * @param[in] outputs Pointer of outputs + */ Param(uint32_t inputCount, const uint32_t *inputs, uint32_t outputCount, const uint32_t *outputs); }; +/** + * @brief Class to represent an operation of data structure + */ class Node final : public op::Node { public: + /** + * @brief Construct a new Node object with param + * @param[in] param Param object that makes up a Node + */ Node(const Param ¶m) : _param(param) { // DO NOTHING } public: + /** + * @brief Destruct as default + */ virtual ~Node() = default; public: + /** + * @brief Get a reference of Param object + * @return Reference of Param object + */ const Param ¶m(void) const { return _param; } public: + /** + * @brief Visit this Node by NodeVisitor + * @param[in] v Visitor + * @return N/A + */ void accept(NodeVisitor &&) const override; private: diff --git a/runtimes/pure_arm_compute/src/internal/op/BatchToSpaceNd.cc b/runtimes/pure_arm_compute/src/internal/op/BatchToSpaceNd.cc new file mode 100644 index 000000000..0768039d0 --- /dev/null +++ b/runtimes/pure_arm_compute/src/internal/op/BatchToSpaceNd.cc @@ -0,0 +1,63 @@ +/*Copyright (c) 2018 Samsung Electronics Co., Ltd. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#include "internal/op/BatchToSpaceNd.h" +#include "internal/op/NodeVisitor.h" + +#include <cassert> + +namespace internal +{ +namespace tflite +{ +namespace op +{ +namespace BatchToSpaceNd +{ + +void Node::accept(NodeVisitor &&v) const { v.visit(*this); } + +} // namespace BatchToSpaceNd +} // namespace op +} // namespace tflite +} // namespace internal + +namespace internal +{ +namespace tflite +{ +namespace op +{ +namespace BatchToSpaceNd +{ + +Param::Param(uint32_t inputCount, const uint32_t *inputs, uint32_t outputCount, + const uint32_t *outputs) +{ + assert(inputCount == 2 && outputCount == 1); + + output_index = outputs[0]; + + // Each input should be interpreted as follows: + // + // 0 -> Input Tensor Index + // 1 -> Block size Index + input_index = inputs[0]; + block_size_index = inputs[1]; +} + +} // namespace BatchToSpaceNd +} // namespace op +} // namespace tflite +} // namespace internal diff --git a/runtimes/pure_arm_compute/src/internal/op/BatchToSpaceNd.h b/runtimes/pure_arm_compute/src/internal/op/BatchToSpaceNd.h new file mode 100644 index 000000000..a514cb44c --- /dev/null +++ b/runtimes/pure_arm_compute/src/internal/op/BatchToSpaceNd.h @@ -0,0 +1,83 @@ +/* + * Copyright (c) 2018 Samsung Electronics Co., Ltd. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef __INTERNAL_OP_BATCHTOSPACE_ND_H__ +#define __INTERNAL_OP_BATCHTOSPACE_ND_H__ + +#include "internal/op/Node.h" + +#include <cstdint> + +namespace internal +{ +namespace tflite +{ +namespace op +{ +namespace BatchToSpaceNd +{ + +struct Param +{ + int32_t output_index; + + int32_t input_index; + int32_t block_size_index; + + Param() = default; + Param(uint32_t inputCount, const uint32_t *inputs, uint32_t outputCount, const uint32_t *outputs); +}; + +} // namespace BatchToSpaceNd +} // namespace op +} // namespace tflite +} // namespace internal + +namespace internal +{ +namespace tflite +{ +namespace op +{ +namespace BatchToSpaceNd +{ +class Node final : public op::Node +{ +public: + Node(const Param ¶m) : _param(param) + { + // DO NOTHING + } + +public: + virtual ~Node() = default; + +public: + const Param ¶m(void) const { return _param; } + +public: + void accept(NodeVisitor &&) const override; + +private: + const Param _param; +}; + +} // namespace BatchToSpaceNd +} // namespace op +} // namespace tflite +} // namespace internal + +#endif // __INTERNAL_OP_BATCHTOSPACE_Nd_H__ diff --git a/runtimes/pure_arm_compute/src/internal/op/Cast.h b/runtimes/pure_arm_compute/src/internal/op/Cast.h index 3b3795189..8af741a16 100644 --- a/runtimes/pure_arm_compute/src/internal/op/Cast.h +++ b/runtimes/pure_arm_compute/src/internal/op/Cast.h @@ -14,6 +14,12 @@ * limitations under the License. */ +/** + * @file Cast.h + * @brief This file contains accept function and params for Cast operation + * @ingroup COM_AI_RUNTIME + */ + #ifndef __INTERNAL_OP_CAST_H__ #define __INTERNAL_OP_CAST_H__ @@ -30,31 +36,64 @@ namespace op namespace Cast { +/** + * @brief Struct of Cast operation's param + */ struct Param { - int32_t output_index; + int32_t output_index; /**< Output index */ - int32_t input_index; + int32_t input_index; /**< Input index */ + /** + * @brief Construct a new Param object for Cast as default + */ Param() = default; + + /** + * @brief Construct a new Param object for Cast with params + * @param [in] inputCount The number of input + * @param [in] inputs Array containing inputs + * @param [in] outputCount The number of output + * @param [in] outputs Array containing outputs + */ Param(uint32_t inputCount, const uint32_t *inputs, uint32_t outputCount, const uint32_t *outputs); }; +/** + * @brief Class to define operation node for Cast + */ class Node final : public op::Node { public: + /** + * @brief Construct a new Node object for Cast with param + * @param [in] param Parameters for Node + */ Node(const Param ¶m) : _param(param) { // DO NOTHING } public: + /** + * @brief Destroy the Node object for Cast + */ virtual ~Node() = default; public: + /** + * @brief Get parameters for Cast + * @return Parameters of Cast + */ const Param ¶m(void) const { return _param; } public: + /** + * @brief Function for accepting node for Cast + * @param [in] v Node visitor for invoking visit function of Cast + * @return N/A + */ void accept(NodeVisitor &&) const override; private: diff --git a/runtimes/pure_arm_compute/src/internal/op/Concat.h b/runtimes/pure_arm_compute/src/internal/op/Concat.h index 185cba3e1..207f964fb 100644 --- a/runtimes/pure_arm_compute/src/internal/op/Concat.h +++ b/runtimes/pure_arm_compute/src/internal/op/Concat.h @@ -14,6 +14,12 @@ * limitations under the License. */ +/** + * @file Concat.h + * @ingroup COM_AI_RUNTIME + * @brief This file defines Concat node + */ + #ifndef __INTERNAL_OP_CONCAT_H__ #define __INTERNAL_OP_CONCAT_H__ @@ -31,36 +37,68 @@ namespace op namespace Concat { +/** + * @brief Struct to manipulate parameter for Concat operation + */ struct Param { - int32_t ofm_index; + int32_t ofm_index; //!< index for output - std::vector<int32_t> ifm_indexes; - int32_t axis_index; + std::vector<int32_t> ifm_indexes; //!< index for input + int32_t axis_index; //!< index for axis + /** + * @brief Default Constructor + */ Param() = default; + /** + * @brief Construct a new Param object + * @param[in] inputCount the number of inputs + * @param[in] inputs pointer for input data + * @param[in] outputCount the number of outputs + * @param[in] outputs pointer for input data + */ Param(uint32_t inputCount, const uint32_t *inputs, uint32_t outputCount, const uint32_t *outputs); }; +/** + * @brief Class to define Concat Operation + */ class Node final : public op::Node { public: + /** + * @brief Construct a new Concat Node object + * @param param Parameter for Concat Node + */ Node(const Param ¶m) : _param(param) { // DO NOTHING } public: + /** + * @brief Default Destructor + */ virtual ~Node() = default; public: + /** + * @brief Get parameter + * @return Param reference + */ const Param ¶m(void) const { return _param; } public: + /** + * @brief Accept a NodeVisitor so that it can visit this node + * @param [in] v Visitor + * @return N/A + */ void accept(NodeVisitor &&) const override; private: - const Param _param; + const Param _param; //!< parameter for Concat node }; } // namespace Concat diff --git a/runtimes/pure_arm_compute/src/internal/op/Conv2D.h b/runtimes/pure_arm_compute/src/internal/op/Conv2D.h index b04b8c85f..de46fbb9c 100644 --- a/runtimes/pure_arm_compute/src/internal/op/Conv2D.h +++ b/runtimes/pure_arm_compute/src/internal/op/Conv2D.h @@ -14,6 +14,12 @@ * limitations under the License. */ +/** + * @file Conv2D.h + * @brief This file contains accept function and params for Conv2D operation + * @ingroup COM_AI_RUNTIME + */ + #ifndef __INTERNAL_OP_CONV_2D_H__ #define __INTERNAL_OP_CONV_2D_H__ @@ -32,43 +38,76 @@ namespace Conv2D namespace Explicit { +/** + * @brief Struct of Conv2D(explicit) operation's param + */ struct Param { - int32_t ofm_index; + int32_t ofm_index; /**< Output format index */ - int32_t ifm_index; - int32_t ker_index; - int32_t bias_index; + int32_t ifm_index; /**< Input format index */ + int32_t ker_index; /**< Kernel index */ + int32_t bias_index; /**< Bias index */ - int32_t hstride_index; - int32_t vstride_index; + int32_t hstride_index; /**< Horizontal stride index */ + int32_t vstride_index; /**< Vertical stride index */ - int32_t padding_left_index; - int32_t padding_right_index; - int32_t padding_top_index; - int32_t padding_bottom_index; + int32_t padding_left_index; /**< Left padding index */ + int32_t padding_right_index; /**< Right padding index */ + int32_t padding_top_index; /**< Top padding index */ + int32_t padding_bottom_index; /**< Bottomd padding index */ - int32_t activation_index; + int32_t activation_index; /**< Activation index */ + /** + * @brief Construct a new Param object for Conv2D(explicit) as default + */ Param() = default; + + /** + * @brief Construct a new Param object for Conv2D(explicit) with params + * @param [in] inputCount The number of input + * @param [in] inputs Array containing inputs + * @param [in] outputCount The number of output + * @param [in] outputs Array containing outputs + */ Param(uint32_t inputCount, const uint32_t *inputs, uint32_t outputCount, const uint32_t *outputs); }; +/** + * @brief Class to define operation node for Conv2D(explicit) + */ class Node final : public op::Node { public: + /** + * @brief Construct a new Node object for conv2D(explicit) with param + * @param [in] param Parameters for Node + */ Node(const Param ¶m) : _param(param) { // DO NOTHING } public: + /** + * @brief Destroy the Node object for conv2D(explicit) + */ virtual ~Node() = default; public: + /** + * @brief Get parameters for conv2D(explicit) + * @return Parameters of conv2D(explicit) + */ const Param ¶m(void) const { return _param; } public: + /** + * @brief Function for accepting node for conv2D(explicit) + * @param [in] v Node visitor for invoking visit function of conv2D(explicit) + * @return N/A + */ void accept(NodeVisitor &&) const override; private: @@ -80,39 +119,72 @@ private: namespace Implicit { +/** + * @brief Struct of Conv2D(implicit) operation's param + */ struct Param { - int32_t ofm_index; + int32_t ofm_index; /**< Output format index */ - int32_t ifm_index; - int32_t ker_index; - int32_t bias_index; + int32_t ifm_index; /**< Input format index */ + int32_t ker_index; /**< Kernel index */ + int32_t bias_index; /**< Bias index */ - int32_t hstride_index; - int32_t vstride_index; + int32_t hstride_index; /**< Horizontal stride index */ + int32_t vstride_index; /**< Vertical stride index */ - int32_t padding_index; - int32_t activation_index; + int32_t padding_index; /**< Padding index */ + int32_t activation_index; /**< Activation index */ + /** + * @brief Construct a new Param object for Conv2D(implicit) as default + */ Param() = default; + + /** + * @brief Construct a new Param object for Conv2D(implicit) with params + * @param [in] inputCount The number of input + * @param [in] inputs Array containing inputs + * @param [in] outputCount The number of output + * @param [in] outputs Array containing outputs + */ Param(uint32_t inputCount, const uint32_t *inputs, uint32_t outputCount, const uint32_t *outputs); }; +/** + * @brief Class to define operation node for Conv2D(implicit) + */ class Node final : public op::Node { public: + /** + * @brief Construct a new Node object for conv2D(implicit) with param + * @param [in] param Parameters for Node + */ Node(const Param ¶m) : _param(param) { // DO NOTHING } public: + /** + * @brief Destroy the Node object for conv2D(implicit) + */ virtual ~Node() = default; public: + /** + * @brief Get parameters for conv2D(implicit) + * @return Parameters of conv2D(implicit) + */ const Param ¶m(void) const { return _param; } public: + /** + * @brief Function for accepting node for conv2D(implicit) + * @param [in] v Node visitor for invoking visit function of conv2D(implicit) + * @return N/A + */ void accept(NodeVisitor &&) const override; private: diff --git a/runtimes/pure_arm_compute/src/internal/op/DepthToSpace.cc b/runtimes/pure_arm_compute/src/internal/op/DepthToSpace.cc new file mode 100644 index 000000000..db164a148 --- /dev/null +++ b/runtimes/pure_arm_compute/src/internal/op/DepthToSpace.cc @@ -0,0 +1,65 @@ +/* + * Copyright (c) 2018 Samsung Electronics Co., Ltd. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "internal/op/DepthToSpace.h" +#include "internal/op/NodeVisitor.h" + +#include <cassert> + +namespace internal +{ +namespace tflite +{ +namespace op +{ +namespace DepthToSpace +{ + +void Node::accept(NodeVisitor &&v) const { v.visit(*this); } + +} // namespace DepthToSpace +} // namespace op +} // namespace tflite +} // namespace internal + +namespace internal +{ +namespace tflite +{ +namespace op +{ +namespace DepthToSpace +{ + +Param::Param(uint32_t inputCount, const uint32_t *inputs, uint32_t outputCount, + const uint32_t *outputs) +{ + assert(inputCount == 2 && outputCount == 1); + + output_index = outputs[0]; + + // Each input should be interpreted as follows: + // + // 0 -> Input Tensor Index + // 1 -> Block size Index + input_index = inputs[0]; + block_size_index = inputs[1]; +} + +} // namespace DepthToSpace +} // namespace op +} // namespace tflite +} // namespace internal diff --git a/runtimes/pure_arm_compute/src/internal/op/DepthToSpace.h b/runtimes/pure_arm_compute/src/internal/op/DepthToSpace.h new file mode 100644 index 000000000..dd4c5c914 --- /dev/null +++ b/runtimes/pure_arm_compute/src/internal/op/DepthToSpace.h @@ -0,0 +1,70 @@ +/* + * Copyright (c) 2018 Samsung Electronics Co., Ltd. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef __INTERNAL_OP_DEPTHTOSPACE_H__ +#define __INTERNAL_OP_DEPTHTOSPACE_H__ + +#include "internal/op/Node.h" + +#include <cstdint> + +namespace internal +{ +namespace tflite +{ +namespace op +{ +namespace DepthToSpace +{ + +struct Param +{ + int32_t output_index; + + int32_t input_index; + int32_t block_size_index; + + Param() = default; + Param(uint32_t inputCount, const uint32_t *inputs, uint32_t outputCount, const uint32_t *outputs); +}; + +class Node final : public op::Node +{ +public: + Node(const Param ¶m) : _param(param) + { + // DO NOTHING + } + +public: + virtual ~Node() = default; + +public: + const Param ¶m(void) const { return _param; } + +public: + void accept(NodeVisitor &&) const override; + +private: + const Param _param; +}; + +} // namespace DepthToSpace +} // namespace op +} // namespace tflite +} // namespace internal + +#endif // __INTERNAL_OP_DEPTHTOSPACE_H__ diff --git a/runtimes/pure_arm_compute/src/internal/op/DepthwiseConv2D.h b/runtimes/pure_arm_compute/src/internal/op/DepthwiseConv2D.h index 77ab4b63e..c63e30aae 100644 --- a/runtimes/pure_arm_compute/src/internal/op/DepthwiseConv2D.h +++ b/runtimes/pure_arm_compute/src/internal/op/DepthwiseConv2D.h @@ -14,6 +14,12 @@ * limitations under the License. */ +/** + * @file DepthwiseConv2D.h + * @ingroup COM_AI_RUNTIME + * @brief This file defines internal::tflite::op::DepthwiseConv2D Param structs + * and internal::tflite::op::DepthwiseConv2D Node classes + */ #ifndef __INTERNAL_OP_DEPTHWISE_CONV_2D_H__ #define __INTERNAL_OP_DEPTHWISE_CONV_2D_H__ @@ -32,44 +38,75 @@ namespace DepthwiseConv2D namespace Explicit { +/** + * @brief Struct to have indexes for explicit padding DepthwiseConv2D operation parameter + */ struct Param { - int32_t ofm_index; + int32_t ofm_index; /**< Index of output feature map */ - int32_t ifm_index; - int32_t ker_index; - int32_t bias_index; + int32_t ifm_index; /**< Index of input feature map */ + int32_t ker_index; /**< Index of kernel */ + int32_t bias_index; /**< Index of bias */ - int32_t hstride_index; - int32_t vstride_index; + int32_t hstride_index; /**< Index of horizontal stride */ + int32_t vstride_index; /**< Index of vertical stride */ - int32_t padding_left_index; - int32_t padding_right_index; - int32_t padding_top_index; - int32_t padding_bottom_index; - - int32_t multipler_index; - int32_t activation_index; + int32_t padding_left_index; /**< Index of padding left */ + int32_t padding_right_index; /**< Index of padding right */ + int32_t padding_top_index; /**< Index of padding top */ + int32_t padding_bottom_index; /**< Index of padding bottom */ + int32_t multipler_index; /**< Index of multipler */ + int32_t activation_index; /**< Index of activation */ + /** + * @brief Construct as default + */ Param() = default; + /** + * @brief Construct a new Param object with params + * @param[in] inputCount Count of inputs + * @param[in] inputs Pointer of inputs + * @param[in] outputCount Count of outputs + * @param[in] outputs Pointer of outputs + */ Param(uint32_t inputCount, const uint32_t *inputs, uint32_t outputCount, const uint32_t *outputs); }; +/** + * @brief Class to represent an explicit padding DepthwiseConv2D operation of data structure + */ class Node final : public op::Node { public: + /** + * @brief Construct a new Node object with param + * @param[in] param Param object that makes up a Node + */ Node(const Param ¶m) : _param(param) { // DO NOTHING } public: + /** + * @brief Destruct as default + */ virtual ~Node() = default; public: + /** + * @brief Get a reference of Param object + * @return Reference of Param object + */ const Param ¶m(void) const { return _param; } public: + /** + * @brief Visit this Node by NodeVisitor + * @param[in] v Visitor + * @return N/A + */ void accept(NodeVisitor &&) const override; private: @@ -78,43 +115,74 @@ private: } // namespace Explicit +/** + * @brief Struct to have indexes for implicit padding DepthwiseConv2D operation parameter + */ namespace Implicit { struct Param { - int32_t ofm_index; - - int32_t ifm_index; - int32_t ker_index; - int32_t bias_index; + int32_t ofm_index; /**< Index of output feature map */ - int32_t hstride_index; - int32_t vstride_index; + int32_t ifm_index; /**< Index of input feature map */ + int32_t ker_index; /**< Index of kernel */ + int32_t bias_index; /**< Index of bias */ - int32_t padding_index; - int32_t multipler_index; - int32_t activation_index; + int32_t hstride_index; /**< Index of horizontal stride */ + int32_t vstride_index; /**< Index of vertical stride */ + int32_t padding_index; /**< Index of padding */ + int32_t multipler_index; /**< Index of multipler */ + int32_t activation_index; /**< Index of activation */ + /** + * @brief Construct as default + */ Param() = default; + /** + * @brief Construct a new Param object with params + * @param[in] inputCount Count of inputs + * @param[in] inputs Pointer of inputs + * @param[in] outputCount Count of outputs + * @param[in] outputs Pointer of outputs + */ Param(uint32_t inputCount, const uint32_t *inputs, uint32_t outputCount, const uint32_t *outputs); }; +/** + * @brief Class to represent an implicit padding DepthwiseConv2D operation of data structure + */ class Node final : public op::Node { public: + /** + * @brief Construct a new Node object with param + * @param[in] param Param object that makes up a Node + */ Node(const Param ¶m) : _param(param) { // DO NOTHING } public: + /** + * @brief Destruct as default + */ virtual ~Node() = default; public: + /** + * @brief Get a reference of Param object + * @return Reference of Param object + */ const Param ¶m(void) const { return _param; } public: + /** + * @brief Visit this Node by NodeVisitor + * @param[in] v Visitor + * @return N/A + */ void accept(NodeVisitor &&) const override; private: diff --git a/runtimes/pure_arm_compute/src/internal/op/Dequantize.h b/runtimes/pure_arm_compute/src/internal/op/Dequantize.h index b0645d136..f19898e9e 100644 --- a/runtimes/pure_arm_compute/src/internal/op/Dequantize.h +++ b/runtimes/pure_arm_compute/src/internal/op/Dequantize.h @@ -14,6 +14,12 @@ * limitations under the License. */ +/** + * @file Dequantize.h + * @ingroup COM_AI_RUNTIME + * @brief This file defines internal::tflite::op::Dequantize::Param struct + * and internal::tflite::op::Dequantize::Node class + */ #ifndef __INTERNAL_OP_DEQUANTIZE_H__ #define __INTERNAL_OP_DEQUANTIZE_H__ @@ -30,31 +36,62 @@ namespace op namespace Dequantize { +/** + * @brief Struct to have indexes for Dequantize operation parameter + */ struct Param { - int32_t output_index; - - int32_t input_index; + int32_t output_index; /**< Index of output feature map */ + int32_t input_index; /**< Index of input feature map */ + /** + * @brief Construct as default + */ Param() = default; + /** + * @brief Construct a new Param object with params + * @param[in] inputCount Count of inputs + * @param[in] inputs Pointer of inputs + * @param[in] outputCount Count of outputs + * @param[in] outputs Pointer of outputs + */ Param(uint32_t inputCount, const uint32_t *inputs, uint32_t outputCount, const uint32_t *outputs); }; +/** + * @brief Class to represent an Dequantize operation of data structure + */ class Node final : public op::Node { public: + /** + * @brief Construct a new Node object with param + * @param[in] param Param object that makes up a Node + */ Node(const Param ¶m) : _param(param) { // DO NOTHING } public: + /** + * @brief Destruct as default + */ virtual ~Node() = default; public: + /** + * @brief Get a reference of Param object + * @return Reference of Param object + */ const Param ¶m(void) const { return _param; } public: + /** + * @brief Visit this Node by NodeVisitor + * @param[in] v Visitor + * @return N/A + */ void accept(NodeVisitor &&) const override; private: diff --git a/runtimes/pure_arm_compute/src/internal/op/Div.h b/runtimes/pure_arm_compute/src/internal/op/Div.h index 06ed7ec21..d5fc09d19 100644 --- a/runtimes/pure_arm_compute/src/internal/op/Div.h +++ b/runtimes/pure_arm_compute/src/internal/op/Div.h @@ -14,6 +14,12 @@ * limitations under the License. */ +/** + * @file Div.h + * @ingroup COM_AI_RUNTIME + * @brief This file defines internal::tflite::op::Div::Param struct + * and internal::tflite::op::Div::Node class + */ #ifndef __INTERNAL_OP_DIV_H__ #define __INTERNAL_OP_DIV_H__ @@ -30,33 +36,64 @@ namespace op namespace Div { +/** + * @brief Struct to have indexes for operation parameter + */ struct Param { - int32_t ofm_index; - - int32_t lhs_index; - int32_t rhs_index; - int32_t activation_index; + int32_t ofm_index; /**< Index of output feature map */ + int32_t lhs_index; /**< Index of lhs */ + int32_t rhs_index; /**< Index of rhs */ + int32_t activation_index; /**< Index of activation */ + /** + * @brief Construct as default + */ Param() = default; + /** + * @brief Construct a new Param object with params + * @param[in] inputCount Count of inputs + * @param[in] inputs Pointer of inputs + * @param[in] outputCount Count of outputs + * @param[in] outputs Pointer of outputs + */ Param(uint32_t inputCount, const uint32_t *inputs, uint32_t outputCount, const uint32_t *outputs); }; +/** + * @brief Class to represent an operation of data structure + */ class Node final : public op::Node { public: + /** + * @brief Construct a new Node object with param + * @param[in] param Param object that makes up a Node + */ Node(const Param ¶m) : _param(param) { // DO NOTHING } public: + /** + * @brief Destruct as default + */ virtual ~Node() = default; public: + /** + * @brief Get a reference of Param object + * @return Reference of Param object + */ const Param ¶m(void) const { return _param; } public: + /** + * @brief Visit this Node by NodeVisitor + * @param[in] v Visitor + * @return N/A + */ void accept(NodeVisitor &&) const override; private: diff --git a/runtimes/pure_arm_compute/src/internal/op/EmbeddingLookup.h b/runtimes/pure_arm_compute/src/internal/op/EmbeddingLookup.h index 4547f27c7..17e8485f7 100644 --- a/runtimes/pure_arm_compute/src/internal/op/EmbeddingLookup.h +++ b/runtimes/pure_arm_compute/src/internal/op/EmbeddingLookup.h @@ -14,6 +14,12 @@ * limitations under the License. */ +/** + * @file EmbeddingLookup.h + * @brief This file contains accept function and params for EmbeddingLookup operation + * @ingroup COM_AI_RUNTIME + */ + #ifndef __INTERNAL_OP_EMBEDDING_LOOKUP_H__ #define __INTERNAL_OP_EMBEDDING_LOOKUP_H__ @@ -30,32 +36,65 @@ namespace op namespace EmbeddingLookup { +/** + * @brief Struct of EmbeddingLookup operation's param + */ struct Param { - int32_t output_index; + int32_t output_index; /**< Output index */ - int32_t lookups_index; - int32_t values_index; + int32_t lookups_index; /**< Lookups index */ + int32_t values_index; /**< Values index */ + /** + * @brief Construct a new Param object for EmbeddingLookup as default + */ Param() = default; + + /** + * @brief Construct a new Param object for EmbeddingLookup with params + * @param [in] inputCount The number of input + * @param [in] inputs Array containing inputs + * @param [in] outputCount The number of output + * @param [in] outputs Array containing outputs + */ Param(uint32_t inputCount, const uint32_t *inputs, uint32_t outputCount, const uint32_t *outputs); }; +/** + * @brief Class to define operation node for EmbeddingLookup + */ class Node final : public op::Node { public: + /** + * @brief Construct a new Node object for EmbeddingLookup with param + * @param [in] param Parameters for Node + */ Node(const Param ¶m) : _param(param) { // DO NOTHING } public: + /** + * @brief Destroy the Node object for EmbeddingLookup + */ virtual ~Node() = default; public: + /** + * @brief Get parameters for EmbeddingLookup + * @return Parameters of EmbeddingLookup + */ const Param ¶m(void) const { return _param; } public: + /** + * @brief Function for accepting node for EmbeddingLookup + * @param [in] v Node visitor for invoking visit function of EmbeddingLookup + * @return N/A + */ void accept(NodeVisitor &&) const override; private: diff --git a/runtimes/pure_arm_compute/src/internal/op/Equal.cc b/runtimes/pure_arm_compute/src/internal/op/Equal.cc new file mode 100644 index 000000000..b9cccc6a9 --- /dev/null +++ b/runtimes/pure_arm_compute/src/internal/op/Equal.cc @@ -0,0 +1,65 @@ +/* + * Copyright (c) 2018 Samsung Electronics Co., Ltd. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "internal/op/Equal.h" +#include "internal/op/NodeVisitor.h" + +#include <cassert> + +namespace internal +{ +namespace tflite +{ +namespace op +{ +namespace Equal +{ + +void Node::accept(NodeVisitor &&v) const { v.visit(*this); } + +} // namespace Equal +} // namespace op +} // namespace tflite +} // namespace internal + +namespace internal +{ +namespace tflite +{ +namespace op +{ +namespace Equal +{ + +Param::Param(uint32_t inputCount, const uint32_t *inputs, uint32_t outputCount, + const uint32_t *outputs) +{ + assert(inputCount == 2 && outputCount == 1); + + output_index = outputs[0]; + + // Each input should be interpreted as follows: + // + // 0 -> input1 Tensor Index + // 1 -> input2 Tensor Index + input1_index = inputs[0]; + input2_index = inputs[1]; +} + +} // namespace Equal +} // namespace op +} // namespace tflite +} // namespace internal diff --git a/runtimes/pure_arm_compute/src/internal/op/Equal.h b/runtimes/pure_arm_compute/src/internal/op/Equal.h new file mode 100644 index 000000000..78b9f846f --- /dev/null +++ b/runtimes/pure_arm_compute/src/internal/op/Equal.h @@ -0,0 +1,83 @@ +/* + * Copyright (c) 2018 Samsung Electronics Co., Ltd. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef __INTERNAL_OP_EQUAL_H__ +#define __INTERNAL_OP_EQUAL_H__ + +#include "internal/op/Node.h" + +#include <cstdint> + +namespace internal +{ +namespace tflite +{ +namespace op +{ +namespace Equal +{ + +struct Param +{ + int32_t output_index; + + int32_t input1_index; + int32_t input2_index; + + Param() = default; + Param(uint32_t inputCount, const uint32_t *inputs, uint32_t outputCount, const uint32_t *outputs); +}; + +} // namespace Equal +} // namespace op +} // namespace tflite +} // namespace internal + +namespace internal +{ +namespace tflite +{ +namespace op +{ +namespace Equal +{ +class Node final : public op::Node +{ +public: + Node(const Param ¶m) : _param(param) + { + // DO NOTHING + } + +public: + virtual ~Node() = default; + +public: + const Param ¶m(void) const { return _param; } + +public: + void accept(NodeVisitor &&) const override; + +private: + const Param _param; +}; + +} // namespace Equal +} // namespace op +} // namespace tflite +} // namespace internal + +#endif // __INTERNAL_OP_EQUAL_H__ diff --git a/runtimes/pure_arm_compute/src/internal/op/Exp.cc b/runtimes/pure_arm_compute/src/internal/op/Exp.cc new file mode 100644 index 000000000..6f1aa8f42 --- /dev/null +++ b/runtimes/pure_arm_compute/src/internal/op/Exp.cc @@ -0,0 +1,63 @@ +/* + * Copyright (c) 2018 Samsung Electronics Co., Ltd. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "internal/op/Exp.h" +#include "internal/op/NodeVisitor.h" + +#include <cassert> + +namespace internal +{ +namespace tflite +{ +namespace op +{ +namespace Exp +{ + +void Node::accept(NodeVisitor &&v) const { v.visit(*this); } + +} // namespace Exp +} // namespace op +} // namespace tflite +} // namespace internal + +namespace internal +{ +namespace tflite +{ +namespace op +{ +namespace Exp +{ + +Param::Param(uint32_t inputCount, const uint32_t *inputs, uint32_t outputCount, + const uint32_t *outputs) +{ + assert(inputCount == 1 && outputCount == 1); + + ofm_index = outputs[0]; + + // Each input should be interpreted as follows: + // + // 0 -> Input Tensor Index + ifm_index = inputs[0]; +} + +} // namespace Exp +} // namespace op +} // namespace tflite +} // namespace internal diff --git a/runtimes/pure_arm_compute/src/internal/op/Exp.h b/runtimes/pure_arm_compute/src/internal/op/Exp.h new file mode 100644 index 000000000..ac7f244b7 --- /dev/null +++ b/runtimes/pure_arm_compute/src/internal/op/Exp.h @@ -0,0 +1,69 @@ +/* + * Copyright (c) 2018 Samsung Electronics Co., Ltd. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef __INTERNAL_OP_EXP_H__ +#define __INTERNAL_OP_EXP_H__ + +#include "internal/op/Node.h" + +#include <cstdint> + +namespace internal +{ +namespace tflite +{ +namespace op +{ +namespace Exp +{ + +struct Param +{ + int32_t ofm_index; + + int32_t ifm_index; + + Param() = default; + Param(uint32_t inputCount, const uint32_t *inputs, uint32_t outputCount, const uint32_t *outputs); +}; + +class Node final : public op::Node +{ +public: + Node(const Param ¶m) : _param(param) + { + // DO NOTHING + } + +public: + virtual ~Node() = default; + +public: + const Param ¶m(void) const { return _param; } + +public: + void accept(NodeVisitor &&) const override; + +private: + const Param _param; +}; + +} // namespace Exp +} // namespace op +} // namespace tflite +} // namespace internal + +#endif // __INTERNAL_OP_EXP_H__ diff --git a/runtimes/pure_arm_compute/src/internal/op/Floor.h b/runtimes/pure_arm_compute/src/internal/op/Floor.h index 8cf2a841c..5264ec10c 100644 --- a/runtimes/pure_arm_compute/src/internal/op/Floor.h +++ b/runtimes/pure_arm_compute/src/internal/op/Floor.h @@ -14,6 +14,12 @@ * limitations under the License. */ +/** + * @file Floor.h + * @brief This file contains accept function and params for Floor operation + * @ingroup COM_AI_RUNTIME + */ + #ifndef __INTERNAL_OP_FLOOR_H__ #define __INTERNAL_OP_FLOOR_H__ @@ -30,31 +36,64 @@ namespace op namespace Floor { +/** + * @brief Struct of Floor operation's param + */ struct Param { - int32_t output_index; + int32_t output_index; /**< Output index */ - int32_t input_index; + int32_t input_index; /**< Input index */ + /** + * @brief Construct a new Param object for Floor as default + */ Param() = default; + + /** + * @brief Construct a new Param object for Floor with params + * @param [in] inputCount The number of input + * @param [in] inputs Array containing inputs + * @param [in] outputCount The number of output + * @param [in] outputs Array containing outputs + */ Param(uint32_t inputCount, const uint32_t *inputs, uint32_t outputCount, const uint32_t *outputs); }; +/** + * @brief Class to define operation node for Floor + */ class Node final : public op::Node { public: + /** + * @brief Construct a new Node object for Floor with param + * @param [in] param Parameters for Node + */ Node(const Param ¶m) : _param(param) { // DO NOTHING } public: + /** + * @brief Destroy the Node object for Floor + */ virtual ~Node() = default; public: + /** + * @brief Get parameters for Floor + * @return Parameters of Floor + */ const Param ¶m(void) const { return _param; } public: + /** + * @brief Function for accepting node for Floor + * @param [in] v Node visitor for invoking visit function of Floor + * @return N/A + */ void accept(NodeVisitor &&) const override; private: diff --git a/runtimes/pure_arm_compute/src/internal/op/FullyConnected.h b/runtimes/pure_arm_compute/src/internal/op/FullyConnected.h index 7a425a6af..434308435 100644 --- a/runtimes/pure_arm_compute/src/internal/op/FullyConnected.h +++ b/runtimes/pure_arm_compute/src/internal/op/FullyConnected.h @@ -14,6 +14,12 @@ * limitations under the License. */ +/** + * @file FullyConnected.h + * @brief This file contains accept function and params for FullyConnected operation + * @ingroup COM_AI_RUNTIME + */ + #ifndef __INTERNAL_OP_FULLY_CONNTECTED_H__ #define __INTERNAL_OP_FULLY_CONNTECTED_H__ @@ -30,34 +36,70 @@ namespace op namespace FullyConnected { +/** + * @brief Struct of FullyConnected operation's param + */ struct Param { - int32_t output_index; + int32_t output_index; /**< Output index */ - int32_t input_index; - int32_t weight_index; - int32_t bias_index; - int32_t activation_index; + int32_t input_index; /**< Input index */ + int32_t weight_index; /**< Weight index */ + int32_t bias_index; /**< Bias index */ + int32_t activation_index; /**< Activation index */ + /** + * @brief Construct a new Param object for FullyConnected as default + */ Param() = default; + + /** + * @brief Construct a new Param object for FullyConnected with params + * @param [in] inputCount The number of input + * @param [in] inputs Array containing inputs + * @param [in] outputCount The number of output + * @param [in] outputs Array containing outputs + */ Param(uint32_t inputCount, const uint32_t *inputs, uint32_t outputCount, const uint32_t *outputs); }; +/** + * @brief Class to define operation node for FullyConnected + */ class Node final : public op::Node { + /** + * @brief Construct a new Node object for FullyConnected with param + * @param [in] param Parameters for Node + */ public: + /** + * @brief Destroy the Node object for FullyConnected + */ Node(const Param ¶m) : _param(param) { // DO NOTHING } public: + /** + * @brief Destroy the Node object for FullyConnected + */ virtual ~Node() = default; public: + /** + * @brief Parameter Get parameters for FullyConnected + * @return _param Parameters of FullyConnected + */ const Param ¶m(void) const { return _param; } public: + /** + * @brief Function for accepting node for FullyConnected + * @param [in] v Node visitor for invoking visit function of FullyConnected + * @return N/A + */ void accept(NodeVisitor &&) const override; private: diff --git a/runtimes/pure_arm_compute/src/internal/op/Gather.h b/runtimes/pure_arm_compute/src/internal/op/Gather.h index 5f7fe956f..4470236eb 100644 --- a/runtimes/pure_arm_compute/src/internal/op/Gather.h +++ b/runtimes/pure_arm_compute/src/internal/op/Gather.h @@ -14,6 +14,12 @@ * limitations under the License. */ +/** + * @file Gather.h + * @ingroup COM_AI_RUNTIME + * @brief This file defines Gather operation + */ + #ifndef __INTERNAL_OP_GATHER_H__ #define __INTERNAL_OP_GATHER_H__ @@ -30,37 +36,69 @@ namespace op namespace Gather { +/** + * @brief Struct to manipulate parameter for Gather operation + */ struct Param { - int32_t ofm_index; // output + int32_t ofm_index; //!< index for output feature map - int32_t lhs_index; // input - int32_t rhs_index; // indexes - int32_t axis_index; // axis + int32_t lhs_index; //!< index for lhs tensor + int32_t rhs_index; //!< index for rhs tensor + int32_t axis_index; //!< index for axis + /** + * @brief Default Constructor + */ Param() = default; + /** + * @brief Construct a new Param object + * @param[in] inputCount the number of inputs + * @param[in] inputs pointer for input data + * @param[in] outputCount the number of outputs + * @param[in] outputs pointer for input data + */ Param(uint32_t inputCount, const uint32_t *inputs, uint32_t outputCount, const uint32_t *outputs); }; +/** + * @brief Class to define Gather Operation + */ class Node final : public op::Node { public: + /** + * @brief Construct a new Tanh Node object + * @param param Parameter for Tanh Node + */ Node(const Param ¶m) : _param(param) { // DO NOTHING } public: + /** + * @brief Default Destructor + */ virtual ~Node() = default; public: + /** + * @brief Get parameter + * @return Param reference + */ const Param ¶m(void) const { return _param; } public: + /** + * @brief Accept a NodeVisitor so that it can visit this node + * @param [in] v Visitor + * @return N/A + */ void accept(NodeVisitor &&) const override; private: - const Param _param; + const Param _param; //!< parameter for Gather node }; } // namespace Gather diff --git a/runtimes/pure_arm_compute/src/internal/op/HashtableLookup.cc b/runtimes/pure_arm_compute/src/internal/op/HashtableLookup.cc index 30a853a64..7e04ecf82 100644 --- a/runtimes/pure_arm_compute/src/internal/op/HashtableLookup.cc +++ b/runtimes/pure_arm_compute/src/internal/op/HashtableLookup.cc @@ -1,52 +1,68 @@ -#include "internal/op/HashtableLookup.h"
-#include "internal/op/NodeVisitor.h"
-
-#include <cassert>
-
-namespace internal
-{
-namespace tflite
-{
-namespace op
-{
-namespace HashtableLookup
-{
-
-void Node::accept(NodeVisitor &&v) const { v.visit(*this); }
-
-} // namespace HashtableLookup
-} // namespace op
-} // namespace tflite
-} // namespace internal
-
-namespace internal
-{
-namespace tflite
-{
-namespace op
-{
-namespace HashtableLookup
-{
-
-Param::Param(uint32_t inputCount, const uint32_t *inputs, uint32_t outputCount,
- const uint32_t *outputs)
-{
- assert(inputCount == 3 && outputCount == 2);
-
- output_index = outputs[0];
- hits_index = outputs[1];
-
- // Each input should be interpreted as follows:
- //
- // 0 -> Lookups Index
- // 1 -> Keys Index
- // 2 -> Values Index
- lookups_index = inputs[0];
- keys_index = inputs[1];
- values_index = inputs[2];
-}
-
-} // namespace HashtableLookup
-} // namespace op
-} // namespace tflite
-} // namespace internal
+/* + * Copyright (c) 2018 Samsung Electronics Co., Ltd. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "internal/op/HashtableLookup.h" +#include "internal/op/NodeVisitor.h" + +#include <cassert> + +namespace internal +{ +namespace tflite +{ +namespace op +{ +namespace HashtableLookup +{ + +void Node::accept(NodeVisitor &&v) const { v.visit(*this); } + +} // namespace HashtableLookup +} // namespace op +} // namespace tflite +} // namespace internal + +namespace internal +{ +namespace tflite +{ +namespace op +{ +namespace HashtableLookup +{ + +Param::Param(uint32_t inputCount, const uint32_t *inputs, uint32_t outputCount, + const uint32_t *outputs) +{ + assert(inputCount == 3 && outputCount == 2); + + output_index = outputs[0]; + hits_index = outputs[1]; + + // Each input should be interpreted as follows: + // + // 0 -> Lookups Index + // 1 -> Keys Index + // 2 -> Values Index + lookups_index = inputs[0]; + keys_index = inputs[1]; + values_index = inputs[2]; +} + +} // namespace HashtableLookup +} // namespace op +} // namespace tflite +} // namespace internal diff --git a/runtimes/pure_arm_compute/src/internal/op/HashtableLookup.h b/runtimes/pure_arm_compute/src/internal/op/HashtableLookup.h index 192da2aae..a5b43d1c7 100644 --- a/runtimes/pure_arm_compute/src/internal/op/HashtableLookup.h +++ b/runtimes/pure_arm_compute/src/internal/op/HashtableLookup.h @@ -1,56 +1,109 @@ -#ifndef __INTERNAL_OP_HASHTABLE_LOOKUP_H__
-#define __INTERNAL_OP_HASHTABLE_LOOKUP_H__
-
-#include "internal/op/Node.h"
-
-#include <cstdint>
-
-namespace internal
-{
-namespace tflite
-{
-namespace op
-{
-namespace HashtableLookup
-{
-
-struct Param
-{
- int32_t output_index;
- int32_t hits_index;
-
- int32_t lookups_index;
- int32_t values_index;
- int32_t keys_index;
-
- Param() = default;
- Param(uint32_t inputCount, const uint32_t *inputs, uint32_t outputCount, const uint32_t *outputs);
-};
-
-class Node final : public op::Node
-{
-public:
- Node(const Param ¶m) : _param(param)
- {
- // DO NOTHING
- }
-
-public:
- virtual ~Node() = default;
-
-public:
- const Param ¶m(void) const { return _param; }
-
-public:
- void accept(NodeVisitor &&) const override;
-
-private:
- const Param _param;
-};
-
-} // namespace HashtableLookup
-} // namespace op
-} // namespace tflite
-} // namespace internal
-
-#endif // __INTERNAL_OP_HASHTABLE_LOOKUP_H__
+/* + * Copyright (c) 2018 Samsung Electronics Co., Ltd. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * @file HashtableLookup.h + * @ingroup COM_AI_RUNTIME + * @brief This file defines internal::tflite::op::HashtableLookup::Param struct + * and internal::tflite::op::HashtableLookup::Node class + */ +#ifndef __INTERNAL_OP_HASHTABLE_LOOKUP_H__ +#define __INTERNAL_OP_HASHTABLE_LOOKUP_H__ + +#include "internal/op/Node.h" + +#include <cstdint> + +namespace internal +{ +namespace tflite +{ +namespace op +{ +namespace HashtableLookup +{ + +/** + * @brief Struct to have indexes for operation parameter + */ +struct Param +{ + int32_t output_index; /**< Index of output feature map */ + int32_t hits_index; /**< Index of hits */ + + int32_t lookups_index; /**< Index of lookups */ + int32_t values_index; /**< Index of values */ + int32_t keys_index; /**< Index of keys */ + /** + * @brief Construct as default + */ + Param() = default; + /** + * @brief Construct a new Param object with params + * @param[in] inputCount Count of inputs + * @param[in] inputs Pointer of inputs + * @param[in] outputCount Count of outputs + * @param[in] outputs Pointer of outputs + */ + Param(uint32_t inputCount, const uint32_t *inputs, uint32_t outputCount, const uint32_t *outputs); +}; + +/** + * @brief Class to represent an operation of data structure + */ +class Node final : public op::Node +{ +public: + /** + * @brief Construct a new Node object with param + * @param[in] param Param object that makes up a Node + */ + Node(const Param ¶m) : _param(param) + { + // DO NOTHING + } + +public: + /** + * @brief Destruct as default + */ + virtual ~Node() = default; + +public: + /** + * @brief Get a reference of Param object + * @return Reference of Param object + */ + const Param ¶m(void) const { return _param; } + +public: + /** + * @brief Visit this Node by NodeVisitor + * @param[in] v Visitor + * @return N/A + */ + void accept(NodeVisitor &&) const override; + +private: + const Param _param; +}; + +} // namespace HashtableLookup +} // namespace op +} // namespace tflite +} // namespace internal + +#endif // __INTERNAL_OP_HASHTABLE_LOOKUP_H__ diff --git a/runtimes/pure_arm_compute/src/internal/op/L2Normalization.cc b/runtimes/pure_arm_compute/src/internal/op/L2Normalization.cc index 449540178..44a6ee63d 100644 --- a/runtimes/pure_arm_compute/src/internal/op/L2Normalization.cc +++ b/runtimes/pure_arm_compute/src/internal/op/L2Normalization.cc @@ -1,3 +1,19 @@ +/* + * Copyright (c) 2018 Samsung Electronics Co., Ltd. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + #include "internal/op/L2Normalization.h" #include "internal/op/NodeVisitor.h" diff --git a/runtimes/pure_arm_compute/src/internal/op/L2Normalization.h b/runtimes/pure_arm_compute/src/internal/op/L2Normalization.h index 70fa2fb7e..2e94fac11 100644 --- a/runtimes/pure_arm_compute/src/internal/op/L2Normalization.h +++ b/runtimes/pure_arm_compute/src/internal/op/L2Normalization.h @@ -1,3 +1,25 @@ +/* + * Copyright (c) 2018 Samsung Electronics Co., Ltd. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * @file L2Normalization.h + * @ingroup COM_AI_RUNTIME + * @brief This file defines internal::tflite::op::L2Normalization::Param struct + * and internal::tflite::op::L2Normalization::Node class + */ #ifndef __INTERNAL_OP_L2_NORMALIZATION_H__ #define __INTERNAL_OP_L2_NORMALIZATION_H__ @@ -14,31 +36,62 @@ namespace op namespace L2Normalization { +/** + * @brief Struct to have indexes for L2Normalization operation parameter + */ struct Param { - int32_t ofm_index; - - int32_t ifm_index; + int32_t ofm_index; /**< Index of output feature map */ + int32_t ifm_index; /**< Index of input feature map */ + /** + * @brief Construct as default + */ Param() = default; + /** + * @brief Construct a new Param object with params + * @param[in] inputCount Count of inputs + * @param[in] inputs Pointer of inputs + * @param[in] outputCount Count of outputs + * @param[in] outputs Pointer of outputs + */ Param(uint32_t inputCount, const uint32_t *inputs, uint32_t outputCount, const uint32_t *outputs); }; +/** + * @brief Class to represent an L2Normalization operation of data structure + */ class Node final : public op::Node { public: + /** + * @brief Construct a new Node object with param + * @param[in] param Param object that makes up a Node + */ Node(const Param ¶m) : _param(param) { // DO NOTHING } public: + /** + * @brief Destruct as default + */ virtual ~Node() = default; public: + /** + * @brief Get a reference of Param object + * @return Reference of Param object + */ const Param ¶m(void) const { return _param; } public: + /** + * @brief Visit this Node by NodeVisitor + * @param[in] v Visitor + * @return N/A + */ void accept(NodeVisitor &&) const override; private: diff --git a/runtimes/pure_arm_compute/src/internal/op/L2Pool2D.cc b/runtimes/pure_arm_compute/src/internal/op/L2Pool2D.cc index 73c1bb65c..64041ab49 100644 --- a/runtimes/pure_arm_compute/src/internal/op/L2Pool2D.cc +++ b/runtimes/pure_arm_compute/src/internal/op/L2Pool2D.cc @@ -1,124 +1,124 @@ -/*
- * Copyright (c) 2018 Samsung Electronics Co., Ltd. All Rights Reserved
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "internal/op/L2Pool2D.h"
-#include "internal/op/NodeVisitor.h"
-
-#include <cassert>
-
-namespace internal
-{
-namespace tflite
-{
-namespace op
-{
-namespace L2Pool2D
-{
-namespace Explicit
-{
-
-void Node::accept(NodeVisitor &&v) const { v.visit(*this); }
-
-} // namespace Explicit
-
-namespace Implicit
-{
-
-void Node::accept(NodeVisitor &&v) const { v.visit(*this); }
-
-} // namespace Implicit
-} // namespace L2Pool2D
-} // namespace op
-} // namespace tflite
-} // namespace internal
-
-namespace internal
-{
-namespace tflite
-{
-namespace op
-{
-namespace L2Pool2D
-{
-namespace Explicit
-{
-
-Param::Param(uint32_t inputCount, const uint32_t *inputs, uint32_t outputCount,
- const uint32_t *outputs)
-{
- assert(inputCount == 10 && outputCount == 1);
-
- ofm_index = outputs[0];
-
- // Each input should be interpreted as follows:
- //
- // 0 -> IFM Tensor Index
- // 1 -> Padding_left index
- // 2 -> Padding_right index
- // 3 -> Padding_top index
- // 4 -> Padding_bottom index
- // 5 -> Horizontal (over width) Stride Index
- // 6 -> Vertial (over height) Stride Index
- // 7 -> Filter Width Index
- // 8 -> Filter Height Index
- // 9 -> FuseCode (activation) Index
- ifm_index = inputs[0];
- padding_left_index = inputs[1];
- padding_right_index = inputs[2];
- padding_top_index = inputs[3];
- padding_bottom_index = inputs[4];
- hstride_index = inputs[5];
- vstride_index = inputs[6];
- kw_index = inputs[7];
- kh_index = inputs[8];
- activation_index = inputs[9];
-}
-
-} // namespace Explicit
-
-namespace Implicit
-{
-
-Param::Param(uint32_t inputCount, const uint32_t *inputs, uint32_t outputCount,
- const uint32_t *outputs)
-{
- assert(inputCount == 7 && outputCount == 1);
-
- ofm_index = outputs[0];
-
- // Each input should be interpreted as follows:
- //
- // 0 -> IFM Tensor Index
- // 1 -> Padding Code (ANEURALNETWORKS_PADDING_SAME or ANEURALNETWORKS_PADDING_VALID) Index
- // 2 -> Horizontal (over width) Stride Index
- // 3 -> Vertial (over height) Stride Index
- // 4 -> Filter Width Index
- // 5 -> Filter Height Index
- // 6 -> FuseCode (activation) Index
- ifm_index = inputs[0];
- padding_index = inputs[1];
- hstride_index = inputs[2];
- vstride_index = inputs[3];
- kw_index = inputs[4];
- kh_index = inputs[5];
- activation_index = inputs[6];
-}
-
-} // namespace Implicit
-} // namespace L2Pool2D
-} // namespace op
-} // namespace tflite
-} // namespace internal
+/* + * Copyright (c) 2018 Samsung Electronics Co., Ltd. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "internal/op/L2Pool2D.h" +#include "internal/op/NodeVisitor.h" + +#include <cassert> + +namespace internal +{ +namespace tflite +{ +namespace op +{ +namespace L2Pool2D +{ +namespace Explicit +{ + +void Node::accept(NodeVisitor &&v) const { v.visit(*this); } + +} // namespace Explicit + +namespace Implicit +{ + +void Node::accept(NodeVisitor &&v) const { v.visit(*this); } + +} // namespace Implicit +} // namespace L2Pool2D +} // namespace op +} // namespace tflite +} // namespace internal + +namespace internal +{ +namespace tflite +{ +namespace op +{ +namespace L2Pool2D +{ +namespace Explicit +{ + +Param::Param(uint32_t inputCount, const uint32_t *inputs, uint32_t outputCount, + const uint32_t *outputs) +{ + assert(inputCount == 10 && outputCount == 1); + + ofm_index = outputs[0]; + + // Each input should be interpreted as follows: + // + // 0 -> IFM Tensor Index + // 1 -> Padding_left index + // 2 -> Padding_right index + // 3 -> Padding_top index + // 4 -> Padding_bottom index + // 5 -> Horizontal (over width) Stride Index + // 6 -> Vertial (over height) Stride Index + // 7 -> Filter Width Index + // 8 -> Filter Height Index + // 9 -> FuseCode (activation) Index + ifm_index = inputs[0]; + padding_left_index = inputs[1]; + padding_right_index = inputs[2]; + padding_top_index = inputs[3]; + padding_bottom_index = inputs[4]; + hstride_index = inputs[5]; + vstride_index = inputs[6]; + kw_index = inputs[7]; + kh_index = inputs[8]; + activation_index = inputs[9]; +} + +} // namespace Explicit + +namespace Implicit +{ + +Param::Param(uint32_t inputCount, const uint32_t *inputs, uint32_t outputCount, + const uint32_t *outputs) +{ + assert(inputCount == 7 && outputCount == 1); + + ofm_index = outputs[0]; + + // Each input should be interpreted as follows: + // + // 0 -> IFM Tensor Index + // 1 -> Padding Code (ANEURALNETWORKS_PADDING_SAME or ANEURALNETWORKS_PADDING_VALID) Index + // 2 -> Horizontal (over width) Stride Index + // 3 -> Vertial (over height) Stride Index + // 4 -> Filter Width Index + // 5 -> Filter Height Index + // 6 -> FuseCode (activation) Index + ifm_index = inputs[0]; + padding_index = inputs[1]; + hstride_index = inputs[2]; + vstride_index = inputs[3]; + kw_index = inputs[4]; + kh_index = inputs[5]; + activation_index = inputs[6]; +} + +} // namespace Implicit +} // namespace L2Pool2D +} // namespace op +} // namespace tflite +} // namespace internal diff --git a/runtimes/pure_arm_compute/src/internal/op/L2Pool2D.h b/runtimes/pure_arm_compute/src/internal/op/L2Pool2D.h index f4a25539b..facb223c7 100644 --- a/runtimes/pure_arm_compute/src/internal/op/L2Pool2D.h +++ b/runtimes/pure_arm_compute/src/internal/op/L2Pool2D.h @@ -1,130 +1,198 @@ -/*
- * Copyright (c) 2018 Samsung Electronics Co., Ltd. All Rights Reserved
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef __INTERNAL_OP_L2_POOL_2D_H__
-#define __INTERNAL_OP_L2_POOL_2D_H__
-
-#include "internal/op/Node.h"
-
-#include <cstdint>
-
-namespace internal
-{
-namespace tflite
-{
-namespace op
-{
-namespace L2Pool2D
-{
-namespace Explicit
-{
-
-struct Param
-{
- int32_t ofm_index;
-
- int32_t ifm_index;
-
- int32_t kw_index;
- int32_t kh_index;
-
- int32_t hstride_index;
- int32_t vstride_index;
-
- int32_t padding_left_index;
- int32_t padding_right_index;
- int32_t padding_top_index;
- int32_t padding_bottom_index;
-
- int32_t activation_index;
-
- Param() = default;
- Param(uint32_t inputCount, const uint32_t *inputs, uint32_t outputCount, const uint32_t *outputs);
-};
-
-class Node final : public op::Node
-{
-public:
- Node(const Param ¶m) : _param(param)
- {
- // DO NOTHING
- }
-
-public:
- virtual ~Node() = default;
-
-public:
- const Param ¶m(void) const { return _param; }
-
-public:
- void accept(NodeVisitor &&) const override;
-
-private:
- const Param _param;
-};
-
-} // namespace Explicit
-
-namespace Implicit
-{
-
-struct Param
-{
- int32_t ofm_index;
-
- int32_t ifm_index;
-
- int32_t kw_index;
- int32_t kh_index;
-
- int32_t hstride_index;
- int32_t vstride_index;
-
- int32_t padding_index;
- int32_t activation_index;
-
- Param() = default;
- Param(uint32_t inputCount, const uint32_t *inputs, uint32_t outputCount, const uint32_t *outputs);
-};
-
-class Node final : public op::Node
-{
-public:
- Node(const Param ¶m) : _param(param)
- {
- // DO NOTHING
- }
-
-public:
- virtual ~Node() = default;
-
-public:
- const Param ¶m(void) const { return _param; }
-
-public:
- void accept(NodeVisitor &&) const override;
-
-private:
- const Param _param;
-};
-
-} // namespace Implicit
-} // namespace L2Pool2D
-} // namespace op
-} // namespace tflite
-} // namespace internal
-
-#endif // __INTERNAL_OP_L2_POOL_2D_H__
+/* + * Copyright (c) 2018 Samsung Electronics Co., Ltd. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * @file L2Pool2D.h + * @ingroup COM_AI_RUNTIME + * @brief This file defines internal::tflite::op::L2Pool2D Param structs + * and internal::tflite::op::L2Pool2D Node classes + */ +#ifndef __INTERNAL_OP_L2_POOL_2D_H__ +#define __INTERNAL_OP_L2_POOL_2D_H__ + +#include "internal/op/Node.h" + +#include <cstdint> + +namespace internal +{ +namespace tflite +{ +namespace op +{ +namespace L2Pool2D +{ +namespace Explicit +{ + +/** + * @brief Struct to have indexes for operation parameter + */ +struct Param +{ + int32_t ofm_index; /**< Index of output feature map */ + + int32_t ifm_index; /**< Index of input feature map */ + + int32_t kw_index; /**< Index of kernel width */ + int32_t kh_index; /**< Index of kernel height */ + + int32_t hstride_index; /**< Index of horizontal stride */ + int32_t vstride_index; /**< Index of vertical stride */ + + int32_t padding_left_index; /**< Index of padding left */ + int32_t padding_right_index; /**< Index of padding right */ + int32_t padding_top_index; /**< Index of padding top */ + int32_t padding_bottom_index; /**< Index of padding bottom */ + + int32_t activation_index; /**< Index of activation */ + /** + * @brief Construct as default + */ + Param() = default; + /** + * @brief Construct a new Param object with params + * @param[in] inputCount Count of inputs + * @param[in] inputs Pointer of inputs + * @param[in] outputCount Count of outputs + * @param[in] outputs Pointer of outputs + */ + Param(uint32_t inputCount, const uint32_t *inputs, uint32_t outputCount, const uint32_t *outputs); +}; + +/** + * @brief Class to represent an operation of data structure + */ +class Node final : public op::Node +{ +public: + /** + * @brief Construct a new Node object with param + * @param[in] param Param object that makes up a Node + */ + Node(const Param ¶m) : _param(param) + { + // DO NOTHING + } + +public: + /** + * @brief Destruct as default + */ + virtual ~Node() = default; + +public: + /** + * @brief Get a reference of Param object + * @return Reference of Param object + */ + const Param ¶m(void) const { return _param; } + +public: + /** + * @brief Visit this Node by NodeVisitor + * @param[in] v Visitor + * @return N/A + */ + void accept(NodeVisitor &&) const override; + +private: + const Param _param; +}; + +} // namespace Explicit + +namespace Implicit +{ + +/** + * @brief Struct to have indexes for operation parameter + */ +struct Param +{ + int32_t ofm_index; /**< Index of output feature map */ + + int32_t ifm_index; /**< Index of input feature map */ + + int32_t kw_index; /**< Index of kernel width */ + int32_t kh_index; /**< Index of kernel height */ + + int32_t hstride_index; /**< Index of horizontal stride */ + int32_t vstride_index; /**< Index of vertical stride */ + + int32_t padding_index; /**< Index of padding */ + int32_t activation_index; /**< Index of activation */ + /** + * @brief Construct as default + */ + Param() = default; + /** + * @brief Construct a new Param object with params + * @param[in] inputCount Count of inputs + * @param[in] inputs Pointer of inputs + * @param[in] outputCount Count of outputs + * @param[in] outputs Pointer of outputs + */ + Param(uint32_t inputCount, const uint32_t *inputs, uint32_t outputCount, const uint32_t *outputs); +}; + +/** + * @brief Class to represent an operation of data structure + */ +class Node final : public op::Node +{ +public: + /** + * @brief Construct a new Node object with param + * @param[in] param Param object that makes up a Node + */ + Node(const Param ¶m) : _param(param) + { + // DO NOTHING + } + +public: + /** + * @brief Destruct as default + */ + virtual ~Node() = default; + +public: + /** + * @brief Get a reference of Param object + * @return Reference of Param object + */ + const Param ¶m(void) const { return _param; } + +public: + /** + * @brief Visit this Node by NodeVisitor + * @param[in] v Visitor + * @return N/A + */ + void accept(NodeVisitor &&) const override; + +private: + const Param _param; +}; + +} // namespace Implicit +} // namespace L2Pool2D +} // namespace op +} // namespace tflite +} // namespace internal + +#endif // __INTERNAL_OP_L2_POOL_2D_H__ diff --git a/runtimes/pure_arm_compute/src/internal/op/LocalResponseNormalization.cc b/runtimes/pure_arm_compute/src/internal/op/LocalResponseNormalization.cc new file mode 100644 index 000000000..b7419d923 --- /dev/null +++ b/runtimes/pure_arm_compute/src/internal/op/LocalResponseNormalization.cc @@ -0,0 +1,64 @@ +/* + * Copyright (c) 2018 Samsung Electronics Co., Ltd. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "internal/op/LocalResponseNormalization.h" +#include "internal/op/NodeVisitor.h" + +#include <cassert> + +namespace internal +{ +namespace tflite +{ +namespace op +{ +namespace LocalResponseNormalization +{ + +void Node::accept(NodeVisitor &&v) const { v.visit(*this); } + +} // namespace LocalResponseNormalization +} // namespace op +} // namespace tflite +} // namespace internal + +namespace internal +{ +namespace tflite +{ +namespace op +{ +namespace LocalResponseNormalization +{ + +Param::Param(uint32_t inputCount, const uint32_t *inputs, uint32_t outputCount, + const uint32_t *outputs) +{ + assert(inputCount == 5 && outputCount == 1); + + ofm_index = outputs[0]; + + ifm_index = inputs[0]; + radius_index = inputs[1]; + bias_index = inputs[2]; + alpha_index = inputs[3]; + beta_index = inputs[4]; +} + +} // namespace LocalResponseNormalization +} // namespace op +} // namespace tflite +} // namespace internal diff --git a/runtimes/pure_arm_compute/src/internal/op/LocalResponseNormalization.h b/runtimes/pure_arm_compute/src/internal/op/LocalResponseNormalization.h new file mode 100644 index 000000000..29e0699ad --- /dev/null +++ b/runtimes/pure_arm_compute/src/internal/op/LocalResponseNormalization.h @@ -0,0 +1,73 @@ +/* + * Copyright (c) 2018 Samsung Electronics Co., Ltd. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef __INTERNAL_OP_LOCAL_RESPONSE_NORMALIZATION_H__ +#define __INTERNAL_OP_LOCAL_RESPONSE_NORMALIZATION_H__ + +#include "internal/op/Node.h" + +#include <cstdint> + +namespace internal +{ +namespace tflite +{ +namespace op +{ +namespace LocalResponseNormalization +{ + +struct Param +{ + int32_t ofm_index; + + int32_t ifm_index; + int32_t radius_index; + int32_t bias_index; + int32_t alpha_index; + int32_t beta_index; + + Param() = default; + Param(uint32_t inputCount, const uint32_t *inputs, uint32_t outputCount, const uint32_t *outputs); +}; + +class Node final : public op::Node +{ +public: + Node(const Param ¶m) : _param(param) + { + // DO NOTHING + } + +public: + virtual ~Node() = default; + +public: + const Param ¶m(void) const { return _param; } + +public: + void accept(NodeVisitor &&) const override; + +private: + const Param _param; +}; + +} // namespace LocalResponseNormalization +} // namespace op +} // namespace tflite +} // namespace internal + +#endif // __INTERNAL_OP_LOCAL_RESPONSE_NORMALIZATION_H__ diff --git a/runtimes/pure_arm_compute/src/internal/op/LogicalAnd.cc b/runtimes/pure_arm_compute/src/internal/op/LogicalAnd.cc new file mode 100644 index 000000000..5b7da4d3b --- /dev/null +++ b/runtimes/pure_arm_compute/src/internal/op/LogicalAnd.cc @@ -0,0 +1,65 @@ +/* + * Copyright (c) 2018 Samsung Electronics Co., Ltd. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "internal/op/LogicalAnd.h" +#include "internal/op/NodeVisitor.h" + +#include <cassert> + +namespace internal +{ +namespace tflite +{ +namespace op +{ +namespace LogicalAnd +{ + +void Node::accept(NodeVisitor &&v) const { v.visit(*this); } + +} // namespace LogicalAnd +} // namespace op +} // namespace tflite +} // namespace internal + +namespace internal +{ +namespace tflite +{ +namespace op +{ +namespace LogicalAnd +{ + +Param::Param(uint32_t inputCount, const uint32_t *inputs, uint32_t outputCount, + const uint32_t *outputs) +{ + assert(inputCount == 2 && outputCount == 1); + + output_index = outputs[0]; + + // Each input should be interpreted as follows: + // + // 0 -> input1 Tensor Index + // 1 -> input2 Tensor Index + input1_index = inputs[0]; + input2_index = inputs[1]; +} + +} // namespace LogicalAnd +} // namespace op +} // namespace tflite +} // namespace internal diff --git a/runtimes/pure_arm_compute/src/internal/op/LogicalAnd.h b/runtimes/pure_arm_compute/src/internal/op/LogicalAnd.h new file mode 100644 index 000000000..2f53f756d --- /dev/null +++ b/runtimes/pure_arm_compute/src/internal/op/LogicalAnd.h @@ -0,0 +1,83 @@ +/* + * Copyright (c) 2018 Samsung Electronics Co., Ltd. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef __INTERNAL_OP_LOGICAL_AND_H__ +#define __INTERNAL_OP_LOGICAL_AND_H__ + +#include "internal/op/Node.h" + +#include <cstdint> + +namespace internal +{ +namespace tflite +{ +namespace op +{ +namespace LogicalAnd +{ + +struct Param +{ + int32_t output_index; + + int32_t input1_index; + int32_t input2_index; + + Param() = default; + Param(uint32_t inputCount, const uint32_t *inputs, uint32_t outputCount, const uint32_t *outputs); +}; + +} // namespace LogicalAnd +} // namespace op +} // namespace tflite +} // namespace internal + +namespace internal +{ +namespace tflite +{ +namespace op +{ +namespace LogicalAnd +{ +class Node final : public op::Node +{ +public: + Node(const Param ¶m) : _param(param) + { + // DO NOTHING + } + +public: + virtual ~Node() = default; + +public: + const Param ¶m(void) const { return _param; } + +public: + void accept(NodeVisitor &&) const override; + +private: + const Param _param; +}; + +} // namespace LogicalAnd +} // namespace op +} // namespace tflite +} // namespace internal + +#endif // __INTERNAL_OP_LOGICAL_AND_H__ diff --git a/runtimes/pure_arm_compute/src/internal/op/LogicalNot.cc b/runtimes/pure_arm_compute/src/internal/op/LogicalNot.cc new file mode 100644 index 000000000..4cb6a8e2a --- /dev/null +++ b/runtimes/pure_arm_compute/src/internal/op/LogicalNot.cc @@ -0,0 +1,60 @@ +/* + * Copyright (c) 2018 Samsung Electronics Co., Ltd. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "internal/op/LogicalNot.h" +#include "internal/op/NodeVisitor.h" + +#include <cassert> + +namespace internal +{ +namespace tflite +{ +namespace op +{ +namespace LogicalNot +{ + +void Node::accept(NodeVisitor &&v) const { v.visit(*this); } + +} // namespace LogicalNot +} // namespace op +} // namespace tflite +} // namespace internal + +namespace internal +{ +namespace tflite +{ +namespace op +{ +namespace LogicalNot +{ + +Param::Param(uint32_t inputCount, const uint32_t *inputs, uint32_t outputCount, + const uint32_t *outputs) +{ + assert(inputCount == 1 && outputCount == 1); + + output_index = outputs[0]; + + input_index = inputs[0]; +} + +} // namespace LogicalNot +} // namespace op +} // namespace tflite +} // namespace internal diff --git a/runtimes/pure_arm_compute/src/internal/op/LogicalNot.h b/runtimes/pure_arm_compute/src/internal/op/LogicalNot.h new file mode 100644 index 000000000..9593deafe --- /dev/null +++ b/runtimes/pure_arm_compute/src/internal/op/LogicalNot.h @@ -0,0 +1,82 @@ +/* + * Copyright (c) 2018 Samsung Electronics Co., Ltd. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef __INTERNAL_OP_LOGICAL_NOT_H__ +#define __INTERNAL_OP_LOGICAL_NOT_H__ + +#include "internal/op/Node.h" + +#include <cstdint> + +namespace internal +{ +namespace tflite +{ +namespace op +{ +namespace LogicalNot +{ + +struct Param +{ + int32_t output_index; + + int32_t input_index; + + Param() = default; + Param(uint32_t inputCount, const uint32_t *inputs, uint32_t outputCount, const uint32_t *outputs); +}; + +} // namespace LogicalNot +} // namespace op +} // namespace tflite +} // namespace internal + +namespace internal +{ +namespace tflite +{ +namespace op +{ +namespace LogicalNot +{ +class Node final : public op::Node +{ +public: + Node(const Param ¶m) : _param(param) + { + // DO NOTHING + } + +public: + virtual ~Node() = default; + +public: + const Param ¶m(void) const { return _param; } + +public: + void accept(NodeVisitor &&) const override; + +private: + const Param _param; +}; + +} // namespace LogicalNot +} // namespace op +} // namespace tflite +} // namespace internal + +#endif // __INTERNAL_OP_LOGICAL_NOT_H__ diff --git a/runtimes/pure_arm_compute/src/internal/op/LogicalOr.cc b/runtimes/pure_arm_compute/src/internal/op/LogicalOr.cc new file mode 100644 index 000000000..8295f6f0b --- /dev/null +++ b/runtimes/pure_arm_compute/src/internal/op/LogicalOr.cc @@ -0,0 +1,65 @@ +/* + * Copyright (c) 2018 Samsung Electronics Co., Ltd. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "internal/op/LogicalOr.h" +#include "internal/op/NodeVisitor.h" + +#include <cassert> + +namespace internal +{ +namespace tflite +{ +namespace op +{ +namespace LogicalOr +{ + +void Node::accept(NodeVisitor &&v) const { v.visit(*this); } + +} // namespace LogicalOr +} // namespace op +} // namespace tflite +} // namespace internal + +namespace internal +{ +namespace tflite +{ +namespace op +{ +namespace LogicalOr +{ + +Param::Param(uint32_t inputCount, const uint32_t *inputs, uint32_t outputCount, + const uint32_t *outputs) +{ + assert(inputCount == 2 && outputCount == 1); + + output_index = outputs[0]; + + // Each input should be interpreted as follows: + // + // 0 -> input1 Tensor Index + // 1 -> input2 Tensor Index + input1_index = inputs[0]; + input2_index = inputs[1]; +} + +} // namespace LogicalOr +} // namespace op +} // namespace tflite +} // namespace internal diff --git a/runtimes/pure_arm_compute/src/internal/op/LogicalOr.h b/runtimes/pure_arm_compute/src/internal/op/LogicalOr.h new file mode 100644 index 000000000..6487fa720 --- /dev/null +++ b/runtimes/pure_arm_compute/src/internal/op/LogicalOr.h @@ -0,0 +1,83 @@ +/* + * Copyright (c) 2018 Samsung Electronics Co., Ltd. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef __INTERNAL_OP_LOGICAL_OR_H__ +#define __INTERNAL_OP_LOGICAL_OR_H__ + +#include "internal/op/Node.h" + +#include <cstdint> + +namespace internal +{ +namespace tflite +{ +namespace op +{ +namespace LogicalOr +{ + +struct Param +{ + int32_t output_index; + + int32_t input1_index; + int32_t input2_index; + + Param() = default; + Param(uint32_t inputCount, const uint32_t *inputs, uint32_t outputCount, const uint32_t *outputs); +}; + +} // namespace LogicalOr +} // namespace op +} // namespace tflite +} // namespace internal + +namespace internal +{ +namespace tflite +{ +namespace op +{ +namespace LogicalOr +{ +class Node final : public op::Node +{ +public: + Node(const Param ¶m) : _param(param) + { + // DO NOTHING + } + +public: + virtual ~Node() = default; + +public: + const Param ¶m(void) const { return _param; } + +public: + void accept(NodeVisitor &&) const override; + +private: + const Param _param; +}; + +} // namespace LogicalOr +} // namespace op +} // namespace tflite +} // namespace internal + +#endif // __INTERNAL_OP_LOGICAL_OR_H__ diff --git a/runtimes/pure_arm_compute/src/internal/op/Logistic.h b/runtimes/pure_arm_compute/src/internal/op/Logistic.h index db8935846..a42fdc0d4 100644 --- a/runtimes/pure_arm_compute/src/internal/op/Logistic.h +++ b/runtimes/pure_arm_compute/src/internal/op/Logistic.h @@ -14,6 +14,12 @@ * limitations under the License. */ +/** + * @file Logistic.h + * @ingroup COM_AI_RUNTIME + * @brief This file defines internal::tflite::op::Logistic::Param struct + * and internal::tflite::op::Logistic::Node class + */ #ifndef __INTERNAL_OP_LOGISTIC_H__ #define __INTERNAL_OP_LOGISTIC_H__ @@ -30,31 +36,61 @@ namespace op namespace Logistic { +/** + * @brief Struct to have indexes for operation parameter + */ struct Param { - int32_t ofm_index; - - int32_t ifm_index; + int32_t ofm_index; /**< Index of output feature map */ + int32_t ifm_index; /**< Index of input feature map */ + /** + * @brief Construct as default + */ Param() = default; + /** + * @brief Construct a new Param object with params + * @param[in] inputCount Count of inputs + * @param[in] inputs Pointer of inputs + * @param[in] outputCount Count of outputs + * @param[in] outputs Pointer of outputs + */ Param(uint32_t inputCount, const uint32_t *inputs, uint32_t outputCount, const uint32_t *outputs); }; +/** + * @brief Class to represent an operation of data structure + */ class Node final : public op::Node { public: + /** + * @brief Construct a new Node object with param + * @param[in] param Param object that makes up a Node + */ Node(const Param ¶m) : _param(param) { // DO NOTHING } public: + /** + * @brief Destruct as default + */ virtual ~Node() = default; public: + /** + * @brief Get a reference of Param object + * @return Reference of Param object + */ const Param ¶m(void) const { return _param; } public: + /** + * @brief Visit this Node by NodeVisitor + * @return N/A + */ void accept(NodeVisitor &&) const override; private: diff --git a/runtimes/pure_arm_compute/src/internal/op/Lstm.h b/runtimes/pure_arm_compute/src/internal/op/Lstm.h index 056ac2ea7..f51f0402a 100644 --- a/runtimes/pure_arm_compute/src/internal/op/Lstm.h +++ b/runtimes/pure_arm_compute/src/internal/op/Lstm.h @@ -14,6 +14,12 @@ * limitations under the License. */ +/** + * @file Lstm.h + * @ingroup COM_AI_RUNTIME + * @brief This file defines internal::tflite::op::LSTM::Param struct + * and internal::tflite::op::LSTM::Node class + */ #ifndef __INTERNAL_OP_LSTM_H__ #define __INTERNAL_OP_LSTM_H__ @@ -30,56 +36,87 @@ namespace op namespace LSTM { +/** + * @brief Struct to have indexes for operation parameter + */ struct Param { - int32_t scratch_buffer_index; - int32_t output_state_out_index; - int32_t cell_state_out_index; - int32_t output_index; + int32_t scratch_buffer_index; /**< Index of scartch buffer */ + int32_t output_state_out_index; /**< Index of output state out */ + int32_t cell_state_out_index; /**< Index of cell state out */ + int32_t output_index; /**< Index of output */ - int32_t input_index; - int32_t input_to_input_weights_index; - int32_t input_to_forget_weights_index; - int32_t input_to_cell_weights_index; - int32_t input_to_output_weights_index; - int32_t recurrent_to_input_weights_index; - int32_t recurrent_to_forget_weights_index; - int32_t recurrent_to_cell_weights_index; - int32_t recurrent_to_output_weights_index; - int32_t cell_to_input_weights_index; - int32_t cell_to_forget_weights_index; - int32_t cell_to_output_weights_index; - int32_t input_gate_bias_index; - int32_t forget_gate_bias_index; - int32_t cell_bias_index; - int32_t output_gate_bias_index; - int32_t projection_weights_index; - int32_t projection_bias_index; - int32_t output_state_in_index; - int32_t cell_state_in_index; - int32_t activation_index; - int32_t cell_threshold_index; - int32_t projection_threshold_index; + int32_t input_index; /**< Index of input */ + int32_t input_to_input_weights_index; /**< Index of input to input weights */ + int32_t input_to_forget_weights_index; /**< Index of input to forget weights */ + int32_t input_to_cell_weights_index; /**< Index of input to cell weights */ + int32_t input_to_output_weights_index; /**< Index of input to output weights */ + int32_t recurrent_to_input_weights_index; /**< Index of recurrent to input weights */ + int32_t recurrent_to_forget_weights_index; /**< Index of recurrent to forget weights */ + int32_t recurrent_to_cell_weights_index; /**< Index of recurrent to cell weights */ + int32_t recurrent_to_output_weights_index; /**< Index of recurrent to output weights */ + int32_t cell_to_input_weights_index; /**< Index of cell to input weights */ + int32_t cell_to_forget_weights_index; /**< Index of cell to forget weights */ + int32_t cell_to_output_weights_index; /**< Index of cell to output weights */ + int32_t input_gate_bias_index; /**< Index of input gate bias */ + int32_t forget_gate_bias_index; /**< Index of forget gate bias */ + int32_t cell_bias_index; /**< Index of cell bias */ + int32_t output_gate_bias_index; /**< Index of output gate bias */ + int32_t projection_weights_index; /**< Index of projection weights */ + int32_t projection_bias_index; /**< Index of projection bias */ + int32_t output_state_in_index; /**< Index of output state in */ + int32_t cell_state_in_index; /**< Index of cell state in */ + int32_t activation_index; /**< Index of activation */ + int32_t cell_threshold_index; /**< Index of cell threshold */ + int32_t projection_threshold_index; /**< Index of projection threshold */ + /** + * @brief Construct as default + */ Param() = default; + /** + * @brief Construct a new Param object with params + * @param[in] inputCount Count of inputs + * @param[in] inputs Pointer of inputs + * @param[in] outputCount Count of outputs + * @param[in] outputs Pointer of outputs + */ Param(uint32_t inputCount, const uint32_t *inputs, uint32_t outputCount, const uint32_t *outputs); }; +/** + * @brief Class to represent an operation of data structure + */ class Node final : public op::Node { public: + /** + * @brief Construct a new Node object with param + * @param[in] param Param object that makes up a Node + */ Node(const Param ¶m) : _param(param) { // DO NOTHING } public: + /** + * @brief Destruct as default + */ virtual ~Node() = default; public: + /** + * @brief Get a reference of Param object + * @return Reference of Param object + */ const Param ¶m(void) const { return _param; } public: + /** + * @brief Visit this Node by NodeVisitor + * @return N/A + */ void accept(NodeVisitor &&) const override; private: diff --git a/runtimes/pure_arm_compute/src/internal/op/MaxPool2D.h b/runtimes/pure_arm_compute/src/internal/op/MaxPool2D.h index d5da17d66..329ccecb7 100644 --- a/runtimes/pure_arm_compute/src/internal/op/MaxPool2D.h +++ b/runtimes/pure_arm_compute/src/internal/op/MaxPool2D.h @@ -14,6 +14,12 @@ * limitations under the License. */ +/** + * @file MaxPool2D.h + * @brief This file contains accept function and params for MaxPool2D operation + * @ingroup COM_AI_RUNTIME + */ + #ifndef __INTERNAL_OP_MAX_POOL_2D_H__ #define __INTERNAL_OP_MAX_POOL_2D_H__ @@ -32,44 +38,77 @@ namespace MaxPool2D namespace Explicit { +/** + * @brief Struct of MaxPool2D(Explicit) operation's param + */ struct Param { - int32_t ofm_index; + int32_t ofm_index; /**< Output format index */ - int32_t ifm_index; + int32_t ifm_index; /**< Input format index */ - int32_t kw_index; - int32_t kh_index; + int32_t kw_index; /**< Kernel width index */ + int32_t kh_index; /**< Kernel height index */ - int32_t hstride_index; - int32_t vstride_index; + int32_t hstride_index; /**< Horizontal stride index */ + int32_t vstride_index; /**< Vertical stride index */ - int32_t padding_left_index; - int32_t padding_right_index; - int32_t padding_top_index; - int32_t padding_bottom_index; + int32_t padding_left_index; /**< Left padding index */ + int32_t padding_right_index; /**< Right padding index */ + int32_t padding_top_index; /**< Top padding index */ + int32_t padding_bottom_index; /**< Bottom padding index */ - int32_t activation_index; + int32_t activation_index; /**< Activation index */ + /** + * @brief Construct a new Param object for MaxPool2D(Explicit) as default + */ Param() = default; + + /** + * @brief Construct a new Param object for MaxPool2D(Explicit) with params + * @param [in] inputCount The number of input + * @param [in] inputs Array containing inputs + * @param [in] outputCount The number of output + * @param [in] outputs Array containing outputs + */ Param(uint32_t inputCount, const uint32_t *inputs, uint32_t outputCount, const uint32_t *outputs); }; +/** + * @brief Class to define operation node for MaxPool2D(Explicit) + */ class Node final : public op::Node { public: + /** + * @brief Construct a new Node object for MaxPool2D(Explicit) with param + * @param [in] param Parameters for Node + */ Node(const Param ¶m) : _param(param) { // DO NOTHING } public: + /** + * @brief Destroy the Node object for MaxPool2D(Explicit) + */ virtual ~Node() = default; public: + /** + * @brief Get parameters for MaxPool2D(Explicit) + * @return Parameters of MaxPool2D(Explicit) + */ const Param ¶m(void) const { return _param; } public: + /** + * @brief Function for accepting node for MaxPool2D(Explicit) + * @param [in] v Node visitor for invoking visit function of MaxPool2D(Explicit) + * @return N/A + */ void accept(NodeVisitor &&) const override; private: @@ -81,40 +120,73 @@ private: namespace Implicit { +/** + * @brief Struct of MaxPool2D(Implicit) operation's param + */ struct Param { - int32_t ofm_index; + int32_t ofm_index; /**< Output format index */ - int32_t ifm_index; + int32_t ifm_index; /**< Input format index */ - int32_t kw_index; - int32_t kh_index; + int32_t kw_index; /**< Kernel width index */ + int32_t kh_index; /**< Kernel height index */ - int32_t hstride_index; - int32_t vstride_index; + int32_t hstride_index; /**< Horizontal stride index */ + int32_t vstride_index; /**< Vertical stride index */ - int32_t padding_index; - int32_t activation_index; + int32_t padding_index; /**< Padding index */ + int32_t activation_index; /**< Activation index */ + /** + * @brief Construct a new Param object for MaxPool2D(Implicit) as default + */ Param() = default; + + /** + * @brief Construct a new Param object for MaxPool2D(Implicit) with params + * @param [in] inputCount The number of input + * @param [in] inputs Array containing inputs + * @param [in] outputCount The number of output + * @param [in] outputs Array containing outputs + */ Param(uint32_t inputCount, const uint32_t *inputs, uint32_t outputCount, const uint32_t *outputs); }; +/** + * @brief Class to define operation node for MaxPool2D(Implicit) + */ class Node final : public op::Node { public: + /** + * @brief Construct a new Node object for MaxPool2D(Implicit) with param + * @param [in] param Parameters for Node + */ Node(const Param ¶m) : _param(param) { // DO NOTHING } public: + /** + * @brief Destroy the Node object for MaxPool2D(Implicit) + */ virtual ~Node() = default; public: + /** + * @brief Get parameters for MaxPool2D(Implicit) + * @return Parameters of MaxPool2D(Implicit) + */ const Param ¶m(void) const { return _param; } public: + /** + * @brief Function for accepting node for MaxPool2D(Implicit) + * @param [in] v Node visitor for invoking visit function of MaxPool2D(Implicit) + * @return N/A + */ void accept(NodeVisitor &&) const override; private: diff --git a/runtimes/pure_arm_compute/src/internal/op/Mean.h b/runtimes/pure_arm_compute/src/internal/op/Mean.h index 385b38dbf..f8e7ed308 100644 --- a/runtimes/pure_arm_compute/src/internal/op/Mean.h +++ b/runtimes/pure_arm_compute/src/internal/op/Mean.h @@ -14,6 +14,12 @@ * limitations under the License. */ +/** + * @file Mean.h + * @ingroup COM_AI_RUNTIME + * @brief This file defines internal::tflite::op::Mean::Param struct + * and internal::tflite::op::Mean::Node class + */ #ifndef __INTERNAL_OP_MEAN_H__ #define __INTERNAL_OP_MEAN_H__ @@ -30,33 +36,64 @@ namespace op namespace Mean { +/** + * @brief Struct to have indexes for operation parameter + */ struct Param { - int32_t ofm_index; // output - - int32_t ifm_index; // input - int32_t axis_index; // axis - int32_t keep_dims_index; // keep_dims + int32_t ofm_index; /**< Index of output feature map */ // output + int32_t ifm_index; /**< Index of input feature map */ // input + int32_t axis_index; /**< Index of axis */ // axis + int32_t keep_dims_index; /**< Index of keep dims */ // keep_dims + /** + * @brief Construct as default + */ Param() = default; + /** + * @brief Construct a new Param object with params + * @param[in] inputCount Count of inputs + * @param[in] inputs Pointer of inputs + * @param[in] outputCount Count of outputs + * @param[in] outputs Pointer of outputs + */ Param(uint32_t inputCount, const uint32_t *inputs, uint32_t outputCount, const uint32_t *outputs); }; +/** + * @brief Class to represent an operation of data structure + */ class Node final : public op::Node { public: + /** + * @brief Construct a new Node object with param + * @param[in] param Param object that makes up a Node + */ Node(const Param ¶m) : _param(param) { // DO NOTHING } public: + /** + * @brief Destruct as default + */ virtual ~Node() = default; public: + /** + * @brief Get a reference of Param object + * @return Reference of Param object + */ const Param ¶m(void) const { return _param; } public: + /** + * @brief Visit this Node by NodeVisitor + * @param[in] v Visitor + * @return N/A + */ void accept(NodeVisitor &&) const override; private: diff --git a/runtimes/pure_arm_compute/src/internal/op/Mul.h b/runtimes/pure_arm_compute/src/internal/op/Mul.h index ebb72c4be..9710dd057 100644 --- a/runtimes/pure_arm_compute/src/internal/op/Mul.h +++ b/runtimes/pure_arm_compute/src/internal/op/Mul.h @@ -14,6 +14,11 @@ * limitations under the License. */ +/** + * @file Mul.h + * @ingroup COM_AI_RUNTIME + * @brief This file defines internal::tflite::op::Mul class + */ #ifndef __INTERNAL_OP_MUL_H__ #define __INTERNAL_OP_MUL_H__ @@ -30,33 +35,63 @@ namespace op namespace Mul { +/** + * @brief Struct to have indexes for operation parameter + */ struct Param { - int32_t ofm_index; - - int32_t lhs_index; - int32_t rhs_index; - int32_t activation_index; + int32_t ofm_index; /** Index of output feature map */ + int32_t lhs_index; /** Index of lhs */ + int32_t rhs_index; /** Index of rhs */ + int32_t activation_index; /** Index of activation */ + /** + * @brief Construct as default + */ Param() = default; + /** + * @brief Construct a new Param object with params + * @param[in] inputCount Count of inputs + * @param[in] inputs Pointer of inputs + * @param[in] outputCount Count of outputs + * @param[in] outputs Pointer of outputs + */ Param(uint32_t inputCount, const uint32_t *inputs, uint32_t outputCount, const uint32_t *outputs); }; +/** + * @brief Class to represent an operation of data structure + */ class Node final : public op::Node { public: + /** + * @brief Construct a new Node object with param + * @param[in] param Param object that makes up a Node + */ Node(const Param ¶m) : _param(param) { // DO NOTHING } public: + /** + * @brief Destruct as default + */ virtual ~Node() = default; public: + /** + * @brief Get a reference of Param object + * @return Reference of Param object + */ const Param ¶m(void) const { return _param; } public: + /** + * @brief Visit this Node by NodeVisitor + * @return N/A + */ void accept(NodeVisitor &&) const override; private: diff --git a/runtimes/pure_arm_compute/src/internal/op/Neg.cc b/runtimes/pure_arm_compute/src/internal/op/Neg.cc new file mode 100644 index 000000000..72fecf484 --- /dev/null +++ b/runtimes/pure_arm_compute/src/internal/op/Neg.cc @@ -0,0 +1,63 @@ +/* + * Copyright (c) 2018 Samsung Electronics Co., Ltd. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "internal/op/Neg.h" +#include "internal/op/NodeVisitor.h" + +#include <cassert> + +namespace internal +{ +namespace tflite +{ +namespace op +{ +namespace Neg +{ + +void Node::accept(NodeVisitor &&v) const { v.visit(*this); } + +} // namespace Neg +} // namespace op +} // namespace tflite +} // namespace internal + +namespace internal +{ +namespace tflite +{ +namespace op +{ +namespace Neg +{ + +Param::Param(uint32_t inputCount, const uint32_t *inputs, uint32_t outputCount, + const uint32_t *outputs) +{ + assert(inputCount == 1 && outputCount == 1); + + ofm_index = outputs[0]; + + // Each input should be interpreted as follows: + // + // 0 -> Input Tensor Index + ifm_index = inputs[0]; +} + +} // namespace Neg +} // namespace op +} // namespace tflite +} // namespace internal diff --git a/runtimes/pure_arm_compute/src/internal/op/Neg.h b/runtimes/pure_arm_compute/src/internal/op/Neg.h new file mode 100644 index 000000000..77507df3d --- /dev/null +++ b/runtimes/pure_arm_compute/src/internal/op/Neg.h @@ -0,0 +1,69 @@ +/* + * Copyright (c) 2018 Samsung Electronics Co., Ltd. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef __INTERNAL_OP_NEG_H__ +#define __INTERNAL_OP_NEG_H__ + +#include "internal/op/Node.h" + +#include <cstdint> + +namespace internal +{ +namespace tflite +{ +namespace op +{ +namespace Neg +{ + +struct Param +{ + int32_t ofm_index; + + int32_t ifm_index; + + Param() = default; + Param(uint32_t inputCount, const uint32_t *inputs, uint32_t outputCount, const uint32_t *outputs); +}; + +class Node final : public op::Node +{ +public: + Node(const Param ¶m) : _param(param) + { + // DO NOTHING + } + +public: + virtual ~Node() = default; + +public: + const Param ¶m(void) const { return _param; } + +public: + void accept(NodeVisitor &&) const override; + +private: + const Param _param; +}; + +} // namespace Neg +} // namespace op +} // namespace tflite +} // namespace internal + +#endif // __INTERNAL_OP_NEG_H__ diff --git a/runtimes/pure_arm_compute/src/internal/op/Node.h b/runtimes/pure_arm_compute/src/internal/op/Node.h index 3927c20f0..be1cbdb5b 100644 --- a/runtimes/pure_arm_compute/src/internal/op/Node.h +++ b/runtimes/pure_arm_compute/src/internal/op/Node.h @@ -14,6 +14,12 @@ * limitations under the License. */ +/** + * @file Node.h + * @brief This file contains struct of Node and NodeVisitor + * @ingroup COM_AI_RUNTIME + */ + #ifndef __INTERNAL_OP_NODE_H__ #define __INTERNAL_OP_NODE_H__ @@ -24,12 +30,26 @@ namespace tflite namespace op { +/** + * @brief Struct of operation NodeVisitor + */ struct NodeVisitor; +/** + * @brief Struct of operation Node + */ struct Node { + /** + * @brief Destroy the Node object for operation + */ virtual ~Node() = default; + /** + * @brief Function for accepting node for operation + * @param [in] v Node visitor for invoking visit function of operation + * @return N/A + */ virtual void accept(NodeVisitor &&) const = 0; }; diff --git a/runtimes/pure_arm_compute/src/internal/op/NodeVisitor.h b/runtimes/pure_arm_compute/src/internal/op/NodeVisitor.h index 6d8d10af0..0c1a4001d 100644 --- a/runtimes/pure_arm_compute/src/internal/op/NodeVisitor.h +++ b/runtimes/pure_arm_compute/src/internal/op/NodeVisitor.h @@ -14,6 +14,12 @@ * limitations under the License. */ +/** + * @file NodeVisitor.h + * @ingroup COM_AI_RUNTIME + * @brief This file defines NodeVisitor + */ + #ifndef __INTERNAL_OP_NODE_VISITOR_H__ #define __INTERNAL_OP_NODE_VISITOR_H__ @@ -26,6 +32,7 @@ #include "internal/op/Dequantize.h" #include "internal/op/MaxPool2D.h" #include "internal/op/AvgPool2D.h" +#include "internal/op/ArgMax.h" #include "internal/op/Concat.h" #include "internal/op/Reshape.h" #include "internal/op/ResizeBilinear.h" @@ -33,9 +40,11 @@ #include "internal/op/FullyConnected.h" #include "internal/op/Softmax.h" #include "internal/op/ReduceMax.h" +#include "internal/op/ReduceMin.h" #include "internal/op/Cast.h" #include "internal/op/TopKV2.h" #include "internal/op/Gather.h" +#include "internal/op/PReLU.h" #include "internal/op/ReLU.h" #include "internal/op/ReLU1.h" #include "internal/op/ReLU6.h" @@ -49,13 +58,30 @@ #include "internal/op/Floor.h" #include "internal/op/Split.h" #include "internal/op/RSQRT.h" +#include "internal/op/SQRT.h" #include "internal/op/Pad.h" #include "internal/op/SpaceToDepth.h" +#include "internal/op/SpaceToBatchND.h" #include "internal/op/L2Pool2D.h" #include "internal/op/EmbeddingLookup.h" #include "internal/op/HashtableLookup.h" #include "internal/op/L2Normalization.h" #include "internal/op/SquaredDifference.h" +#include "internal/op/LocalResponseNormalization.h" +#include "internal/op/DepthToSpace.h" +#include "internal/op/Unpack.h" +#include "internal/op/Neg.h" +#include "internal/op/Exp.h" +#include "internal/op/ReduceSum.h" +#include "internal/op/Equal.h" +#include "internal/op/BatchToSpaceNd.h" +#include "internal/op/TransposeConv.h" +#include "internal/op/Pack.h" +#include "internal/op/Abs.h" +#include "internal/op/NotEqual.h" +#include "internal/op/LogicalAnd.h" +#include "internal/op/LogicalNot.h" +#include "internal/op/LogicalOr.h" namespace internal { @@ -64,54 +90,400 @@ namespace tflite namespace op { +/** + * @brief Struct to define visitor for operation Nodes + */ struct NodeVisitor { + /** + * @brief Destruct NodeVisitor object with default + */ virtual ~NodeVisitor() = default; + /** + * @brief Visit an Add node + * @param[in] node Add node to visit + * @return N/A + */ virtual void visit(const Add::Node &) = 0; + /** + * @brief Visit a Mul node + * @param[in] node Mul node to visit + * @return N/A + */ virtual void visit(const Sub::Node &) = 0; + /** + * @brief Visit a Mul node + * @param[in] node Mul node to visit + * @return N/A + */ virtual void visit(const Mul::Node &) = 0; + /** + * @brief Visit a Div node + * @param[in] node Div node to visit + * @return N/A + */ virtual void visit(const Div::Node &) = 0; + /** + * @brief Visit a Conv2D node with implicit padding + * @param[in] node Conv2D node to visit + * @return N/A + */ virtual void visit(const Conv2D::Implicit::Node &) = 0; + /** + * @brief Visit a Conv2D node with explicit padding + * @param[in] node Conv2D node to visit + * @return N/A + */ virtual void visit(const Conv2D::Explicit::Node &) = 0; + /** + * @brief Visit a DepthwiseConv2D node with implicit padding + * @param[in] node DepthwiseConv2D node to visit + * @return N/A + */ virtual void visit(const DepthwiseConv2D::Implicit::Node &) = 0; + /** + * @brief Visit a DepthwiseConv2D node with explicit padding + * @param[in] node DepthwiseConv2D node to visit + * @return N/A + */ virtual void visit(const DepthwiseConv2D::Explicit::Node &) = 0; + /** + * @brief Visit a Dequantize node + * @param[in] node Dequantize node to visit + * @return N/A + */ virtual void visit(const Dequantize::Node &) = 0; + /** + * @brief Visit a MaxPool2D node with implicit padding + * @param[in] node MaxPool2D node to visit + * @return N/A + */ virtual void visit(const MaxPool2D::Implicit::Node &) = 0; + /** + * @brief Visit a MaxPool2D node with explicit padding + * @param[in] node MaxPool2D node to visit + * @return N/A + */ virtual void visit(const MaxPool2D::Explicit::Node &) = 0; + /** + * @brief Visit an AvgPool2D node with implicit padding + * @param[in] node AvgPool2D node to visit + * @return N/A + */ virtual void visit(const AvgPool2D::Implicit::Node &) = 0; + /** + * @brief Visit an AvgPool2D node with explicit padding + * @param[in] node AvgPool2D node to visit + * @return N/A + */ virtual void visit(const AvgPool2D::Explicit::Node &) = 0; + /** + * @brief Visit a Concat node + * @param[in] node Concat node to visit + * @return N/A + */ virtual void visit(const Concat::Node &) = 0; + /** + * @brief Visit a ArgMax node + * @param[in] node ArgMax node to visit + * @return N/A + */ + virtual void visit(const ArgMax::Node &) = 0; + /** + * @brief Visit an Reshape node + * @param[in] node Reshape node to visit + * @return N/A + */ virtual void visit(const Reshape::Node &) = 0; + /** + * @brief Visit an ResizeBilinear node + * @param[in] node ResizeBilinear node to visit + * @return N/A + */ virtual void visit(const ResizeBilinear::Node &) = 0; + /** + * @brief Visit a StridedSlice node + * @param[in] node StridedSlice node to visit + * @return N/A + */ virtual void visit(const StridedSlice::Node &) = 0; + /** + * @brief Visit a FullyConnected node + * @param[in] node FullyConnected node to visit + * @return N/A + */ virtual void visit(const FullyConnected::Node &) = 0; + /** + * @brief Visit a Softmax node + * @param[in] node Softmax node to visit + * @return N/A + */ virtual void visit(const Softmax::Node &) = 0; + /** + * @brief Visit a ReduceMax node + * @param[in] node ReduceMax node to visit + * @return N/A + */ virtual void visit(const ReduceMax::Node &) = 0; + /** + * @brief Visit a ReduceMin node + * @param[in] node ReduceMin node to visit + * @return N/A + */ + virtual void visit(const ReduceMin::Node &) = 0; + /** + * @brief Visit a Cast node + * @param[in] node Cast node to visit + * @return N/A + */ virtual void visit(const Cast::Node &) = 0; + /** + * @brief Visit a TopKV2 node + * @param[in] node TopKV2 node to visit + * @return N/A + */ virtual void visit(const TopKV2::Node &) = 0; + /** + * @brief Visit a Gather node + * @param[in] node Gather node to visit + * @return N/A + */ virtual void visit(const Gather::Node &) = 0; + /** + * @brief Visit an PReLU node + * @param[in] node PReLU node to visit + * @return N/A + */ + virtual void visit(const PReLU::Node &) = 0; + /** + * @brief Visit an ReLU node + * @param[in] node Relu node to visit + * @return N/A + */ virtual void visit(const ReLU::Node &) = 0; + /** + * @brief Visit a ReLU1 node + * @param[in] node ReLU1 node to visit + * @return N/A + */ virtual void visit(const ReLU1::Node &) = 0; + /** + * @brief Visit a ReLU6 node + * @param[in] node ReLU6 node to visit + * @return N/A + */ virtual void visit(const ReLU6::Node &) = 0; + /** + * @brief Visit a Tanh node + * @param[in] node Tanh node to visit + * @return N/A + */ virtual void visit(const Tanh::Node &) = 0; + /** + * @brief Visit a Squeeze node + * @param[in] node Squeeze node to visit + * @return N/A + */ virtual void visit(const Squeeze::Node &) = 0; + /** + * @brief Visit an Logistic node + * @param[in] node Logistic node to visit + * @return N/A + */ virtual void visit(const Logistic::Node &) = 0; + /** + * @brief Visit a Mean node + * @param[in] node Mean node to visit + * @return N/A + */ virtual void visit(const Mean::Node &) = 0; + /** + * @brief Visit an RNN node + * @param[in] node RNN node to visit + * @return N/A + */ virtual void visit(const RNN::Node &) = 0; + /** + * @brief Visit a Transpose node + * @param[in] node Transpose node to visit + * @return N/A + */ virtual void visit(const Transpose::Node &) = 0; + /** + * @brief Visit an LSTM node + * @param[in] node LSTM node to visit + * @return N/A + */ virtual void visit(const LSTM::Node &) = 0; + /** + * @brief Visit a Floor node + * @param[in] node Floor node to visit + * @return N/A + */ virtual void visit(const Floor::Node &) = 0; + /** + * @brief Visit a Split node + * @param[in] node Split node to visit + * @return N/A + */ virtual void visit(const Split::Node &) = 0; + /** + * @brief Visit an RSQRT node + * @param[in] node RSQRT node to visit + * @return N/A + */ virtual void visit(const RSQRT::Node &) = 0; + /** + * @brief Visit an SQRT node + * @param[in] node SQRT node to visit + * @return N/A + */ + virtual void visit(const SQRT::Node &) = 0; + /** + * @brief Visit a Pad node + * @param[in] node Pad node to visit + * @return N/A + */ virtual void visit(const Pad::Node &) = 0; + /** + * @brief Visit a SpaceToDepth node + * @param[in] node SpaceToDepth node to visit + * @return N/A + */ virtual void visit(const SpaceToDepth::Node &) = 0; + /** + * @brief Visit a SpaceToBatchND node + * @param[in] node SpaceToBatchND node to visit + * @return N/A + */ + virtual void visit(const SpaceToBatchND::Node &) = 0; + /** + * @brief Visit an L2Pool2D node with implicit padding + * @param[in] node L2Pool2D node to visit + * @return N/A + */ virtual void visit(const L2Pool2D::Implicit::Node &) = 0; + /** + * @brief Visit an L2Pool2D node with explicit padding + * @param[in] node L2Pool2D node to visit + * @return N/A + */ virtual void visit(const L2Pool2D::Explicit::Node &) = 0; + /** + * @brief Visit an EmbeddingLookup node + * @param[in] node EmbeddingLookup node to visit + * @return N/A + */ virtual void visit(const EmbeddingLookup::Node &) = 0; + /** + * @brief Visit a HashtableLookup node + * @param[in] node HashtableLookup node to visit + * @return N/A + */ virtual void visit(const HashtableLookup::Node &) = 0; + /** + * @brief Visit an L2Normalization node + * @param[in] node L2Normalization node to visit + * @return N/A + */ virtual void visit(const L2Normalization::Node &) = 0; + /** + * @brief Visit a SquaredDifference node + * @param[in] node SquaredDifference node to visit + * @return N/A + */ virtual void visit(const SquaredDifference::Node &) = 0; + /** + * @brief Visit a LocalResponseNormalization node + * @param[in] node LocalResponseNormalization node to visit + * @return N/A + */ + virtual void visit(const LocalResponseNormalization::Node &) = 0; + /** + * @brief Visit a DepthToSpace node + * @param[in] node DepthToSpace node to visit + * @return N/A + */ + virtual void visit(const DepthToSpace::Node &) = 0; + /** + * @brief Visit a Unpack node + * @param[in] node Unpack node to visit + * @return N/A + */ + virtual void visit(const Unpack::Node &) = 0; + /** + * @brief Visit a Neg node + * @param[in] node Neg node to visit + * @return N/A + */ + virtual void visit(const Neg::Node &) = 0; + /** + * @brief Visit a Exp node + * @param[in] node Exp node to visit + * @return N/A + */ + virtual void visit(const Exp::Node &) = 0; + /** + * @brief Visit a ReduceSum node + * @param[in] node ReduceSum node to visit + * @return N/A + */ + virtual void visit(const ReduceSum::Node &) = 0; + /** + * @brief Visit a Equal node + * @param[in] node Equal node to visit + * @return N/A + */ + virtual void visit(const Equal::Node &) = 0; + /** + * @brief Visit a BatchToSpaceNd node + * @param[in] node BatchToSpaceNd node to visit + * @return N/A + */ + virtual void visit(const BatchToSpaceNd::Node &) = 0; + /** + * @brief Visit a TransposeConv node + * @param[in] node TransposeConv node to visit + * @return N/A + */ + virtual void visit(const TransposeConv::Node &) = 0; + /** + * @brief Visit a Pack node + * @param[in] node Pack node to visit + * @return N/A + */ + virtual void visit(const Pack::Node &) = 0; + /** + * @brief Visit a Abs node + * @param[in] node Abs node to visit + * @return N/A + */ + virtual void visit(const Abs::Node &) = 0; + /** + * @brief Visit a NotEqual node + * @param[in] node NotEqual node to visit + * @return N/A + */ + virtual void visit(const NotEqual::Node &) = 0; + /** + * @brief Visit a LogicalAnd node + * @param[in] node LogicalAnd node to visit + * @return N/A + */ + virtual void visit(const LogicalAnd::Node &) = 0; + /** + * @brief Visit a LogicalNot node + * @param[in] node LogicalNot node to visit + * @return N/A + */ + virtual void visit(const LogicalNot::Node &) = 0; + /** + * @brief Visit a LogicalOr node + * @param[in] node LogicalOr node to visit + * @return N/A + */ + virtual void visit(const LogicalOr::Node &) = 0; }; } // namespace op diff --git a/runtimes/pure_arm_compute/src/internal/op/NotEqual.cc b/runtimes/pure_arm_compute/src/internal/op/NotEqual.cc new file mode 100644 index 000000000..2906e214b --- /dev/null +++ b/runtimes/pure_arm_compute/src/internal/op/NotEqual.cc @@ -0,0 +1,65 @@ +/* + * Copyright (c) 2018 Samsung Electronics Co., Ltd. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "internal/op/NotEqual.h" +#include "internal/op/NodeVisitor.h" + +#include <cassert> + +namespace internal +{ +namespace tflite +{ +namespace op +{ +namespace NotEqual +{ + +void Node::accept(NodeVisitor &&v) const { v.visit(*this); } + +} // namespace NotEqual +} // namespace op +} // namespace tflite +} // namespace internal + +namespace internal +{ +namespace tflite +{ +namespace op +{ +namespace NotEqual +{ + +Param::Param(uint32_t inputCount, const uint32_t *inputs, uint32_t outputCount, + const uint32_t *outputs) +{ + assert(inputCount == 2 && outputCount == 1); + + output_index = outputs[0]; + + // Each input should be interpreted as follows: + // + // 0 -> input1 Tensor Index + // 1 -> input2 Tensor Index + input1_index = inputs[0]; + input2_index = inputs[1]; +} + +} // namespace NotEqual +} // namespace op +} // namespace tflite +} // namespace internal diff --git a/runtimes/pure_arm_compute/src/internal/op/NotEqual.h b/runtimes/pure_arm_compute/src/internal/op/NotEqual.h new file mode 100644 index 000000000..0d6130948 --- /dev/null +++ b/runtimes/pure_arm_compute/src/internal/op/NotEqual.h @@ -0,0 +1,83 @@ +/* + * Copyright (c) 2018 Samsung Electronics Co., Ltd. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef __INTERNAL_OP_NOT_EQUAL_H__ +#define __INTERNAL_OP_NOT_EQUAL_H__ + +#include "internal/op/Node.h" + +#include <cstdint> + +namespace internal +{ +namespace tflite +{ +namespace op +{ +namespace NotEqual +{ + +struct Param +{ + int32_t output_index; + + int32_t input1_index; + int32_t input2_index; + + Param() = default; + Param(uint32_t inputCount, const uint32_t *inputs, uint32_t outputCount, const uint32_t *outputs); +}; + +} // namespace NotEqual +} // namespace op +} // namespace tflite +} // namespace internal + +namespace internal +{ +namespace tflite +{ +namespace op +{ +namespace NotEqual +{ +class Node final : public op::Node +{ +public: + Node(const Param ¶m) : _param(param) + { + // DO NOTHING + } + +public: + virtual ~Node() = default; + +public: + const Param ¶m(void) const { return _param; } + +public: + void accept(NodeVisitor &&) const override; + +private: + const Param _param; +}; + +} // namespace NotEqual +} // namespace op +} // namespace tflite +} // namespace internal + +#endif // __INTERNAL_OP_NOT_EQUAL_H__ diff --git a/runtimes/pure_arm_compute/src/internal/op/PReLU.cc b/runtimes/pure_arm_compute/src/internal/op/PReLU.cc new file mode 100644 index 000000000..25b06505b --- /dev/null +++ b/runtimes/pure_arm_compute/src/internal/op/PReLU.cc @@ -0,0 +1,65 @@ +/* + * Copyright (c) 2018 Samsung Electronics Co., Ltd. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "internal/op/PReLU.h" +#include "internal/op/NodeVisitor.h" + +#include <cassert> + +namespace internal +{ +namespace tflite +{ +namespace op +{ +namespace PReLU +{ + +void Node::accept(NodeVisitor &&v) const { v.visit(*this); } + +} // namespace PReLU +} // namespace op +} // namespace tflite +} // namespace internal + +namespace internal +{ +namespace tflite +{ +namespace op +{ +namespace PReLU +{ + +Param::Param(uint32_t inputCount, const uint32_t *inputs, uint32_t outputCount, + const uint32_t *outputs) +{ + assert(inputCount == 2 && outputCount == 1); + + ofm_index = outputs[0]; + + // Each input should be interpreted as follows: + // + // 0 -> input Tensor Index + // 1 -> alpha Tensor Index + ifm_index = inputs[0]; + alpha_index = inputs[1]; +} + +} // namespace PReLU +} // namespace op +} // namespace tflite +} // namespace internal diff --git a/runtimes/pure_arm_compute/src/internal/op/PReLU.h b/runtimes/pure_arm_compute/src/internal/op/PReLU.h new file mode 100644 index 000000000..ae754abb4 --- /dev/null +++ b/runtimes/pure_arm_compute/src/internal/op/PReLU.h @@ -0,0 +1,109 @@ +/* + * Copyright (c) 2018 Samsung Electronics Co., Ltd. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * @file ReLU.h + * @brief This file contains accept function and params for ReLU operation + * @ingroup COM_AI_RUNTIME + */ + +#ifndef __INTERNAL_OP_PRELU_H__ +#define __INTERNAL_OP_PRELU_H__ + +#include "internal/op/Node.h" + +#include <cstdint> + +namespace internal +{ +namespace tflite +{ +namespace op +{ +namespace PReLU +{ + +/** + * @brief Struct of PReLU operation's param + */ +struct Param +{ + int32_t ofm_index; /**< Output format index */ + + int32_t ifm_index; /**< Input format index */ + int32_t alpha_index; /**< Alpha input index */ + + /** + * @brief Construct a new Param object for ReLU as default + */ + Param() = default; + + /** + * @brief Construct a new Param object for PReLU with params + * @param [in] inputCount The number of input + * @param [in] inputs Array containing inputs + * @param [in] outputCount The number of output + * @param [in] outputs Array containing outputs + */ + Param(uint32_t inputCount, const uint32_t *inputs, uint32_t outputCount, const uint32_t *outputs); +}; + +/** + * @brief Class to define operation node for PReLU + */ +class Node final : public op::Node +{ +public: + /** + * @brief Construct a new Node object for PReLU with param + * @param [in] param Parameters for Node + */ + Node(const Param ¶m) : _param(param) + { + // DO NOTHING + } + +public: + /** + * @brief Destroy the Node object for PReLU + */ + virtual ~Node() = default; + +public: + /** + * @brief Get parameters for PReLU + * @return Parameters of PReLU + */ + const Param ¶m(void) const { return _param; } + +public: + /** + * @brief Function for accepting node for PReLU + * @param [in] v Node visitor for invoking visit function of PReLU + * @return N/A + */ + void accept(NodeVisitor &&) const override; + +private: + const Param _param; +}; + +} // namespace PReLU +} // namespace op +} // namespace tflite +} // namespace internal + +#endif // __INTERNAL_OP_PRELU_H__ diff --git a/runtimes/pure_arm_compute/src/internal/op/Pack.cc b/runtimes/pure_arm_compute/src/internal/op/Pack.cc new file mode 100644 index 000000000..73f89b840 --- /dev/null +++ b/runtimes/pure_arm_compute/src/internal/op/Pack.cc @@ -0,0 +1,69 @@ +/* + * Copyright (c) 2018 Samsung Electronics Co., Ltd. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "internal/op/Pack.h" +#include "internal/op/NodeVisitor.h" + +#include <cassert> + +namespace internal +{ +namespace tflite +{ +namespace op +{ +namespace Pack +{ + +void Node::accept(NodeVisitor &&v) const { v.visit(*this); } + +} // namespace Pack +} // namespace op +} // namespace tflite +} // namespace internal + +namespace internal +{ +namespace tflite +{ +namespace op +{ +namespace Pack +{ + +Param::Param(uint32_t inputCount, const uint32_t *inputs, uint32_t outputCount, + const uint32_t *outputs) +{ + assert(outputCount == 1); + + // Each input should be interpreted as follows: + // + // 0 .. n - 3 -> Input Tensor Index + // n - 2 -> Input Tensor counts (will be ignored) + // n - 1 -> Input Axis Index + ofm_index = outputs[0]; + axis_index = inputs[inputCount - 1]; + // last input is axis along which packing is required + for (uint32_t n = 0; n < inputCount - 2; ++n) + { + ifm_indexes.emplace_back(inputs[n]); + } +} + +} // namespace Pack +} // namespace op +} // namespace tflite +} // namespace internal diff --git a/runtimes/pure_arm_compute/src/internal/op/Pack.h b/runtimes/pure_arm_compute/src/internal/op/Pack.h new file mode 100644 index 000000000..c5de01bd8 --- /dev/null +++ b/runtimes/pure_arm_compute/src/internal/op/Pack.h @@ -0,0 +1,72 @@ +/* + * Copyright (c) 2018 Samsung Electronics Co., Ltd. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef __INTERNAL_OP_PACK_H__ +#define __INTERNAL_OP_PACK_H__ + +#include "internal/op/Node.h" +#include <vector> + +#include <cstdint> + +namespace internal +{ +namespace tflite +{ +namespace op +{ +namespace Pack +{ + +struct Param +{ + int32_t ofm_index; + // There are N+1 inputs, 0 to N-1 are tensors of same shape + // Nth input is axis index along which stack is needed to be done. + std::vector<int32_t> ifm_indexes; + int32_t axis_index; + + Param() = default; + Param(uint32_t inputCount, const uint32_t *inputs, uint32_t outputCount, const uint32_t *outputs); +}; + +class Node final : public op::Node +{ +public: + Node(const Param ¶m) : _param(param) + { + // DO NOTHING + } + +public: + virtual ~Node() = default; + +public: + const Param ¶m(void) const { return _param; } + +public: + void accept(NodeVisitor &&) const override; + +private: + const Param _param; +}; + +} // namespace Pack +} // namespace op +} // namespace tflite +} // namespace internal + +#endif // __INTERNAL_OP_PACK_H__ diff --git a/runtimes/pure_arm_compute/src/internal/op/Pad.cc b/runtimes/pure_arm_compute/src/internal/op/Pad.cc index 24d08bf36..00938242b 100644 --- a/runtimes/pure_arm_compute/src/internal/op/Pad.cc +++ b/runtimes/pure_arm_compute/src/internal/op/Pad.cc @@ -1,63 +1,63 @@ -/*
- * Copyright (c) 2018 Samsung Electronics Co., Ltd. All Rights Reserved
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "internal/op/Pad.h"
-#include "internal/op/NodeVisitor.h"
-
-#include <cassert>
-
-namespace internal
-{
-namespace tflite
-{
-namespace op
-{
-namespace Pad
-{
-
-void Node::accept(NodeVisitor &&v) const { v.visit(*this); }
-
-} // namespace Pad
-} // namespace op
-} // namespace tflite
-} // namespace internal
-
-namespace internal
-{
-namespace tflite
-{
-namespace op
-{
-namespace Pad
-{
-
-Param::Param(uint32_t inputCount, const uint32_t *inputs, uint32_t outputCount,
- const uint32_t *outputs)
-{
- assert(inputCount == 2 && outputCount == 1);
- ofm_index = outputs[0];
-
- // Each input should be interpreted as follows:
- //
- // 0 -> input Tensor Index
- // 1 -> paddings
- ifm_index = inputs[0];
- paddings_index = inputs[1];
-}
-} // namespace Pad
-} // namespace op
-} // namespace tflite
-} // namespace internal
+/* + * Copyright (c) 2018 Samsung Electronics Co., Ltd. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "internal/op/Pad.h" +#include "internal/op/NodeVisitor.h" + +#include <cassert> + +namespace internal +{ +namespace tflite +{ +namespace op +{ +namespace Pad +{ + +void Node::accept(NodeVisitor &&v) const { v.visit(*this); } + +} // namespace Pad +} // namespace op +} // namespace tflite +} // namespace internal + +namespace internal +{ +namespace tflite +{ +namespace op +{ +namespace Pad +{ + +Param::Param(uint32_t inputCount, const uint32_t *inputs, uint32_t outputCount, + const uint32_t *outputs) +{ + assert(inputCount == 2 && outputCount == 1); + ofm_index = outputs[0]; + + // Each input should be interpreted as follows: + // + // 0 -> input Tensor Index + // 1 -> paddings + ifm_index = inputs[0]; + paddings_index = inputs[1]; +} +} // namespace Pad +} // namespace op +} // namespace tflite +} // namespace internal diff --git a/runtimes/pure_arm_compute/src/internal/op/Pad.h b/runtimes/pure_arm_compute/src/internal/op/Pad.h index e3ddae44c..68752a10e 100644 --- a/runtimes/pure_arm_compute/src/internal/op/Pad.h +++ b/runtimes/pure_arm_compute/src/internal/op/Pad.h @@ -1,69 +1,107 @@ -/*
- * Copyright (c) 2018 Samsung Electronics Co., Ltd. All Rights Reserved
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef __INTERNAL_OP_PAD_H__
-#define __INTERNAL_OP_PAD_H__
-
-#include "internal/op/Node.h"
-
-#include <cstdint>
-
-namespace internal
-{
-namespace tflite
-{
-namespace op
-{
-namespace Pad
-{
-
-struct Param
-{
- int32_t ifm_index;
- int32_t paddings_index;
- int32_t ofm_index;
-
- Param() = default;
- Param(uint32_t inputCount, const uint32_t *inputs, uint32_t outputCount, const uint32_t *outputs);
-};
-
-class Node final : public op::Node
-{
-public:
- Node(const Param ¶m) : _param(param)
- {
- // DO NOTHING
- }
-
-public:
- virtual ~Node() = default;
-
-public:
- const Param ¶m(void) const { return _param; }
-
-public:
- void accept(NodeVisitor &&) const override;
-
-private:
- const Param _param;
-};
-
-} // namespace Pad
-} // namespace op
-} // namespace tflite
-} // namespace internal
-
-#endif // __INTERNAL_OP_PAD_H_
+/* + * Copyright (c) 2018 Samsung Electronics Co., Ltd. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * @file Pad.h + * @ingroup COM_AI_RUNTIME + * @brief This file defines Pad node + */ + +#ifndef __INTERNAL_OP_PAD_H__ +#define __INTERNAL_OP_PAD_H__ + +#include "internal/op/Node.h" + +#include <cstdint> + +namespace internal +{ +namespace tflite +{ +namespace op +{ +namespace Pad +{ + +/** + * @brief Struct to manipulate parameter for Pad operation + */ +struct Param +{ + int32_t ifm_index; //!< index for input + int32_t paddings_index; //!< index for padding + int32_t ofm_index; //!< index for output + + /** + * @brief Default Constructor + */ + Param() = default; + /** + * @brief Construct a new Param object + * @param[in] inputCount the number of inputs + * @param[in] inputs pointer for input data + * @param[in] outputCount the number of outputs + * @param[in] outputs pointer for input data + */ + Param(uint32_t inputCount, const uint32_t *inputs, uint32_t outputCount, const uint32_t *outputs); +}; + +/** + * @brief Class to define Pad Operation + */ +class Node final : public op::Node +{ +public: + /** + * @brief Construct a new RNN Node object + * @param param Parameter for RNN Node + */ + Node(const Param ¶m) : _param(param) + { + // DO NOTHING + } + +public: + /** + * @brief Default Destructor + */ + virtual ~Node() = default; + +public: + /** + * @brief Get parameter + * @return Param reference + */ + const Param ¶m(void) const { return _param; } + +public: + /** + * @brief Accept a NodeVisitor so that it can visit this node + * @param [in] v Visitor + * @return N/A + */ + void accept(NodeVisitor &&) const override; + +private: + const Param _param; //!< parameter for Pad node +}; + +} // namespace Pad +} // namespace op +} // namespace tflite +} // namespace internal + +#endif // __INTERNAL_OP_PAD_H_ diff --git a/runtimes/pure_arm_compute/src/internal/op/RSQRT.h b/runtimes/pure_arm_compute/src/internal/op/RSQRT.h index e384b27f2..e39d60241 100644 --- a/runtimes/pure_arm_compute/src/internal/op/RSQRT.h +++ b/runtimes/pure_arm_compute/src/internal/op/RSQRT.h @@ -14,6 +14,12 @@ * limitations under the License. */ +/** + * @file RSQRT.h + * @ingroup COM_AI_RUNTIME + * @brief This file defines internal::tflite::op::RSQRT::Param struct + * and internal::tflite::op::RSQRT::Node class + */ #ifndef __INTERNAL_OP_RSQRT_H__ #define __INTERNAL_OP_RSQRT_H__ @@ -30,31 +36,61 @@ namespace op namespace RSQRT { +/** + * @brief Struct to have indexes for operation parameter + */ struct Param { - int32_t output_index; - - int32_t input_index; + int32_t output_index; /**< Index of output feature map */ + int32_t input_index; /**< Index of input feature map */ + /** + * @brief Construct as default + */ Param() = default; + /** + * @brief Construct a new Param object with params + * @param[in] inputCount Count of inputs + * @param[in] inputs Pointer of inputs + * @param[in] outputCount Count of outputs + * @param[in] outputs Pointer of outputs + */ Param(uint32_t inputCount, const uint32_t *inputs, uint32_t outputCount, const uint32_t *outputs); }; +/** + * @brief Class to represent an operation of data structure + */ class Node final : public op::Node { public: + /** + * @brief Construct a new Node object with param + * @param[in] param Param object that makes up a Node + */ Node(const Param ¶m) : _param(param) { // DO NOTHING } public: + /** + * @brief Destruct as default + */ virtual ~Node() = default; public: + /** + * @brief Get a reference of Param object + * @return Reference of Param object + */ const Param ¶m(void) const { return _param; } public: + /** + * @brief Visit this Node by NodeVisitor + * @return N/A + */ void accept(NodeVisitor &&) const override; private: diff --git a/runtimes/pure_arm_compute/src/internal/op/ReLU.h b/runtimes/pure_arm_compute/src/internal/op/ReLU.h index 64dcf2e14..aaa39b523 100644 --- a/runtimes/pure_arm_compute/src/internal/op/ReLU.h +++ b/runtimes/pure_arm_compute/src/internal/op/ReLU.h @@ -14,6 +14,12 @@ * limitations under the License. */ +/** + * @file ReLU.h + * @brief This file contains accept function and params for ReLU operation + * @ingroup COM_AI_RUNTIME + */ + #ifndef __INTERNAL_OP_RELU_H__ #define __INTERNAL_OP_RELU_H__ @@ -30,31 +36,64 @@ namespace op namespace ReLU { +/** + * @brief Struct of ReLU operation's param + */ struct Param { - int32_t ofm_index; + int32_t ofm_index; /**< Output format index */ - int32_t ifm_index; + int32_t ifm_index; /**< Input format index */ + /** + * @brief Construct a new Param object for ReLU as default + */ Param() = default; + + /** + * @brief Construct a new Param object for ReLU with params + * @param [in] inputCount The number of input + * @param [in] inputs Array containing inputs + * @param [in] outputCount The number of output + * @param [in] outputs Array containing outputs + */ Param(uint32_t inputCount, const uint32_t *inputs, uint32_t outputCount, const uint32_t *outputs); }; +/** + * @brief Class to define operation node for ReLU + */ class Node final : public op::Node { public: + /** + * @brief Construct a new Node object for ReLU with param + * @param [in] param Parameters for Node + */ Node(const Param ¶m) : _param(param) { // DO NOTHING } public: + /** + * @brief Destroy the Node object for ReLU + */ virtual ~Node() = default; public: + /** + * @brief Get parameters for ReLU + * @return Parameters of ReLU + */ const Param ¶m(void) const { return _param; } public: + /** + * @brief Function for accepting node for ReLU + * @param [in] v Node visitor for invoking visit function of ReLU + * @return N/A + */ void accept(NodeVisitor &&) const override; private: diff --git a/runtimes/pure_arm_compute/src/internal/op/ReLU1.h b/runtimes/pure_arm_compute/src/internal/op/ReLU1.h index 997a9faff..330445af8 100644 --- a/runtimes/pure_arm_compute/src/internal/op/ReLU1.h +++ b/runtimes/pure_arm_compute/src/internal/op/ReLU1.h @@ -14,6 +14,12 @@ * limitations under the License. */ +/** + * @file ReLU1.h + * @brief This file contains accept function and params for ReLU1 operation + * @ingroup COM_AI_RUNTIME + */ + #ifndef __INTERNAL_OP_RELU1_H__ #define __INTERNAL_OP_RELU1_H__ @@ -30,31 +36,64 @@ namespace op namespace ReLU1 { +/** + * @brief Struct of ReLU1 operation's param + */ struct Param { - int32_t ofm_index; + int32_t ofm_index; /**< Output format index */ - int32_t ifm_index; + int32_t ifm_index; /**< Input format index */ + /** + * @brief Construct a new Param object for ReLU1 as default + */ Param() = default; + + /** + * @brief Construct a new Param object for ReLU1 with params + * @param [in] inputCount The number of input + * @param [in] inputs Array containing inputs + * @param [in] outputCount The number of output + * @param [in] outputs Array containing outputs + */ Param(uint32_t inputCount, const uint32_t *inputs, uint32_t outputCount, const uint32_t *outputs); }; +/** + * @brief Class to define operation node for ReLU1 + */ class Node final : public op::Node { public: + /** + * @brief Construct a new Node object for ReLU1 with param + * @param [in] param Parameters for Node + */ Node(const Param ¶m) : _param(param) { // DO NOTHING } public: + /** + * @brief Destroy the Node object for ReLU1 + */ virtual ~Node() = default; public: + /** + * @brief Get parameters for ReLU1 + * @return Parameters of ReLU1 + */ const Param ¶m(void) const { return _param; } public: + /** + * @brief Function for accepting node for ReLU1 + * @param [in] v Node visitor for invoking visit function of ReLU1 + * @return N/A + */ void accept(NodeVisitor &&) const override; private: diff --git a/runtimes/pure_arm_compute/src/internal/op/ReLU6.h b/runtimes/pure_arm_compute/src/internal/op/ReLU6.h index 77c55b64c..6fc2c24fe 100644 --- a/runtimes/pure_arm_compute/src/internal/op/ReLU6.h +++ b/runtimes/pure_arm_compute/src/internal/op/ReLU6.h @@ -14,6 +14,11 @@ * limitations under the License. */ +/** + * @file ReLU6.h + * @ingroup COM_AI_RUNTIME + * @brief This file defines internal::tflite::op::ReLU6 class + */ #ifndef __INTERNAL_OP_RELU6_H__ #define __INTERNAL_OP_RELU6_H__ @@ -30,31 +35,61 @@ namespace op namespace ReLU6 { +/** + * @brief Struct to have indexes for operation parameter + */ struct Param { - int32_t ofm_index; - - int32_t ifm_index; + int32_t ofm_index; /** Index of output feature map */ + int32_t ifm_index; /** Index of input feature map */ + /** + * @brief Construct as default + */ Param() = default; + /** + * @brief Construct a new Param object with params + * @param[in] inputCount Count of inputs + * @param[in] inputs Pointer of inputs + * @param[in] outputCount Count of outputs + * @param[in] outputs Pointer of outputs + */ Param(uint32_t inputCount, const uint32_t *inputs, uint32_t outputCount, const uint32_t *outputs); }; +/** + * @brief Class to represent an operation of data structure + */ class Node final : public op::Node { public: + /** + * @brief Construct a new Node object with param + * @param[in] param Param object that makes up a Node + */ Node(const Param ¶m) : _param(param) { // DO NOTHING } public: + /** + * @brief Destruct as default + */ virtual ~Node() = default; public: + /** + * @brief Get a reference of Param object + * @return Reference of Param object + */ const Param ¶m(void) const { return _param; } public: + /** + * @brief Visit this Node by NodeVisitor + * @return N/A + */ void accept(NodeVisitor &&) const override; private: diff --git a/runtimes/pure_arm_compute/src/internal/op/ReduceMax.h b/runtimes/pure_arm_compute/src/internal/op/ReduceMax.h index e3278aacf..77d8bd869 100644 --- a/runtimes/pure_arm_compute/src/internal/op/ReduceMax.h +++ b/runtimes/pure_arm_compute/src/internal/op/ReduceMax.h @@ -14,6 +14,12 @@ * limitations under the License. */ +/** + * @file ReduceMax.h + * @ingroup COM_AI_RUNTIME + * @brief This file defines internal::tflite::op::ReduceMax::Param struct + * and internal::tflite::op::ReduceMax::Node class + */ #ifndef __INTERNAL_OP_REDUCEMAX_H__ #define __INTERNAL_OP_REDUCEMAX_H__ @@ -30,32 +36,63 @@ namespace op namespace ReduceMax { +/** + * @brief Struct to have indexes for operation parameter + */ struct Param { - int32_t ofm_index; - - int32_t ifm_index; - int32_t axis_index; + int32_t ofm_index; /**< Index of output feature map */ + int32_t ifm_index; /**< Index of input feature map */ + int32_t axis_index; /**< Index of axis */ + /** + * @brief Construct as default + */ Param() = default; + /** + * @brief Construct a new Param object with params + * @param[in] inputCount Count of inputs + * @param[in] inputs Pointer of inputs + * @param[in] outputCount Count of outputs + * @param[in] outputs Pointer of outputs + */ Param(uint32_t inputCount, const uint32_t *inputs, uint32_t outputCount, const uint32_t *outputs); }; +/** + * @brief Class to represent an operation of data structure + */ class Node final : public op::Node { public: + /** + * @brief Construct a new Node object with param + * @param[in] param Param object that makes up a Node + */ Node(const Param ¶m) : _param(param) { // DO NOTHING } public: + /** + * @brief Destruct as default + */ virtual ~Node() = default; public: + /** + * @brief Get a reference of Param object + * @return Reference of Param object + */ const Param ¶m(void) const { return _param; } public: + /** + * @brief Visit this Node by NodeVisitor + * @param[in] v Visitor + * @return N/A + */ void accept(NodeVisitor &&) const override; private: diff --git a/runtimes/pure_arm_compute/src/internal/op/ReduceMin.cc b/runtimes/pure_arm_compute/src/internal/op/ReduceMin.cc new file mode 100644 index 000000000..72b6079d4 --- /dev/null +++ b/runtimes/pure_arm_compute/src/internal/op/ReduceMin.cc @@ -0,0 +1,65 @@ +/* + * Copyright (c) 2018 Samsung Electronics Co., Ltd. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "internal/op/ReduceMin.h" +#include "internal/op/NodeVisitor.h" + +#include <cassert> + +namespace internal +{ +namespace tflite +{ +namespace op +{ +namespace ReduceMin +{ + +void Node::accept(NodeVisitor &&v) const { v.visit(*this); } + +} // namespace ReduceMin +} // namespace op +} // namespace tflite +} // namespace internal + +namespace internal +{ +namespace tflite +{ +namespace op +{ +namespace ReduceMin +{ + +Param::Param(uint32_t inputCount, const uint32_t *inputs, uint32_t outputCount, + const uint32_t *outputs) +{ + assert(inputCount == 2 && outputCount == 1); + + ofm_index = outputs[0]; + + // Each input should be interpreted as follows: + // + // 0 -> Input Tensor Index + // 1 -> Axis Tensor Index + ifm_index = inputs[0]; + axis_index = inputs[1]; +} + +} // namespace ReduceMin +} // namespace op +} // namespace tflite +} // namespace internal diff --git a/runtimes/pure_arm_compute/src/internal/op/ReduceMin.h b/runtimes/pure_arm_compute/src/internal/op/ReduceMin.h new file mode 100644 index 000000000..5dd82ec43 --- /dev/null +++ b/runtimes/pure_arm_compute/src/internal/op/ReduceMin.h @@ -0,0 +1,107 @@ +/* + * Copyright (c) 2018 Samsung Electronics Co., Ltd. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * @file ReduceMin.h + * @ingroup COM_AI_RUNTIME + * @brief This file defines internal::tflite::op::ReduceMin::Param struct + * and internal::tflite::op::ReduceMin::Node class + */ +#ifndef __INTERNAL_OP_REDUCEMIN_H__ +#define __INTERNAL_OP_REDUCEMIN_H__ + +#include "internal/op/Node.h" + +#include <cstdint> + +namespace internal +{ +namespace tflite +{ +namespace op +{ +namespace ReduceMin +{ + +/** + * @brief Struct to have indexes for operation parameter + */ +struct Param +{ + int32_t ofm_index; /**< Index of output feature map */ + + int32_t ifm_index; /**< Index of input feature map */ + int32_t axis_index; /**< Index of axis */ + /** + * @brief Construct as default + */ + Param() = default; + /** + * @brief Construct a new Param object with params + * @param[in] inputCount Count of inputs + * @param[in] inputs Pointer of inputs + * @param[in] outputCount Count of outputs + * @param[in] outputs Pointer of outputs + */ + Param(uint32_t inputCount, const uint32_t *inputs, uint32_t outputCount, const uint32_t *outputs); +}; + +/** + * @brief Class to represent an operation of data structure + */ +class Node final : public op::Node +{ +public: + /** + * @brief Construct a new Node object with param + * @param[in] param Param object that makes up a Node + */ + Node(const Param ¶m) : _param(param) + { + // DO NOTHING + } + +public: + /** + * @brief Destruct as default + */ + virtual ~Node() = default; + +public: + /** + * @brief Get a reference of Param object + * @return Reference of Param object + */ + const Param ¶m(void) const { return _param; } + +public: + /** + * @brief Visit this Node by NodeVisitor + * @param[in] v Visitor + * @return N/A + */ + void accept(NodeVisitor &&) const override; + +private: + const Param _param; +}; + +} // namespace ReduceMin +} // namespace op +} // namespace tflite +} // namespace internal + +#endif // __INTERNAL_OP_REDUCEMIN_H__ diff --git a/runtimes/pure_arm_compute/src/internal/op/ReduceSum.cc b/runtimes/pure_arm_compute/src/internal/op/ReduceSum.cc new file mode 100644 index 000000000..4d83c1734 --- /dev/null +++ b/runtimes/pure_arm_compute/src/internal/op/ReduceSum.cc @@ -0,0 +1,65 @@ +/* + * Copyright (c) 2018 Samsung Electronics Co., Ltd. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "internal/op/ReduceSum.h" +#include "internal/op/NodeVisitor.h" + +#include <cassert> + +namespace internal +{ +namespace tflite +{ +namespace op +{ +namespace ReduceSum +{ + +void Node::accept(NodeVisitor &&v) const { v.visit(*this); } + +} // namespace ReduceSum +} // namespace op +} // namespace tflite +} // namespace internal + +namespace internal +{ +namespace tflite +{ +namespace op +{ +namespace ReduceSum +{ + +Param::Param(uint32_t inputCount, const uint32_t *inputs, uint32_t outputCount, + const uint32_t *outputs) +{ + assert(inputCount == 2 && outputCount == 1); + + ofm_index = outputs[0]; + + // Each input should be interpreted as follows: + // + // 0 -> Input Tensor Index + // 1 -> Axis Tensor Index + ifm_index = inputs[0]; + axis_index = inputs[1]; +} + +} // namespace ReduceSum +} // namespace op +} // namespace tflite +} // namespace internal diff --git a/runtimes/pure_arm_compute/src/internal/op/ReduceSum.h b/runtimes/pure_arm_compute/src/internal/op/ReduceSum.h new file mode 100644 index 000000000..9c661f63a --- /dev/null +++ b/runtimes/pure_arm_compute/src/internal/op/ReduceSum.h @@ -0,0 +1,70 @@ +/* + * Copyright (c) 2018 Samsung Electronics Co., Ltd. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef __INTERNAL_OP_REDUCESUM_H__ +#define __INTERNAL_OP_REDUCESUM_H__ + +#include "internal/op/Node.h" + +#include <cstdint> + +namespace internal +{ +namespace tflite +{ +namespace op +{ +namespace ReduceSum +{ + +struct Param +{ + int32_t ofm_index; + + int32_t ifm_index; + int32_t axis_index; + + Param() = default; + Param(uint32_t inputCount, const uint32_t *inputs, uint32_t outputCount, const uint32_t *outputs); +}; + +class Node final : public op::Node +{ +public: + Node(const Param ¶m) : _param(param) + { + // DO NOTHING + } + +public: + virtual ~Node() = default; + +public: + const Param ¶m(void) const { return _param; } + +public: + void accept(NodeVisitor &&) const override; + +private: + const Param _param; +}; + +} // namespace ReduceSum +} // namespace op +} // namespace tflite +} // namespace internal + +#endif // __INTERNAL_OP_REDUCESUM_H__ diff --git a/runtimes/pure_arm_compute/src/internal/op/Reshape.h b/runtimes/pure_arm_compute/src/internal/op/Reshape.h index ab77ade8c..7152eaece 100644 --- a/runtimes/pure_arm_compute/src/internal/op/Reshape.h +++ b/runtimes/pure_arm_compute/src/internal/op/Reshape.h @@ -14,6 +14,12 @@ * limitations under the License. */ +/** + * @file Reshape.h + * @ingroup COM_AI_RUNTIME + * @brief This file defines Reshape node + */ + #ifndef __INTERNAL_OP_RESHAPE_H__ #define __INTERNAL_OP_RESHAPE_H__ @@ -30,36 +36,68 @@ namespace op namespace Reshape { +/** + * @brief Struct to manipulate parameter for Reshape operation + */ struct Param { - int32_t output_index; + int32_t output_index; //!< index for output feature map - int32_t input_index; - int32_t shape_index; + int32_t input_index; //!< index for input feature map + int32_t shape_index; //!< index for shape + /** + * @brief Default Constructor + */ Param() = default; + /** + * @brief Construct a new Param object + * @param[in] inputCount the number of inputs + * @param[in] inputs pointer for input data + * @param[in] outputCount the number of outputs + * @param[in] outputs pointer for input data + */ Param(uint32_t inputCount, const uint32_t *inputs, uint32_t outputCount, const uint32_t *outputs); }; +/** + * @brief Class to define Reshape Operation + */ class Node final : public op::Node { public: + /** + * @brief Construct a new Reshape Node object + * @param param Parameter for Reshape Node + */ Node(const Param ¶m) : _param(param) { // DO NOTHING } public: + /** + * @brief Default Destructor + */ virtual ~Node() = default; public: + /** + * @brief Get parameter + * @return Param reference + */ const Param ¶m(void) const { return _param; } public: + /** + * @brief Accept a NodeVisitor so that it can visit this node + * @param [in] v Visitor + * @return N/A + */ void accept(NodeVisitor &&) const override; private: - const Param _param; + const Param _param; //!< parameter for Reshape node }; } // namespace Reshape diff --git a/runtimes/pure_arm_compute/src/internal/op/ResizeBilinear.h b/runtimes/pure_arm_compute/src/internal/op/ResizeBilinear.h index bf216b75f..f2eab4aaf 100644 --- a/runtimes/pure_arm_compute/src/internal/op/ResizeBilinear.h +++ b/runtimes/pure_arm_compute/src/internal/op/ResizeBilinear.h @@ -14,6 +14,12 @@ * limitations under the License. */ +/** + * @file ResizeBilinear.h + * @ingroup COM_AI_RUNTIME + * @brief This file defines internal::tflite::op::ResizeBilinear::Param struct + * and internal::tflite::op::ResizeBilinear::Node class + */ #ifndef __INTERNAL_OP_RESIZE_BILINEAR_H__ #define __INTERNAL_OP_RESIZE_BILINEAR_H__ @@ -30,33 +36,64 @@ namespace op namespace ResizeBilinear { +/** + * @brief Struct to have indexes for ResizeBilinear operation parameter + */ struct Param { - int32_t ofm_index; - - int32_t ifm_index; - int32_t height_index; - int32_t width_index; + int32_t ofm_index; /**< Index of output feature map */ + int32_t ifm_index; /**< Index of input feature map */ + int32_t height_index; /**< Index of height */ + int32_t width_index; /**< Index of width */ + /** + * @brief Construct as default + */ Param() = default; + /** + * @brief Construct a new Param object with params + * @param[in] inputCount Count of inputs + * @param[in] inputs Pointer of inputs + * @param[in] outputCount Count of outputs + * @param[in] outputs Pointer of outputs + */ Param(uint32_t inputCount, const uint32_t *inputs, uint32_t outputCount, const uint32_t *outputs); }; +/** + * @brief Class to represent an ResizeBilinear operation of data structure + */ class Node final : public op::Node { public: + /** + * @brief Construct a new Node object with param + * @param[in] param Param object that makes up a Node + */ Node(const Param ¶m) : _param(param) { // DO NOTHING } public: + /** + * @brief Destruct as default + */ virtual ~Node() = default; public: + /** + * @brief Get a reference of Param object + * @return Reference of Param object + */ const Param ¶m(void) const { return _param; } public: + /** + * @brief Visit this Node by NodeVisitor + * @param[in] v Visitor + * @return N/A + */ void accept(NodeVisitor &&) const override; private: diff --git a/runtimes/pure_arm_compute/src/internal/op/Rnn.h b/runtimes/pure_arm_compute/src/internal/op/Rnn.h index c436a0987..7b2a10843 100644 --- a/runtimes/pure_arm_compute/src/internal/op/Rnn.h +++ b/runtimes/pure_arm_compute/src/internal/op/Rnn.h @@ -14,6 +14,12 @@ * limitations under the License. */ +/** + * @file Rnn.h + * @ingroup COM_AI_RUNTIME + * @brief This file defines RNN node + */ + #ifndef __INTERNAL_OP_RNN_H__ #define __INTERNAL_OP_RNN_H__ @@ -30,41 +36,73 @@ namespace op namespace RNN { +/** + * @brief Struct to manipulate parameter for RNN operation + */ struct Param { - int32_t output_index; - int32_t hidden_state_out_index; + int32_t output_index; //!< index for ouuput + int32_t hidden_state_out_index; //!< index for hidden state output - int32_t input_index; - int32_t weights_index; - int32_t recurrent_weights_index; - int32_t bias_index; - int32_t hidden_state_in_index; - int32_t fused_activation_index; + int32_t input_index; //!< index for input + int32_t weights_index; //!< index for weight + int32_t recurrent_weights_index; //!< index for recurrent weights + int32_t bias_index; //!< index for bias + int32_t hidden_state_in_index; //!< index for hidden state input + int32_t fused_activation_index; //!< index for fused activation + /** + * @brief Default Constructor + */ Param() = default; + /** + * @brief Construct a new Param object + * @param[in] inputCount the number of inputs + * @param[in] inputs pointer for input data + * @param[in] outputCount the number of outputs + * @param[in] outputs pointer for input data + */ Param(uint32_t inputCount, const uint32_t *inputs, uint32_t outputCount, const uint32_t *outputs); }; +/** + * @brief Class to define RNN Operation + */ class Node final : public op::Node { public: + /** + * @brief Construct a new RNN Node object + * @param param Parameter for RNN Node + */ Node(const Param ¶m) : _param(param) { // DO NOTHING } public: + /** + * @brief Default Destructor + */ virtual ~Node() = default; public: + /** + * @brief Get parameter + * @return Param reference + */ const Param ¶m(void) const { return _param; } public: + /** + * @brief Accept a NodeVisitor so that it can visit this node + * @param [in] v Visitor + * @return N/A + */ void accept(NodeVisitor &&) const override; private: - const Param _param; + const Param _param; //!< parameter for RNN node }; } // namespace RNN diff --git a/runtimes/pure_arm_compute/src/internal/op/SQRT.cc b/runtimes/pure_arm_compute/src/internal/op/SQRT.cc new file mode 100644 index 000000000..70ce42e9c --- /dev/null +++ b/runtimes/pure_arm_compute/src/internal/op/SQRT.cc @@ -0,0 +1,62 @@ +/* + * Copyright (c) 2018 Samsung Electronics Co., Ltd. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "internal/op/SQRT.h" +#include "internal/op/NodeVisitor.h" + +#include <cassert> + +namespace internal +{ +namespace tflite +{ +namespace op +{ +namespace SQRT +{ + +void Node::accept(NodeVisitor &&v) const { v.visit(*this); } + +} // namespace SQRT +} // namespace op +} // namespace tflite +} // namespace internal + +namespace internal +{ +namespace tflite +{ +namespace op +{ +namespace SQRT +{ + +Param::Param(uint32_t inputCount, const uint32_t *inputs, uint32_t outputCount, + const uint32_t *outputs) +{ + assert(inputCount == 1 && outputCount == 1); + + output_index = outputs[0]; + + // Each input should be interpreted as follows: + // 0 -> input Tensor Index + input_index = inputs[0]; +} + +} // namespace SQRT +} // namespace op +} // namespace tflite +} // namespace internal diff --git a/runtimes/pure_arm_compute/src/internal/op/SQRT.h b/runtimes/pure_arm_compute/src/internal/op/SQRT.h new file mode 100644 index 000000000..85dfb97a7 --- /dev/null +++ b/runtimes/pure_arm_compute/src/internal/op/SQRT.h @@ -0,0 +1,105 @@ +/* + * Copyright (c) 2018 Samsung Electronics Co., Ltd. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * @file SQRT.h + * @ingroup COM_AI_RUNTIME + * @brief This file defines internal::tflite::op::SQRT::Param struct + * and internal::tflite::op::SQRT::Node class + */ +#ifndef __INTERNAL_OP_SQRT_H__ +#define __INTERNAL_OP_SQRT_H__ + +#include "internal/op/Node.h" + +#include <cstdint> + +namespace internal +{ +namespace tflite +{ +namespace op +{ +namespace SQRT +{ + +/** + * @brief Struct to have indexes for operation parameter + */ +struct Param +{ + int32_t output_index; /**< Index of output feature map */ + + int32_t input_index; /**< Index of input feature map */ + /** + * @brief Construct as default + */ + Param() = default; + /** + * @brief Construct a new Param object with params + * @param[in] inputCount Count of inputs + * @param[in] inputs Pointer of inputs + * @param[in] outputCount Count of outputs + * @param[in] outputs Pointer of outputs + */ + Param(uint32_t inputCount, const uint32_t *inputs, uint32_t outputCount, const uint32_t *outputs); +}; + +/** + * @brief Class to represent an operation of data structure + */ +class Node final : public op::Node +{ +public: + /** + * @brief Construct a new Node object with param + * @param[in] param Param object that makes up a Node + */ + Node(const Param ¶m) : _param(param) + { + // DO NOTHING + } + +public: + /** + * @brief Destruct as default + */ + virtual ~Node() = default; + +public: + /** + * @brief Get a reference of Param object + * @return Reference of Param object + */ + const Param ¶m(void) const { return _param; } + +public: + /** + * @brief Visit this Node by NodeVisitor + * @return N/A + */ + void accept(NodeVisitor &&) const override; + +private: + const Param _param; +}; + +} // namespace SQRT +} // namespace op +} // namespace tflite +} // namespace internal + +#endif // __INTERNAL_OP_SQRT_H__ diff --git a/runtimes/pure_arm_compute/src/internal/op/Softmax.h b/runtimes/pure_arm_compute/src/internal/op/Softmax.h index 746f6b4e6..6e631af5f 100644 --- a/runtimes/pure_arm_compute/src/internal/op/Softmax.h +++ b/runtimes/pure_arm_compute/src/internal/op/Softmax.h @@ -14,6 +14,12 @@ * limitations under the License. */ +/** + * @file Softmax.h + * @brief This file contains accept function and params for Softmax operation + * @ingroup COM_AI_RUNTIME + */ + #ifndef __INTERNAL_OP_SOFTMAX_H__ #define __INTERNAL_OP_SOFTMAX_H__ @@ -30,32 +36,65 @@ namespace op namespace Softmax { +/** + * @brief Struct of Softmax operation's param + */ struct Param { - int32_t output_index; + int32_t output_index; /**< Output index */ - int32_t input_index; - int32_t scale_index; + int32_t input_index; /**< Input index */ + int32_t scale_index; /**< Scale index */ + /** + * @brief Construct a new Param object for Softmax as default + */ Param() = default; + + /** + * @brief Construct a new Param object for Softmax with params + * @param [in] inputCount The number of input + * @param [in] inputs Array containing inputs + * @param [in] outputCount The number of output + * @param [in] outputs Array containing outputs + */ Param(uint32_t inputCount, const uint32_t *inputs, uint32_t outputCount, const uint32_t *outputs); }; +/** + * @brief Class to define operation node for Softmax + */ class Node final : public op::Node { public: + /** + * @brief Construct a new Node object for Softmax with param + * @param [in] param Parameters for Node + */ Node(const Param ¶m) : _param(param) { // DO NOTHING } public: + /** + * @brief Destroy the Node object for Softmax + */ virtual ~Node() = default; public: + /** + * @brief Get parameters for Softmax + * @return Parameters of Softmax + */ const Param ¶m(void) const { return _param; } public: + /** + * @brief Function for accepting node for Softmax + * @param [in] v Node visitor for invoking visit function of Softmax + * @return N/A + */ void accept(NodeVisitor &&) const override; private: diff --git a/runtimes/pure_arm_compute/src/internal/op/SpaceToBatchND.cc b/runtimes/pure_arm_compute/src/internal/op/SpaceToBatchND.cc new file mode 100644 index 000000000..9ab026cf4 --- /dev/null +++ b/runtimes/pure_arm_compute/src/internal/op/SpaceToBatchND.cc @@ -0,0 +1,67 @@ +/* + * Copyright (c) 2018 Samsung Electronics Co., Ltd. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "internal/op/SpaceToBatchND.h" +#include "internal/op/NodeVisitor.h" + +#include <cassert> + +namespace internal +{ +namespace tflite +{ +namespace op +{ +namespace SpaceToBatchND +{ + +void Node::accept(NodeVisitor &&v) const { v.visit(*this); } + +} // namespace SpaceToBatchND +} // namespace op +} // namespace tflite +} // namespace internal + +namespace internal +{ +namespace tflite +{ +namespace op +{ +namespace SpaceToBatchND +{ + +Param::Param(uint32_t inputCount, const uint32_t *inputs, uint32_t outputCount, + const uint32_t *outputs) +{ + assert(inputCount == 3 && outputCount == 1); + + output_index = outputs[0]; + + // Each input should be interpreted as follows: + // + // 0 -> Input Tensor Index + // 1 -> Block size Index + // 2 -> Padding size Index + input_index = inputs[0]; + block_size_index = inputs[1]; + padding_size_index = inputs[2]; +} + +} // namespace SpaceToBatchND +} // namespace op +} // namespace tflite +} // namespace internal diff --git a/runtimes/pure_arm_compute/src/internal/op/SpaceToBatchND.h b/runtimes/pure_arm_compute/src/internal/op/SpaceToBatchND.h new file mode 100644 index 000000000..650d068f4 --- /dev/null +++ b/runtimes/pure_arm_compute/src/internal/op/SpaceToBatchND.h @@ -0,0 +1,71 @@ +/* + * Copyright (c) 2018 Samsung Electronics Co., Ltd. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef __INTERNAL_OP_SPACETOBATCHND_H__ +#define __INTERNAL_OP_SPACETOBATCHND_H__ + +#include "internal/op/Node.h" + +#include <cstdint> + +namespace internal +{ +namespace tflite +{ +namespace op +{ +namespace SpaceToBatchND +{ + +struct Param +{ + int32_t output_index; + + int32_t input_index; + int32_t block_size_index; + int32_t padding_size_index; + + Param() = default; + Param(uint32_t inputCount, const uint32_t *inputs, uint32_t outputCount, const uint32_t *outputs); +}; + +class Node final : public op::Node +{ +public: + Node(const Param ¶m) : _param(param) + { + // DO NOTHING + } + +public: + virtual ~Node() = default; + +public: + const Param ¶m(void) const { return _param; } + +public: + void accept(NodeVisitor &&) const override; + +private: + const Param _param; +}; + +} // namespace SpaceToBatchND +} // namespace op +} // namespace tflite +} // namespace internal + +#endif // __INTERNAL_OP_SPACETOBATCHND_H__ diff --git a/runtimes/pure_arm_compute/src/internal/op/SpaceToDepth.h b/runtimes/pure_arm_compute/src/internal/op/SpaceToDepth.h index 81bfe5246..2e624006a 100644 --- a/runtimes/pure_arm_compute/src/internal/op/SpaceToDepth.h +++ b/runtimes/pure_arm_compute/src/internal/op/SpaceToDepth.h @@ -14,6 +14,12 @@ * limitations under the License. */ +/** + * @file SpaceToDepth.h + * @brief This file contains accept function and params for SpaceToDepth operation + * @ingroup COM_AI_RUNTIME + */ + #ifndef __INTERNAL_OP_SPACETODEPTH_H__ #define __INTERNAL_OP_SPACETODEPTH_H__ @@ -30,32 +36,65 @@ namespace op namespace SpaceToDepth { +/** + * @brief Struct of SpaceToDepth operation's param + */ struct Param { - int32_t output_index; + int32_t output_index; /**< Output index */ - int32_t input_index; - int32_t block_size_index; + int32_t input_index; /**< Input index */ + int32_t block_size_index; /**< Block size index */ + /** + * @brief Construct a new Param object for SpaceToDepth as default + */ Param() = default; + + /** + * @brief Construct a new Param object for SpaceToDepth with params + * @param [in] inputCount The number of input + * @param [in] inputs Array containing inputs + * @param [in] outputCount The number of output + * @param [in] outputs Array containing outputs + */ Param(uint32_t inputCount, const uint32_t *inputs, uint32_t outputCount, const uint32_t *outputs); }; +/** + * @brief Class to define operation node for SpaceToDepth + */ class Node final : public op::Node { public: + /** + * @brief Construct a new Node object for SpaceToDepth with param + * @param [in] param Parameters for Node + */ Node(const Param ¶m) : _param(param) { // DO NOTHING } public: + /** + * @brief Destroy the Node object for SpaceToDepth + */ virtual ~Node() = default; public: + /** + * @brief Get parameters for SpaceToDepth + * @return Parameters of SpaceToDepth + */ const Param ¶m(void) const { return _param; } public: + /** + * @brief Function for accepting node for SpaceToDepth + * @param [in] v Node visitor for invoking visit function of SpaceToDepth + * @return N/A + */ void accept(NodeVisitor &&) const override; private: diff --git a/runtimes/pure_arm_compute/src/internal/op/Split.h b/runtimes/pure_arm_compute/src/internal/op/Split.h index 8bea1000d..b2c6c2fd1 100644 --- a/runtimes/pure_arm_compute/src/internal/op/Split.h +++ b/runtimes/pure_arm_compute/src/internal/op/Split.h @@ -14,6 +14,12 @@ * limitations under the License. */ +/** + * @file Split.h + * @ingroup COM_AI_RUNTIME + * @brief This file defines Split node + */ + #ifndef __INTERNAL_OP_SPLIT_H__ #define __INTERNAL_OP_SPLIT_H__ @@ -31,36 +37,68 @@ namespace op namespace Split { +/** + * @brief Struct to manipulate parameter for Split operation + */ struct Param { - int32_t axis_index; - int32_t ifm_index; + int32_t axis_index; //!< index for axis + int32_t ifm_index; //!< index for input feature map - std::vector<int32_t> ofm_indexes; + std::vector<int32_t> ofm_indexes; //!< index for output feature map + /** + * @brief Default Constructor + */ Param() = default; + /** + * @brief Construct a new Param object + * @param[in] inputCount the number of inputs + * @param[in] inputs pointer for input data + * @param[in] outputCount the number of outputs + * @param[in] outputs pointer for input data + */ Param(uint32_t inputCount, const uint32_t *inputs, uint32_t outputCount, const uint32_t *outputs); }; +/** + * @brief Class to define Split Operation + */ class Node final : public op::Node { public: + /** + * @brief Construct a new Split Node object + * @param param Parameter for Split Node + */ Node(const Param ¶m) : _param(param) { // DO NOTHING } public: + /** + * @brief Default Destructor + */ virtual ~Node() = default; public: + /** + * @brief Get parameter + * @return Param reference + */ const Param ¶m(void) const { return _param; } public: + /** + * @brief Accept a NodeVisitor so that it can visit this node + * @param [in] v Visitor + * @return N/A + */ void accept(NodeVisitor &&) const override; private: - const Param _param; + const Param _param; //!< parameter for Split node }; } // namespace Split diff --git a/runtimes/pure_arm_compute/src/internal/op/SquaredDifference.cc b/runtimes/pure_arm_compute/src/internal/op/SquaredDifference.cc index c2c4f7242..f6c8bc5df 100644 --- a/runtimes/pure_arm_compute/src/internal/op/SquaredDifference.cc +++ b/runtimes/pure_arm_compute/src/internal/op/SquaredDifference.cc @@ -1,3 +1,19 @@ +/* + * Copyright (c) 2018 Samsung Electronics Co., Ltd. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + #include "internal/op/SquaredDifference.h" #include "internal/op/NodeVisitor.h" @@ -30,7 +46,7 @@ namespace SquaredDifference Param::Param(uint32_t inputCount, const uint32_t *inputs, uint32_t outputCount, const uint32_t *outputs) { - assert(inputCount == 3 && outputCount == 1); + assert(inputCount == 2 && outputCount == 1); ofm_index = outputs[0]; @@ -38,10 +54,8 @@ Param::Param(uint32_t inputCount, const uint32_t *inputs, uint32_t outputCount, // // 0 -> LHS Tensor Index // 1 -> RHS Tensor Index - // 2 -> Activation Index lhs_index = inputs[0]; rhs_index = inputs[1]; - activation_index = inputs[2]; } } // namespace SquaredDifference diff --git a/runtimes/pure_arm_compute/src/internal/op/SquaredDifference.h b/runtimes/pure_arm_compute/src/internal/op/SquaredDifference.h index 7760405b9..ecbb03209 100644 --- a/runtimes/pure_arm_compute/src/internal/op/SquaredDifference.h +++ b/runtimes/pure_arm_compute/src/internal/op/SquaredDifference.h @@ -1,3 +1,25 @@ +/* + * Copyright (c) 2018 Samsung Electronics Co., Ltd. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * @file SquaredDifference.h + * @ingroup COM_AI_RUNTIME + * @brief This file defines internal::tflite::op::SquaredDifference::Param struct + * and internal::tflite::op::SquaredDifference::Node class + */ #ifndef __INTERNAL_OP_SQUAREDDIFFERENCE_H__ #define __INTERNAL_OP_SQUAREDDIFFERENCE_H__ @@ -14,33 +36,62 @@ namespace op namespace SquaredDifference { +/** + * @brief Struct to have indexes for operation parameter + */ struct Param { - int32_t ofm_index; - - int32_t lhs_index; - int32_t rhs_index; - int32_t activation_index; + int32_t ofm_index; /**< Index of output feature map */ + int32_t lhs_index; /**< Index of lhs */ + int32_t rhs_index; /**< Index of rhs */ + /** + * @brief Construct as default + */ Param() = default; + /** + * @brief Construct a new Param object with params + * @param[in] inputCount Count of inputs + * @param[in] inputs Pointer of inputs + * @param[in] outputCount Count of outputs + * @param[in] outputs Pointer of outputs + */ Param(uint32_t inputCount, const uint32_t *inputs, uint32_t outputCount, const uint32_t *outputs); }; +/** + * @brief Class to represent an operation of data structure + */ class Node final : public op::Node { public: + /** + * @brief Construct a new Node object with param + * @param[in] param Param object that makes up a Node + */ Node(const Param ¶m) : _param(param) { // DO NOTHING } public: + /** + * @brief Destruct as default + */ virtual ~Node() = default; public: + /** + * @brief Get a reference of Param object + * @return Reference of Param object + */ const Param ¶m(void) const { return _param; } public: + /** + * @brief Visit this Node by NodeVisitor + * @return N/A + */ void accept(NodeVisitor &&) const override; private: diff --git a/runtimes/pure_arm_compute/src/internal/op/Squeeze.h b/runtimes/pure_arm_compute/src/internal/op/Squeeze.h index e871067f5..d5f36f85f 100644 --- a/runtimes/pure_arm_compute/src/internal/op/Squeeze.h +++ b/runtimes/pure_arm_compute/src/internal/op/Squeeze.h @@ -14,6 +14,12 @@ * limitations under the License. */ +/** + * @file Squeeze.h + * @ingroup COM_AI_RUNTIME + * @brief This file defines internal::tflite::op::Squeeze::Param struct + * and internal::tflite::op::Squeeze::Node class + */ #ifndef __INTERNAL_OP_SQUEEZE_H__ #define __INTERNAL_OP_SQUEEZE_H__ @@ -30,32 +36,64 @@ namespace op namespace Squeeze { +/** + * @brief Struct to have indexes for operation parameter + */ struct Param { - int32_t output_index; - - int32_t input_index; - int32_t dims_index_optional = -1; // optional param. default is -1 + int32_t output_index; /**< Index of output feature map */ + int32_t input_index; /**< Index of input feature map */ + // optional param. default is -1 + int32_t dims_index_optional = -1; /**< Index of dims */ + /** + * @brief Construct as default + */ Param() = default; + /** + * @brief Construct a new Param object with params + * @param[in] inputCount Count of inputs + * @param[in] inputs Pointer of inputs + * @param[in] outputCount Count of outputs + * @param[in] outputs Pointer of outputs + */ Param(uint32_t inputCount, const uint32_t *inputs, uint32_t outputCount, const uint32_t *outputs); }; +/** + * @brief Class to represent an operation of data structure + */ class Node final : public op::Node { public: + /** + * @brief Construct a new Node object with param + * @param[in] param Param object that makes up a Node + */ Node(const Param ¶m) : _param(param) { // DO NOTHING } public: + /** + * @brief Destruct as default + */ virtual ~Node() = default; public: + /** + * @brief Get a reference of Param object + * @return Reference of Param object + */ const Param ¶m(void) const { return _param; } public: + /** + * @brief Visit this Node by NodeVisitor + * @param[in] v Visitor + * @return N/A + */ void accept(NodeVisitor &&) const override; private: diff --git a/runtimes/pure_arm_compute/src/internal/op/StridedSlice.h b/runtimes/pure_arm_compute/src/internal/op/StridedSlice.h index 26bb81a8c..21dbb9e68 100644 --- a/runtimes/pure_arm_compute/src/internal/op/StridedSlice.h +++ b/runtimes/pure_arm_compute/src/internal/op/StridedSlice.h @@ -14,6 +14,12 @@ * limitations under the License. */ +/** + * @file StridedSlice.h + * @ingroup COM_AI_RUNTIME + * @brief This file defines StridedSlice node + */ + #ifndef __INTERNAL_OP_STRIDEDSLICE_H__ #define __INTERNAL_OP_STRIDEDSLICE_H__ @@ -30,41 +36,73 @@ namespace op namespace StridedSlice { +/** + * @brief Struct to manipulate parameter for StridedSlice operation + */ struct Param { - int32_t outputData_index; + int32_t outputData_index; //!< index for output data - int32_t inputData_index; - int32_t startData_index; - int32_t endData_index; - int32_t stridesData_index; - int32_t beginMask_index; - int32_t endMask_index; - int32_t shrinkAxisMask_index; + int32_t inputData_index; //!< index for input data + int32_t startData_index; //!< index where slicing start from + int32_t endData_index; //!< index where slicing ends to + int32_t stridesData_index; //!< index for stride value + int32_t beginMask_index; //!< index for beginmask + int32_t endMask_index; //!< index for endmask + int32_t shrinkAxisMask_index; //!< index for shrink axis + /** + * @brief Default Constructor + */ Param() = default; + /** + * @brief Construct a new Param object + * @param[in] inputCount the number of inputs + * @param[in] inputs pointer for input data + * @param[in] outputCount the number of outputs + * @param[in] outputs pointer for input data + */ Param(uint32_t inputCount, const uint32_t *inputs, uint32_t outputCount, const uint32_t *outputs); }; +/** + * @brief Class to define StridedSlice Operation + */ class Node final : public op::Node { public: + /** + * @brief Construct a new StridedSlice Node object + * @param param Parameter for StridedSlice Node + */ Node(const Param ¶m) : _param(param) { // DO NOTHING } public: + /** + * @brief Default Destructor + */ virtual ~Node() = default; public: + /** + * @brief Get parameter + * @return Param reference + */ const Param ¶m(void) const { return _param; } public: + /** + * @brief Accept a NodeVisitor so that it can visit this node + * @param [in] v Visitor + * @return N/A + */ void accept(NodeVisitor &&) const override; private: - const Param _param; + const Param _param; //!< parameter for StridedSlice node }; } // namespace StridedSlice diff --git a/runtimes/pure_arm_compute/src/internal/op/Sub.h b/runtimes/pure_arm_compute/src/internal/op/Sub.h index 3da271029..864359d1e 100644 --- a/runtimes/pure_arm_compute/src/internal/op/Sub.h +++ b/runtimes/pure_arm_compute/src/internal/op/Sub.h @@ -14,6 +14,12 @@ * limitations under the License. */ +/** + * @file Sub.h + * @ingroup COM_AI_RUNTIME + * @brief This file defines SUB Node + */ + #ifndef __INTERNAL_OP_SUB_H__ #define __INTERNAL_OP_SUB_H__ @@ -30,37 +36,69 @@ namespace op namespace Sub { +/** + * @brief Struct to manipulate parameters for SUB + */ struct Param { - int32_t ofm_index; + int32_t ofm_index; //!< index for output feature map - int32_t lhs_index; - int32_t rhs_index; - int32_t activation_index; + int32_t lhs_index; //!< index for left-hand side + int32_t rhs_index; //!< index for right-hand side + int32_t activation_index; //!< index for activation function + /** + * @brief Default Constructor + */ Param() = default; + /** + * @brief Construct a new Param object + * @param[in] inputCount the number of inputs + * @param[in] inputs pointer for input data + * @param[in] outputCount the number of outputs + * @param[in] outputs pointer for input data + */ Param(uint32_t inputCount, const uint32_t *inputs, uint32_t outputCount, const uint32_t *outputs); }; +/** + * @brief Class to define SUB Operation + */ class Node final : public op::Node { public: + /** + * @brief Construct a new Sub Node object + * @param param Parameter for Sub Node + */ Node(const Param ¶m) : _param(param) { // DO NOTHING } public: + /** + * @brief Default Destructor + */ virtual ~Node() = default; public: + /** + * @brief Get parameter + * @return Param reference + */ const Param ¶m(void) const { return _param; } public: + /** + * @brief Accept a NodeVisitor so that it can visit this node + * @param [in] v Visitor + * @return N/A + */ void accept(NodeVisitor &&) const override; private: - const Param _param; + const Param _param; //!< parameter for SUB node }; } // namespace Sub diff --git a/runtimes/pure_arm_compute/src/internal/op/Tanh.h b/runtimes/pure_arm_compute/src/internal/op/Tanh.h index f5a9f102e..fd87297f1 100644 --- a/runtimes/pure_arm_compute/src/internal/op/Tanh.h +++ b/runtimes/pure_arm_compute/src/internal/op/Tanh.h @@ -14,6 +14,12 @@ * limitations under the License. */ +/** + * @file Tanh.h + * @ingroup COM_AI_RUNTIME + * @brief This file defines TANH node + */ + #ifndef __INTERNAL_OP_TANH_H__ #define __INTERNAL_OP_TANH_H__ @@ -30,35 +36,67 @@ namespace op namespace Tanh { +/** + * @brief Struct to manipulate parameter for hyperbolic tangent operation + */ struct Param { - int32_t ofm_index; + int32_t ofm_index; //!< index for output feature map - int32_t ifm_index; + int32_t ifm_index; //!< index for input feature map + /** + * @brief Default Constructor + */ Param() = default; + /** + * @brief Construct a new Param object + * @param[in] inputCount the number of inputs + * @param[in] inputs pointer for input data + * @param[in] outputCount the number of outputs + * @param[in] outputs pointer for input data + */ Param(uint32_t inputCount, const uint32_t *inputs, uint32_t outputCount, const uint32_t *outputs); }; +/** + * @brief Class to define Tanh Operation + */ class Node final : public op::Node { public: + /** + * @brief Construct a new Tanh Node object + * @param param Parameter for Tanh Node + */ Node(const Param ¶m) : _param(param) { // DO NOTHING } public: + /** + * @brief Default Destructor + */ virtual ~Node() = default; public: + /** + * @brief Get parameter + * @return Param reference + */ const Param ¶m(void) const { return _param; } public: + /** + * @brief Accept a NodeVisitor so that it can visit this node + * @param [in] v Visitor + * @return N/A + */ void accept(NodeVisitor &&) const override; private: - const Param _param; + const Param _param; //!< parameter for Tanh node }; } // namespace Tanh diff --git a/runtimes/pure_arm_compute/src/internal/op/TopKV2.h b/runtimes/pure_arm_compute/src/internal/op/TopKV2.h index 79bbd1f2e..02b7827e9 100644 --- a/runtimes/pure_arm_compute/src/internal/op/TopKV2.h +++ b/runtimes/pure_arm_compute/src/internal/op/TopKV2.h @@ -14,6 +14,12 @@ * limitations under the License. */ +/** + * @file TopKV2.h + * @brief This file contains accept function and params for TopKV2 operation + * @ingroup COM_AI_RUNTIME + */ + #ifndef __INTERNAL_OP_TOPKV2_H__ #define __INTERNAL_OP_TOPKV2_H__ @@ -30,33 +36,66 @@ namespace op namespace TopKV2 { +/** + * @brief Struct of TopKV2 operation's param + */ struct Param { - int32_t outputValues_index; - int32_t outputIndices_index; + int32_t outputValues_index; /**< Output values index */ + int32_t outputIndices_index; /**< Output indices index */ - int32_t inputData_index; - int32_t k_index; + int32_t inputData_index; /**< Input data index */ + int32_t k_index; /**< K value index */ + /** + * @brief Construct a new Param object for TopKV2 as default + */ Param() = default; + + /** + * @brief Construct a new Param object for TopKV2 with params + * @param [in] inputCount The number of input + * @param [in] inputs Array containing inputs + * @param [in] outputCount The number of output + * @param [in] outputs Array containing outputs + */ Param(uint32_t inputCount, const uint32_t *inputs, uint32_t outputCount, const uint32_t *outputs); }; +/** + * @brief Class to define operation node for TopKV2 + */ class Node final : public op::Node { public: + /** + * @brief Construct a new Node object for TopKV2 with param + * @param [in] param Parameters for Node + */ Node(const Param ¶m) : _param(param) { // DO NOTHING } public: + /** + * @brief Destroy the Node object for TopKV2 + */ virtual ~Node() = default; public: + /** + * @brief Get parameters for TopKV2 + * @return Parameters of TopKV2 + */ const Param ¶m(void) const { return _param; } public: + /** + * @brief Function for accepting node for TopKV2 + * @param [in] v Node visitor for invoking visit function of TopKV2 + * @return N/A + */ void accept(NodeVisitor &&) const override; private: diff --git a/runtimes/pure_arm_compute/src/internal/op/Transpose.h b/runtimes/pure_arm_compute/src/internal/op/Transpose.h index dac2ef8f2..bb01bf322 100644 --- a/runtimes/pure_arm_compute/src/internal/op/Transpose.h +++ b/runtimes/pure_arm_compute/src/internal/op/Transpose.h @@ -14,6 +14,12 @@ * limitations under the License. */ +/** + * @file Transpose.h + * @brief This file contains accept function and params for Transpose operation + * @ingroup COM_AI_RUNTIME + */ + #ifndef __INTERNAL_OP_TRANSPOSE_H__ #define __INTERNAL_OP_TRANSPOSE_H__ @@ -30,32 +36,65 @@ namespace op namespace Transpose { +/** + * @brief Struct of Transpose operation's param + */ struct Param { - int32_t ofm_index; + int32_t ofm_index; /**< Output format index */ - int32_t ifm_index; - int32_t permu_index; + int32_t ifm_index; /**< Input format index */ + int32_t permu_index; /**< Permutation index */ + /** + * @brief Construct a new Param object for Transpose as default + */ Param() = default; + + /** + * @brief Construct a new Param object for Transpose with params + * @param [in] inputCount The number of input + * @param [in] inputs Array containing inputs + * @param [in] outputCount The number of output + * @param [in] outputs Array containing outputs + */ Param(uint32_t inputCount, const uint32_t *inputs, uint32_t outputCount, const uint32_t *outputs); }; +/** + * @brief Class to define operation node for Transpose + */ class Node final : public op::Node { public: + /** + * @brief Construct a new Node object for Transpose with param + * @param [in] param Parameters for Node + */ Node(const Param ¶m) : _param(param) { // DO NOTHING } public: + /** + * @brief Destroy the Node object for Transpose + */ virtual ~Node() = default; public: + /** + * @brief Get parameters for Transpose + * @return Parameters of Transpose + */ const Param ¶m(void) const { return _param; } public: + /** + * @brief Function for accepting node for Transpose + * @param [in] v Node visitor for invoking visit function of Transpose + * @return N/A + */ void accept(NodeVisitor &&) const override; private: diff --git a/runtimes/pure_arm_compute/src/internal/op/TransposeConv.cc b/runtimes/pure_arm_compute/src/internal/op/TransposeConv.cc new file mode 100644 index 000000000..502eff525 --- /dev/null +++ b/runtimes/pure_arm_compute/src/internal/op/TransposeConv.cc @@ -0,0 +1,74 @@ +/* + * Copyright (c) 2018 Samsung Electronics Co., Ltd. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "internal/op/TransposeConv.h" +#include "internal/op/NodeVisitor.h" + +#include <cassert> + +namespace internal +{ +namespace tflite +{ +namespace op +{ +namespace TransposeConv +{ + +void Node::accept(NodeVisitor &&v) const { v.visit(*this); } + +} // namespace TransposeConv +} // namespace op +} // namespace tflite +} // namespace internal + +namespace internal +{ +namespace tflite +{ +namespace op +{ +namespace TransposeConv +{ + +Param::Param(uint32_t inputCount, const uint32_t *inputs, uint32_t outputCount, + const uint32_t *outputs) +{ + assert(inputCount == 6 && outputCount == 1); + + ofm_index = outputs[0]; + + // Each input should be interpreted as follows: + // + // 0 -> Output Shape Index + // 1 -> Weights Index + // 2 -> Input Tensor Index + // 3 -> Padding Type + // 4 -> Stride width + // 5 -> Stride height + + op_shape_index = inputs[0]; + ker_index = inputs[1]; + ifm_index = inputs[2]; + padding_index = inputs[3]; + hstride_index = inputs[4]; + vstride_index = inputs[5]; +} + +} // namespace TransposeConv +} // namespace op +} // namespace tflite +} // namespace internal diff --git a/runtimes/pure_arm_compute/src/internal/op/TransposeConv.h b/runtimes/pure_arm_compute/src/internal/op/TransposeConv.h new file mode 100644 index 000000000..b0122f82d --- /dev/null +++ b/runtimes/pure_arm_compute/src/internal/op/TransposeConv.h @@ -0,0 +1,74 @@ +/* + * Copyright (c) 2018 Samsung Electronics Co., Ltd. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef __INTERNAL_OP_TRANSPOSECONV_H__ +#define __INTERNAL_OP_TRANSPOSECONV_H__ + +#include "internal/op/Node.h" + +#include <cstdint> + +namespace internal +{ +namespace tflite +{ +namespace op +{ +namespace TransposeConv +{ + +struct Param +{ + int32_t ofm_index; + + int32_t op_shape_index; + int32_t ker_index; + int32_t ifm_index; + int32_t padding_index; + int32_t hstride_index; + int32_t vstride_index; + + Param() = default; + Param(uint32_t inputCount, const uint32_t *inputs, uint32_t outputCount, const uint32_t *outputs); +}; + +class Node final : public op::Node +{ +public: + Node(const Param ¶m) : _param(param) + { + // DO NOTHING + } + +public: + virtual ~Node() = default; + +public: + const Param ¶m(void) const { return _param; } + +public: + void accept(NodeVisitor &&) const override; + +private: + const Param _param; +}; + +} // namespace TransposeConv +} // namespace op +} // namespace tflite +} // namespace internal + +#endif // __INTERNAL_OP_TRANSPOSECONV_H__ diff --git a/runtimes/pure_arm_compute/src/internal/op/Unpack.cc b/runtimes/pure_arm_compute/src/internal/op/Unpack.cc new file mode 100644 index 000000000..a1be0280c --- /dev/null +++ b/runtimes/pure_arm_compute/src/internal/op/Unpack.cc @@ -0,0 +1,68 @@ +/* + * Copyright (c) 2018 Samsung Electronics Co., Ltd. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "internal/op/Unpack.h" +#include "internal/op/NodeVisitor.h" + +#include <cassert> + +namespace internal +{ +namespace tflite +{ +namespace op +{ +namespace Unpack +{ + +void Node::accept(NodeVisitor &&v) const { v.visit(*this); } + +} // namespace Unpack +} // namespace op +} // namespace tflite +} // namespace internal + +namespace internal +{ +namespace tflite +{ +namespace op +{ +namespace Unpack +{ +// There are three inputs: tensor which is to be unpacked, +// axis along which tensor needs to be unpacked +// and number of splits along the axis. + +Param::Param(uint32_t inputCount, const uint32_t *inputs, uint32_t outputCount, + const uint32_t *outputs) +{ + assert(inputCount == 3); + + ifm_index = inputs[0]; + + for (uint32_t n = 0; n < outputCount; ++n) + { + ofm_indexes.emplace_back(outputs[n]); + } + num_split_index = inputs[1]; + axis_index = inputs[2]; +} + +} // namespace Unpack +} // namespace op +} // namespace tflite +} // namespace internal diff --git a/runtimes/pure_arm_compute/src/internal/op/Unpack.h b/runtimes/pure_arm_compute/src/internal/op/Unpack.h new file mode 100644 index 000000000..575e3d024 --- /dev/null +++ b/runtimes/pure_arm_compute/src/internal/op/Unpack.h @@ -0,0 +1,72 @@ +/* + * Copyright (c) 2018 Samsung Electronics Co., Ltd. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef __INTERNAL_OP_UNPACK_H__ +#define __INTERNAL_OP_UNPACK_H__ + +#include "internal/op/Node.h" + +#include <cstdint> +#include <vector> + +namespace internal +{ +namespace tflite +{ +namespace op +{ +namespace Unpack +{ + +struct Param +{ + int32_t ifm_index; + int32_t axis_index; + int32_t num_split_index; + // There are N outputs after Unpacking Input Tensor along axis + std::vector<int32_t> ofm_indexes; + + Param() = default; + Param(uint32_t inputCount, const uint32_t *inputs, uint32_t outputCount, const uint32_t *outputs); +}; + +class Node final : public op::Node +{ +public: + Node(const Param ¶m) : _param(param) + { + // DO NOTHING + } + +public: + virtual ~Node() = default; + +public: + const Param ¶m(void) const { return _param; } + +public: + void accept(NodeVisitor &&) const override; + +private: + const Param _param; +}; + +} // namespace Unpack +} // namespace op +} // namespace tflite +} // namespace internal + +#endif // __INTERNAL_OP_UNPACK_H__ |