diff options
Diffstat (limited to 'runtimes/neurun/src/model/operation')
30 files changed, 0 insertions, 1621 deletions
diff --git a/runtimes/neurun/src/model/operation/AddNode.cc b/runtimes/neurun/src/model/operation/AddNode.cc deleted file mode 100644 index 0c9d4e09b..000000000 --- a/runtimes/neurun/src/model/operation/AddNode.cc +++ /dev/null @@ -1,49 +0,0 @@ -/* - * 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 "AddNode.h" - -#include <cassert> - -#include "NodeVisitor.h" - -namespace neurun -{ -namespace model -{ -namespace operation -{ - -void AddNode::accept(NodeVisitor &&v) const { v.visit(*this); } - -AddNode::AddNode(const model::operation::Node::InitParam &init_param) - : model::operation::Node{OperandConstraint::createExact(2u)} -{ - assert(init_param.input_count == 2); - assert(init_param.output_count == 1); - - // Each input should be interpreted as follows: - // - // 0 -> Lefthand side operand - // 1 -> Righthand side operand - - setInputs({init_param.inputs[0], init_param.inputs[1]}); - setOutputs({init_param.outputs[0]}); -} - -} // namespace operation -} // namespace model -} // namespace neurun diff --git a/runtimes/neurun/src/model/operation/AddNode.h b/runtimes/neurun/src/model/operation/AddNode.h deleted file mode 100644 index 533fb0ab3..000000000 --- a/runtimes/neurun/src/model/operation/AddNode.h +++ /dev/null @@ -1,54 +0,0 @@ -/* - * 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 __NEURUN_MODEL_OPERATION_ADD_NODE_H__ -#define __NEURUN_MODEL_OPERATION_ADD_NODE_H__ - -#include "model/operation/Node.h" - -namespace neurun -{ -namespace model -{ -namespace operation -{ - -class AddNode : public model::operation::Node -{ -public: - AddNode(const model::operation::Node::InitParam &init_param); - - enum Input - { - LHS = 0, - RHS - }; - - struct Param - { - operand::Index activation_index; - }; - -public: - virtual void accept(NodeVisitor &&) const override; - virtual std::string getName() const override { return "Add"; } -}; - -} // namespace operation -} // namespace model -} // namespace neurun - -#endif // __NEURUN_MODEL_OPERATION_ADD_H__ diff --git a/runtimes/neurun/src/model/operation/AvgPool2DNode.cc b/runtimes/neurun/src/model/operation/AvgPool2DNode.cc deleted file mode 100644 index 8c688e60a..000000000 --- a/runtimes/neurun/src/model/operation/AvgPool2DNode.cc +++ /dev/null @@ -1,62 +0,0 @@ -/* - * 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 "AvgPool2DNode.h" - -#include <cassert> - -#include "NodeVisitor.h" - -namespace neurun -{ -namespace model -{ -namespace operation -{ - -void AvgPool2DNode::accept(NodeVisitor &&v) const { v.visit(*this); } - -AvgPool2DNode::AvgPool2DNode(const model::operation::Node::InitParam &init_param) - : model::operation::Node{OperandConstraint::createExact(1u)} -{ - assert(init_param.input_count == 7); - assert(init_param.output_count == 1); - - // 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 - - setInputs({init_param.inputs[0]}); - setOutputs({init_param.outputs[0]}); - - _param.padding_index = operand::Index{init_param.inputs[1]}; - _param.hstride_index = operand::Index{init_param.inputs[2]}; - _param.vstride_index = operand::Index{init_param.inputs[3]}; - - _param.kw_index = operand::Index{init_param.inputs[4]}; - _param.kh_index = operand::Index{init_param.inputs[5]}; - _param.activation_index = operand::Index{init_param.inputs[6]}; -} - -} // namespace operation -} // namespace model -} // namespace neurun diff --git a/runtimes/neurun/src/model/operation/AvgPool2DNode.h b/runtimes/neurun/src/model/operation/AvgPool2DNode.h deleted file mode 100644 index e66e6146e..000000000 --- a/runtimes/neurun/src/model/operation/AvgPool2DNode.h +++ /dev/null @@ -1,68 +0,0 @@ -/* - * 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 __NEURUN_MODEL_OPERATION_AVGPOOL2D_NODE_H__ -#define __NEURUN_MODEL_OPERATION_AVGPOOL2D_NODE_H__ - -#include <memory> - -#include "model/operation/Node.h" - -namespace neurun -{ -namespace model -{ -namespace operation -{ - -class AvgPool2DNode : public model::operation::Node -{ -public: - AvgPool2DNode(const model::operation::Node::InitParam &init_param); - - enum Input - { - INPUT = 0 - }; - - struct Param - { - operand::Index kw_index; - operand::Index kh_index; - - operand::Index hstride_index; - operand::Index vstride_index; - - operand::Index padding_index; - operand::Index activation_index; - }; - -public: - virtual void accept(NodeVisitor &&) const override; - virtual std::string getName() const override { return "AvgPool2D"; } - -public: - const Param ¶m() const { return _param; } - -private: - Param _param; -}; - -} // namespace operation -} // namespace model -} // namespace neurun - -#endif // __NEURUN_MODEL_OPERATION_AVGPOOL2D_H__ diff --git a/runtimes/neurun/src/model/operation/ConcatNode.cc b/runtimes/neurun/src/model/operation/ConcatNode.cc deleted file mode 100644 index 23cfef294..000000000 --- a/runtimes/neurun/src/model/operation/ConcatNode.cc +++ /dev/null @@ -1,59 +0,0 @@ -/* - * 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 "ConcatNode.h" - -#include <cassert> - -#include "NodeVisitor.h" - -namespace neurun -{ -namespace model -{ -namespace operation -{ - -void ConcatNode::accept(NodeVisitor &&v) const { v.visit(*this); } - -ConcatNode::ConcatNode(const model::operation::Node::InitParam &init_param) - : model::operation::Node{OperandConstraint::createAtLeast(2u)} -{ - assert(init_param.input_count >= 2); // At least one one input tensor and axis - assert(init_param.output_count == 1); - - // When there are N + 1 inputs, each input should be interpreted as follows: - // - // [0, N) -> Input tensors - // N -> Axis - // - - { - operand::IndexSet inds; - for (uint32_t n = 0; n < init_param.input_count - 1; ++n) - { - inds.append(operand::Index{init_param.inputs[n]}); - } - setInputs(inds); - } - setOutputs({init_param.outputs[0]}); - - _param.axis_index = operand::Index{init_param.inputs[init_param.input_count - 1]}; -} - -} // namespace operation -} // namespace model -} // namespace neurun diff --git a/runtimes/neurun/src/model/operation/ConcatNode.h b/runtimes/neurun/src/model/operation/ConcatNode.h deleted file mode 100644 index b69ee2f23..000000000 --- a/runtimes/neurun/src/model/operation/ConcatNode.h +++ /dev/null @@ -1,56 +0,0 @@ -/* - * 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 __NEURUN_MODEL_OPERATION_CONCAT_NODE_H__ -#define __NEURUN_MODEL_OPERATION_CONCAT_NODE_H__ - -#include <memory> - -#include "model/operation/Node.h" - -namespace neurun -{ -namespace model -{ -namespace operation -{ - -class ConcatNode : public model::operation::Node -{ -public: - ConcatNode(const model::operation::Node::InitParam &init_param); - - struct Param - { - operand::Index axis_index; - }; - -public: - virtual void accept(NodeVisitor &&) const override; - virtual std::string getName() const override { return "Concat"; } - -public: - const Param ¶m() const { return _param; } - -private: - Param _param; -}; - -} // namespace operation -} // namespace model -} // namespace neurun - -#endif // __NEURUN_MODEL_OPERATION_CONCAT_H__ diff --git a/runtimes/neurun/src/model/operation/Conv2DNode.cc b/runtimes/neurun/src/model/operation/Conv2DNode.cc deleted file mode 100644 index 7eb2b183d..000000000 --- a/runtimes/neurun/src/model/operation/Conv2DNode.cc +++ /dev/null @@ -1,59 +0,0 @@ -/* - * 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 "Conv2DNode.h" - -#include <cassert> - -#include "NodeVisitor.h" - -namespace neurun -{ -namespace model -{ -namespace operation -{ - -void Conv2DNode::accept(NodeVisitor &&v) const { v.visit(*this); } - -Conv2DNode::Conv2DNode(const model::operation::Node::InitParam &init_param) - : model::operation::Node{OperandConstraint::createExact(3u)} -{ - assert(init_param.input_count == 7 && init_param.output_count == 1); - - // Each input should be interpreted as follows: - // - // - // 0 -> IFM Tensor Index - // 1 -> Kernel Tensor Index - // 2 -> Bias Tensor Index - // 3 -> Padding Code (ANEURALNETWORKS_PADDING_SAME or ANEURALNETWORKS_PADDING_VALID) Index - // 4 -> Stride (width) Index - // 5 -> Stride (height) INdex - // 6 -> Activation Index - - setInputs({init_param.inputs[0], init_param.inputs[1], init_param.inputs[2]}); - setOutputs({init_param.outputs[0]}); - - _param.padding_index = operand::Index{init_param.inputs[3]}; - _param.hstride_index = operand::Index{init_param.inputs[4]}; - _param.vstride_index = operand::Index{init_param.inputs[5]}; - _param.activation_index = operand::Index{init_param.inputs[6]}; -} - -} // namespace operation -} // namespace model -} // namespace neurun diff --git a/runtimes/neurun/src/model/operation/Conv2DNode.h b/runtimes/neurun/src/model/operation/Conv2DNode.h deleted file mode 100644 index 34a95f0d9..000000000 --- a/runtimes/neurun/src/model/operation/Conv2DNode.h +++ /dev/null @@ -1,67 +0,0 @@ -/* - * 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 __NEURUN_MODEL_OPERATION_CONV2D_NODE_H__ -#define __NEURUN_MODEL_OPERATION_CONV2D_NODE_H__ - -#include <memory> - -#include "model/operation/Node.h" - -namespace neurun -{ -namespace model -{ -namespace operation -{ - -class Conv2DNode : public model::operation::Node -{ -public: - Conv2DNode(const model::operation::Node::InitParam &); - - enum Input - { - INPUT = 0, - KERNEL, - BIAS - }; - - struct Param - { - operand::Index hstride_index; - operand::Index vstride_index; - - operand::Index padding_index; - operand::Index activation_index; - }; - -public: - virtual void accept(NodeVisitor &&) const override; - virtual std::string getName() const override { return "Conv2D"; } - -public: - const Param ¶m() const { return _param; } - -private: - Param _param; -}; - -} // namespace operation -} // namespace model -} // namespace neurun - -#endif // __NEURUN_MODEL_OPERATION_CONV2D_NODE_H__ diff --git a/runtimes/neurun/src/model/operation/FullyConnectedNode.cc b/runtimes/neurun/src/model/operation/FullyConnectedNode.cc deleted file mode 100644 index 0fde5182d..000000000 --- a/runtimes/neurun/src/model/operation/FullyConnectedNode.cc +++ /dev/null @@ -1,52 +0,0 @@ -/* - * 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 "FullyConnectedNode.h" - -#include <cassert> - -#include "NodeVisitor.h" - -namespace neurun -{ -namespace model -{ -namespace operation -{ - -void FullyConnectedNode::accept(NodeVisitor &&v) const { v.visit(*this); } - -FullyConnectedNode::FullyConnectedNode(const model::operation::Node::InitParam &init_param) - : model::operation::Node{OperandConstraint::createExact(3u)} -{ - assert(init_param.input_count == 4 && init_param.output_count == 1); - - // Each input should be interpreted as follows: - // - // 0 -> A tensor, specifying the input. - // 1 -> A 2-D tensor, specifying the weights - // 2 -> A 1-D tensor, specifying the bias - // 3 -> An INT32 value, and has to be one of the FuseCode values - - setInputs({init_param.inputs[0], init_param.inputs[1], init_param.inputs[2]}); - setOutputs({init_param.outputs[0]}); - - _param.activation_index = operand::Index{init_param.inputs[3]}; -} - -} // namespace operation -} // namespace model -} // namespace neurun diff --git a/runtimes/neurun/src/model/operation/FullyConnectedNode.h b/runtimes/neurun/src/model/operation/FullyConnectedNode.h deleted file mode 100644 index 9820ddc8c..000000000 --- a/runtimes/neurun/src/model/operation/FullyConnectedNode.h +++ /dev/null @@ -1,63 +0,0 @@ -/* - * 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 __NEURUN_MODEL_OPERATION_FULLYCONNECTED_NODE_H__ -#define __NEURUN_MODEL_OPERATION_FULLYCONNECTED_NODE_H__ - -#include <memory> - -#include "model/operation/Node.h" - -namespace neurun -{ -namespace model -{ -namespace operation -{ - -class FullyConnectedNode : public model::operation::Node -{ -public: - FullyConnectedNode(const model::operation::Node::InitParam &init_param); - - enum Input - { - INPUT = 0, - WEIGHT, - BIAS - }; - - struct Param - { - operand::Index activation_index; - }; - -public: - virtual void accept(NodeVisitor &&) const override; - virtual std::string getName() const override { return "FullyConnected"; } - -public: - const Param ¶m() const { return _param; } - -private: - Param _param; -}; - -} // namespace operation -} // namespace model -} // namespace neurun - -#endif // __NEURUN_MODEL_OPERATION_FULLYCONNECTED_NODE_H__ diff --git a/runtimes/neurun/src/model/operation/Index.h b/runtimes/neurun/src/model/operation/Index.h deleted file mode 100644 index e03dd74d6..000000000 --- a/runtimes/neurun/src/model/operation/Index.h +++ /dev/null @@ -1,35 +0,0 @@ -/* - * 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 __NEURUN_MODEL_OPERATION_INDEX_H__ -#define __NEURUN_MODEL_OPERATION_INDEX_H__ - -#include "graph/Index.h" - -namespace neurun -{ -namespace model -{ -namespace operation -{ - -using Index = ::neurun::graph::Index<uint32_t, struct IndexTag>; - -} // namespace operation -} // namespace model -} // namespace neurun - -#endif // __NEURUN_MODEL_OPERATION_INDEX_H__ diff --git a/runtimes/neurun/src/model/operation/IndexList.cc b/runtimes/neurun/src/model/operation/IndexList.cc deleted file mode 100644 index e46987036..000000000 --- a/runtimes/neurun/src/model/operation/IndexList.cc +++ /dev/null @@ -1,40 +0,0 @@ -/* - * 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 "IndexList.h" - -#include <algorithm> - -namespace neurun -{ -namespace model -{ -namespace operation -{ - -IndexList::IndexList(std::initializer_list<Index> list) : _list(list) -{ - // DO NOTHING -} - -bool IndexList::contains(const ::neurun::model::operation::Index &index) const -{ - return std::find(_list.begin(), _list.end(), index) != _list.end(); -} - -} // namespace operation -} // namespace model -} // namespace neurun diff --git a/runtimes/neurun/src/model/operation/IndexList.h b/runtimes/neurun/src/model/operation/IndexList.h deleted file mode 100644 index c0af29829..000000000 --- a/runtimes/neurun/src/model/operation/IndexList.h +++ /dev/null @@ -1,55 +0,0 @@ -/* - * 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 __NEURUN_MODEL_OPERATION_INDEX_LIST_H__ -#define __NEURUN_MODEL_OPERATION_INDEX_LIST_H__ - -#include <initializer_list> -#include <list> - -#include "Index.h" - -namespace neurun -{ -namespace model -{ -namespace operation -{ - -class IndexList -{ -public: - IndexList(void) = default; - IndexList(std::initializer_list<Index> list); - -public: - void append(const Index &index) { _list.push_back(index); } - void remove(const Index &index) { _list.remove(index); } - -public: - uint32_t size() const { return static_cast<uint32_t>(_list.size()); } - const std::list<Index> &list() const { return _list; } - bool contains(const Index &index) const; - -private: - std::list<Index> _list; -}; - -} // namespace operation -} // namespace model -} // namespace neurun - -#endif // __NEURUN_MODEL_OPERATION_INDEX_LIST_H__ diff --git a/runtimes/neurun/src/model/operation/MaxPool2DNode.cc b/runtimes/neurun/src/model/operation/MaxPool2DNode.cc deleted file mode 100644 index 3d3686b0e..000000000 --- a/runtimes/neurun/src/model/operation/MaxPool2DNode.cc +++ /dev/null @@ -1,62 +0,0 @@ -/* - * 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 "MaxPool2DNode.h" - -#include <cassert> - -#include "NodeVisitor.h" - -namespace neurun -{ -namespace model -{ -namespace operation -{ - -void MaxPool2DNode::accept(NodeVisitor &&v) const { v.visit(*this); } - -MaxPool2DNode::MaxPool2DNode(const model::operation::Node::InitParam &init_param) - : model::operation::Node{OperandConstraint::createExact(1u)} -{ - assert(init_param.input_count == 7); - assert(init_param.output_count == 1); - - // 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 - - setInputs({init_param.inputs[0]}); - setOutputs({init_param.outputs[0]}); - - _param.padding_index = operand::Index{init_param.inputs[1]}; - _param.hstride_index = operand::Index{init_param.inputs[2]}; - _param.vstride_index = operand::Index{init_param.inputs[3]}; - - _param.kw_index = operand::Index{init_param.inputs[4]}; - _param.kh_index = operand::Index{init_param.inputs[5]}; - _param.activation_index = operand::Index{init_param.inputs[6]}; -} - -} // namespace operation -} // namespace model -} // namespace neurun diff --git a/runtimes/neurun/src/model/operation/MaxPool2DNode.h b/runtimes/neurun/src/model/operation/MaxPool2DNode.h deleted file mode 100644 index 96d1210a7..000000000 --- a/runtimes/neurun/src/model/operation/MaxPool2DNode.h +++ /dev/null @@ -1,68 +0,0 @@ -/* - * 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 __NEURUN_MODEL_OPERATION_MAXPOOL2D_NODE_H__ -#define __NEURUN_MODEL_OPERATION_MAXPOOL2D_NODE_H__ - -#include <memory> - -#include "model/operation/Node.h" - -namespace neurun -{ -namespace model -{ -namespace operation -{ - -class MaxPool2DNode : public model::operation::Node -{ -public: - MaxPool2DNode(const model::operation::Node::InitParam &init_param); - - enum Input - { - INPUT = 0 - }; - - struct Param - { - operand::Index kw_index; - operand::Index kh_index; - - operand::Index hstride_index; - operand::Index vstride_index; - - operand::Index padding_index; - operand::Index activation_index; - }; - -public: - virtual void accept(NodeVisitor &&) const override; - virtual std::string getName() const override { return "MaxPool2D"; } - -public: - const Param ¶m() const { return _param; } - -private: - Param _param; -}; - -} // namespace operation -} // namespace model -} // namespace neurun - -#endif // __NEURUN_MODEL_OPERATION_MAXPOOL2D_NODE_H__ diff --git a/runtimes/neurun/src/model/operation/Node.Include.h b/runtimes/neurun/src/model/operation/Node.Include.h deleted file mode 100644 index 95e78c7b5..000000000 --- a/runtimes/neurun/src/model/operation/Node.Include.h +++ /dev/null @@ -1,27 +0,0 @@ -/* - * 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. - */ - -// This file has no ifdef guard intentionally - -#include "Conv2DNode.h" -#include "MaxPool2DNode.h" -#include "AvgPool2DNode.h" -#include "ConcatNode.h" -#include "ReshapeNode.h" -#include "FullyConnectedNode.h" -#include "SoftmaxNode.h" -#include "PermuteNode.h" -#include "AddNode.h" diff --git a/runtimes/neurun/src/model/operation/Node.cc b/runtimes/neurun/src/model/operation/Node.cc deleted file mode 100644 index 76397afde..000000000 --- a/runtimes/neurun/src/model/operation/Node.cc +++ /dev/null @@ -1,54 +0,0 @@ -/* - * 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 "Node.h" - -#include <cassert> - -#include "graph/operation/LowerInfo.h" - -namespace neurun -{ -namespace model -{ -namespace operation -{ - -Node::Node(OperandConstraint input_constr) : _input_constr{input_constr} {} - -Node::~Node() = default; - -void Node::setInputs(const operand::IndexSet &indexes) -{ - assert(_input_constr.check(indexes.size())); - _inputs = indexes; -} - -void Node::setOutputs(const operand::IndexSet &indexes) { _outputs = indexes; } - -void Node::replaceInput(const operand::Index &from, const operand::Index &to) -{ - _inputs.replace(from, to); -} - -void Node::replaceOutput(const operand::Index &from, const operand::Index &to) -{ - _outputs.replace(from, to); -} - -} // namespace operation -} // namespace model -} // namespace neurun diff --git a/runtimes/neurun/src/model/operation/Node.h b/runtimes/neurun/src/model/operation/Node.h deleted file mode 100644 index 76f0d2d00..000000000 --- a/runtimes/neurun/src/model/operation/Node.h +++ /dev/null @@ -1,84 +0,0 @@ -/* - * 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 __NEURUN_MODEL_OPERATION_NODE_H__ -#define __NEURUN_MODEL_OPERATION_NODE_H__ - -#include <memory> - -#include "model/operand/Object.h" -#include "model/operand/IndexSet.h" -#include "OperandConstraint.h" - -namespace neurun -{ -namespace graph -{ -namespace operation -{ -class LowerInfo; -} // namespace operation -} // namespace graph -} // namespace neurun - -namespace neurun -{ -namespace model -{ -namespace operation -{ - -struct NodeVisitor; - -class Node -{ -public: - struct InitParam - { - uint32_t input_count; - const uint32_t *inputs; - uint32_t output_count; - const uint32_t *outputs; - }; - -public: - Node(OperandConstraint input_constr); - virtual ~Node(); - -public: - virtual void accept(NodeVisitor &&) const = 0; - virtual std::string getName() const = 0; - -public: - void replaceInput(const operand::Index &from, const operand::Index &to); - void replaceOutput(const operand::Index &from, const operand::Index &to); - const operand::IndexSet &getInputs() const { return _inputs; } - const operand::IndexSet &getOutputs() const { return _outputs; } - // It's for only input/output tensors but const data. - void setInputs(const operand::IndexSet &indexes); - void setOutputs(const operand::IndexSet &indexes); - -private: - operand::IndexSet _inputs; - operand::IndexSet _outputs; - OperandConstraint _input_constr; -}; - -} // namespace operation -} // namespace model -} // namespace neurun - -#endif // __NEURUN_MODEL_OPERATION_NODE_H__ diff --git a/runtimes/neurun/src/model/operation/NodeVisitor.h b/runtimes/neurun/src/model/operation/NodeVisitor.h deleted file mode 100644 index 8420de998..000000000 --- a/runtimes/neurun/src/model/operation/NodeVisitor.h +++ /dev/null @@ -1,43 +0,0 @@ -/* - * 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 __NEURUN_MODEL_OPERATION_NODE_VISITOR_H__ -#define __NEURUN_MODEL_OPERATION_NODE_VISITOR_H__ - -#include "Node.Include.h" - -namespace neurun -{ -namespace model -{ -namespace operation -{ - -struct NodeVisitor -{ - virtual ~NodeVisitor() = default; - -#define OP(InternalName, IsNnApi, NnApiName) \ - virtual void visit(const InternalName &) {} -#include "model/operation/Op.lst" -#undef OP -}; - -} // namespace operation -} // namespace model -} // namespace neurun - -#endif // __NEURUN_MODEL_OPERATION_NODE_VISITOR_H__ diff --git a/runtimes/neurun/src/model/operation/Op.lst b/runtimes/neurun/src/model/operation/Op.lst deleted file mode 100644 index 23f4b5118..000000000 --- a/runtimes/neurun/src/model/operation/Op.lst +++ /dev/null @@ -1,32 +0,0 @@ -/* - * 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 OP -#error Define OP before including this file -#endif - -// NOTE The relation between "Internal Name" and "NN API Name" is "1 : N". - -// Internal Name | NN API? | NN API Name -OP(AddNode , true , ADD) -OP(Conv2DNode , true , CONV_2D) -OP(AvgPool2DNode , true , AVERAGE_POOL_2D) -OP(MaxPool2DNode , true , MAX_POOL_2D) -OP(ConcatNode , true , CONCATENATION) -OP(FullyConnectedNode , true , FULLY_CONNECTED) -OP(ReshapeNode , true , RESHAPE) -OP(SoftmaxNode , true , SOFTMAX) -OP(PermuteNode , false , NOT_AVAILABLE) diff --git a/runtimes/neurun/src/model/operation/OperandConstraint.cc b/runtimes/neurun/src/model/operation/OperandConstraint.cc deleted file mode 100644 index 5c69de928..000000000 --- a/runtimes/neurun/src/model/operation/OperandConstraint.cc +++ /dev/null @@ -1,28 +0,0 @@ -/* - * 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 "OperandConstraint.h" - -namespace neurun -{ -namespace model -{ -namespace operation -{ - -} // namespace operation -} // namespace model -} // namespace neurun diff --git a/runtimes/neurun/src/model/operation/OperandConstraint.h b/runtimes/neurun/src/model/operation/OperandConstraint.h deleted file mode 100644 index d1cd8aa2c..000000000 --- a/runtimes/neurun/src/model/operation/OperandConstraint.h +++ /dev/null @@ -1,61 +0,0 @@ -/* - * 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 __NEURUN_MODEL_OPERATION_OPERAND_CONSTRAINT_H__ -#define __NEURUN_MODEL_OPERATION_OPERAND_CONSTRAINT_H__ - -#include <stdint.h> -#include <limits> -#include <set> - -namespace neurun -{ -namespace model -{ -namespace operation -{ - -class OperandConstraint -{ -private: - static const uint32_t INF = std::numeric_limits<uint32_t>::max(); - -public: - static OperandConstraint createAny() { return OperandConstraint{0u, INF}; } - static OperandConstraint createExact(uint32_t exact) { return OperandConstraint{exact, exact}; } - static OperandConstraint createAtMost(uint32_t end) { return OperandConstraint{0u, end}; } - static OperandConstraint createAtLeast(uint32_t begin) { return OperandConstraint{begin, INF}; } - static OperandConstraint createInRange(uint32_t begin, uint32_t end) - { - return OperandConstraint{begin, end}; - } - -private: - OperandConstraint(uint32_t begin, uint32_t end) : _begin{begin}, _end{end} {} - -public: - bool check(uint32_t ind) const { return _begin <= ind && ind <= _end; } - -private: - uint32_t _begin; - uint32_t _end; -}; - -} // namespace operation -} // namespace model -} // namespace neurun - -#endif // __NEURUN_MODEL_OPERATION_OPERAND_CONSTRAINT_H__ diff --git a/runtimes/neurun/src/model/operation/PermuteNode.cc b/runtimes/neurun/src/model/operation/PermuteNode.cc deleted file mode 100644 index 174d2a86b..000000000 --- a/runtimes/neurun/src/model/operation/PermuteNode.cc +++ /dev/null @@ -1,41 +0,0 @@ -/* - * 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 "PermuteNode.h" - -#include <cassert> - -#include "NodeVisitor.h" - -namespace neurun -{ -namespace model -{ -namespace operation -{ - -void PermuteNode::accept(NodeVisitor &&v) const { v.visit(*this); } - -PermuteNode::PermuteNode(const operand::Index &input, const operand::Index &output, Type type) - : model::operation::Node{OperandConstraint::createExact(1u)}, _param{type} -{ - setInputs({input}); - setOutputs({output}); -} - -} // namespace operation -} // namespace model -} // namespace neurun diff --git a/runtimes/neurun/src/model/operation/PermuteNode.h b/runtimes/neurun/src/model/operation/PermuteNode.h deleted file mode 100644 index b589975be..000000000 --- a/runtimes/neurun/src/model/operation/PermuteNode.h +++ /dev/null @@ -1,62 +0,0 @@ -/* - * 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 __NEURUN_MODEL_OPERATION_PERMUTE_NODE_H__ -#define __NEURUN_MODEL_OPERATION_PERMUTE_NODE_H__ - -#include "model/operation/Node.h" - -namespace neurun -{ -namespace model -{ -namespace operation -{ - -class PermuteNode : public model::operation::Node -{ -public: - enum class Type - { - NHWC_TO_NCHW, - NCHW_TO_NHWC, - COPY - }; - - struct Param - { - Type type; - }; - -public: - virtual void accept(NodeVisitor &&) const override; - virtual std::string getName() const override { return "Permute"; } - -public: - PermuteNode(const operand::Index &input, const operand::Index &output, Type type); - -public: - const Param ¶m() const { return _param; } - -private: - Param _param; -}; - -} // namespace operation -} // namespace model -} // namespace neurun - -#endif // __NEURUN_MODEL_OPERATION_PERMUTE_NODE_H__ diff --git a/runtimes/neurun/src/model/operation/ReshapeNode.cc b/runtimes/neurun/src/model/operation/ReshapeNode.cc deleted file mode 100644 index 616b8cd65..000000000 --- a/runtimes/neurun/src/model/operation/ReshapeNode.cc +++ /dev/null @@ -1,50 +0,0 @@ -/* - * 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 "ReshapeNode.h" - -#include <cassert> - -#include "NodeVisitor.h" - -namespace neurun -{ -namespace model -{ -namespace operation -{ - -void ReshapeNode::accept(NodeVisitor &&v) const { v.visit(*this); } - -ReshapeNode::ReshapeNode(const model::operation::Node::InitParam &init_param) - : model::operation::Node{OperandConstraint::createExact(1u)} -{ - assert(init_param.input_count == 2 && init_param.output_count == 1); - - // Each input should be interpreted as follows: - // - // 0 -> A tensor, specifying the tensor to be reshaped. - // 1 -> A 1-D tensor of type ANEURALNETWORKS_TENSOR_INT32, defining the shape of the output - // tensor - - // TODO Second input should be shape tensor (init_param.inputs[1]) - setInputs({init_param.inputs[0] /* , init_param.inputs[1] */}); - setOutputs({init_param.outputs[0]}); -} - -} // namespace operation -} // namespace model -} // namespace neurun diff --git a/runtimes/neurun/src/model/operation/ReshapeNode.h b/runtimes/neurun/src/model/operation/ReshapeNode.h deleted file mode 100644 index 1758e9ec8..000000000 --- a/runtimes/neurun/src/model/operation/ReshapeNode.h +++ /dev/null @@ -1,50 +0,0 @@ -/* - * 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 __NEURUN_MODEL_OPERATION_RESHAPE_NODE_H__ -#define __NEURUN_MODEL_OPERATION_RESHAPE_NODE_H__ - -#include <memory> - -#include "model/operation/Node.h" - -namespace neurun -{ -namespace model -{ -namespace operation -{ - -class ReshapeNode : public model::operation::Node -{ -public: - ReshapeNode(const model::operation::Node::InitParam &init_param); - - enum Input - { - INPUT = 0 - }; - -public: - virtual void accept(NodeVisitor &&) const override; - virtual std::string getName() const override { return "Reshape"; } -}; - -} // namespace operation -} // namespace model -} // namespace neurun - -#endif // __NEURUN_MODEL_OPERATION_RESHAPE_NODE_H__ diff --git a/runtimes/neurun/src/model/operation/Set.cc b/runtimes/neurun/src/model/operation/Set.cc deleted file mode 100644 index 14bd4f584..000000000 --- a/runtimes/neurun/src/model/operation/Set.cc +++ /dev/null @@ -1,67 +0,0 @@ -/* - * 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 "Set.h" - -#include <cassert> - -namespace neurun -{ -namespace model -{ -namespace operation -{ - -const Index Set::generateIndex() -{ - assert((_index_count) <= 0x7fffffff); - - return Index{_index_count++}; -} - -Index Set::append(std::unique_ptr<Node> &&node) -{ - auto index = generateIndex(); - - _nodes[index] = std::move(node); - return index; -} - -const Node &Set::at(const Index &index) const { return *(_nodes.at(index)); } - -Node &Set::at(const Index &index) { return *(_nodes.at(index)); } - -bool Set::exist(const Index &index) const { return _nodes.find(index) != _nodes.end(); } - -void Set::iterate(const std::function<void(const Index &, const Node &)> &fn) const -{ - for (auto it = _nodes.begin(); it != _nodes.end(); ++it) - { - fn(it->first, *it->second); - } -} - -void Set::iterate(const std::function<void(const Index &, Node &)> &fn) -{ - for (auto it = _nodes.begin(); it != _nodes.end(); ++it) - { - fn(it->first, *it->second); - } -} - -} // namespace operation -} // namespace model -} // namespace neurun diff --git a/runtimes/neurun/src/model/operation/Set.h b/runtimes/neurun/src/model/operation/Set.h deleted file mode 100644 index eebf91e65..000000000 --- a/runtimes/neurun/src/model/operation/Set.h +++ /dev/null @@ -1,63 +0,0 @@ -/* - * 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 __NEURUN_MODEL_OPERATION_SET_H__ -#define __NEURUN_MODEL_OPERATION_SET_H__ - -#include <memory> - -#include "model/operation/Index.h" -#include "Node.h" - -#include <unordered_map> - -namespace neurun -{ -namespace model -{ -namespace operation -{ - -class Set -{ -public: - Set() : _index_count(0) {} - -public: - Index append(std::unique_ptr<Node> &&node); - void remove(const Index &index) { _nodes.erase(index); }; - -public: - const Node &at(const Index &) const; - Node &at(const Index &); - bool exist(const Index &) const; - uint32_t size() const { return _nodes.size(); } - void iterate(const std::function<void(const Index &, const Node &)> &fn) const; - void iterate(const std::function<void(const Index &, Node &)> &fn); - -private: - const Index generateIndex(); - -private: - std::unordered_map<Index, std::unique_ptr<Node>> _nodes; - uint32_t _index_count; -}; - -} // namespace operation -} // namespace model -} // namespace neurun - -#endif // __NEURUN_MODEL_OPERATION_SET_H__ diff --git a/runtimes/neurun/src/model/operation/SoftmaxNode.cc b/runtimes/neurun/src/model/operation/SoftmaxNode.cc deleted file mode 100644 index d157aa4a7..000000000 --- a/runtimes/neurun/src/model/operation/SoftmaxNode.cc +++ /dev/null @@ -1,50 +0,0 @@ -/* - * 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 "SoftmaxNode.h" - -#include <cassert> - -#include "NodeVisitor.h" - -namespace neurun -{ -namespace model -{ -namespace operation -{ - -void SoftmaxNode::accept(NodeVisitor &&v) const { v.visit(*this); } - -SoftmaxNode::SoftmaxNode(const model::operation::Node::InitParam &init_param) - : model::operation::Node{OperandConstraint::createExact(1u)} -{ - assert(init_param.input_count == 2 && init_param.output_count == 1); - - // Each input should be interpreted as follows: - // - // 0 -> A 2-D or 4-D tensor, specifying the tensor to be reshaped. - // 1 -> FLOAT32 value, specifying the positive scaling factor for the exponent, beta. - - setInputs({init_param.inputs[0]}); - setOutputs({init_param.outputs[0]}); - - _param.scale_index = operand::Index{init_param.inputs[1]}; -} - -} // namespace operation -} // namespace model -} // namespace neurun diff --git a/runtimes/neurun/src/model/operation/SoftmaxNode.h b/runtimes/neurun/src/model/operation/SoftmaxNode.h deleted file mode 100644 index 4a5a72e5a..000000000 --- a/runtimes/neurun/src/model/operation/SoftmaxNode.h +++ /dev/null @@ -1,60 +0,0 @@ -/* - * 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 __NEURUN_MODEL_OPERATION_SOFTMAX_NODE_H__ -#define __NEURUN_MODEL_OPERATION_SOFTMAX_NODE_H__ - -#include <memory> - -#include "model/operation/Node.h" - -namespace neurun -{ -namespace model -{ -namespace operation -{ - -class SoftmaxNode : public model::operation::Node -{ -public: - SoftmaxNode(const model::operation::Node::InitParam &init_param); - enum Input - { - INPUT = 0 - }; - - struct Param - { - operand::Index scale_index; - }; - -public: - virtual void accept(NodeVisitor &&) const override; - virtual std::string getName() const override { return "SoftMax"; } - -public: - const Param ¶m() const { return _param; } - -private: - Param _param; -}; - -} // namespace operation -} // namespace model -} // namespace neurun - -#endif // __NEURUN_MODEL_OPERATION_SOFTMAX_NODE_H__ |