This commit enables `ReLU`, `RSQRT` for `acl_ac`.
Signed-off-by: sjsujinkim <sjsujin.kim@samsung.com>
});
}
+void StageGenerator::visit(const model::operation::RSQRTNode &node)
+{
+ const auto output_index{node.getOutputs().at(0)};
+ const auto input_index{node.getInputs().at(model::operation::LogisticNode::Input::INPUT)};
+
+ // Construct operation parameters
+ struct Param
+ {
+ model::operand::Index ofm_index;
+ model::operand::Index ifm_index;
+ };
+
+ Param param;
+
+ param.ofm_index = output_index;
+ param.ifm_index = input_index;
+
+ auto tensors = _tensor_builder;
+
+ returnStage([tensors, param](IExecutionBuilder &builder) {
+ auto ofm_alloc = tensors->at(param.ofm_index).get();
+ auto ifm_alloc = tensors->at(param.ifm_index).get();
+
+ const ::arm_compute::ActivationLayerInfoEx act_info{
+ ::arm_compute::ActivationLayerInfoEx::ActivationFunction::RSQRT};
+
+ auto fn = make_layer<::arm_compute::CLActivationLayerEx>();
+
+ fn->configure(ifm_alloc->handle(), ofm_alloc->handle(), act_info);
+
+ auto acl_fn = make_cl_function(std::move(fn));
+
+ builder.append(std::move(acl_fn));
+ });
+}
+
+void StageGenerator::visit(const model::operation::ReLUNode &node)
+{
+ const auto output_index{node.getOutputs().at(0)};
+ const auto input_index{node.getInputs().at(model::operation::ReLUNode::Input::INPUT)};
+
+ struct Param
+ {
+ model::operand::Index output_index;
+ model::operand::Index input_index;
+ };
+
+ Param param;
+
+ param.output_index = output_index;
+ param.input_index = input_index;
+
+ auto tensors = _tensor_builder;
+
+ returnStage([tensors, param](IExecutionBuilder &builder) {
+ auto output_alloc = tensors->at(param.output_index).get();
+ auto input_alloc = tensors->at(param.input_index).get();
+
+ auto fn = make_layer<arm_compute::CLActivationLayer>();
+
+ const ::arm_compute::ActivationLayerInfo act_info{
+ ::arm_compute::ActivationLayerInfo::ActivationFunction::RELU};
+
+ fn->configure(input_alloc->handle(), output_alloc->handle(), act_info);
+
+ auto acl_fn = make_cl_function(std::move(fn));
+
+ builder.append(std::move(acl_fn));
+ });
+}
+
} // namespace acl_cl
} // namespace backend
} // namespace neurun
virtual void visit(const model::operation::ReduceMaxNode &) override;
virtual void visit(const model::operation::NotEqualNode &) override;
virtual void visit(const model::operation::LogicalAndNode &) override;
+ virtual void visit(const model::operation::RSQRTNode &) override;
+ virtual void visit(const model::operation::ReLUNode &) override;
private:
const neurun::model::operand::Set &_ctx;
return new operation::LogicalAndNode{inputs, outputs};
};
+
+ _map[ANEURALNETWORKS_RSQRT_EX] = [](const OperationFactory::Param &init_param) {
+ assert(init_param.input_count == 1 && init_param.output_count == 1);
+
+ operand::IndexSet outputs{init_param.outputs[0]};
+
+ // Each input should be interpreted as follows:
+ //
+ // 0 -> Input Tensor Index
+ operand::IndexSet inputs{init_param.inputs[0]};
+
+ return new operation::RSQRTNode{inputs, outputs};
+ };
+
+ _map[ANEURALNETWORKS_RELU] = [](const OperationFactory::Param &init_param) {
+ assert(init_param.input_count == 1 && init_param.output_count == 1);
+
+ operand::IndexSet outputs{init_param.outputs[0]};
+
+ // Each input should be interpreted as follows:
+ //
+ // 0 -> Input Tensor Index
+ operand::IndexSet inputs{init_param.inputs[0]};
+
+ return new operation::ReLUNode{inputs, outputs};
+ };
}
neurun::model::operation::Node *OperationFactory::create(ANeuralNetworksOperationType type,
#include "ReduceMaxNode.h"
#include "NotEqualNode.h"
#include "LogicalAndNode.h"
+#include "RSQRTNode.h"
+#include "ReLUNode.h"
OP(ReduceMaxNode , true , TENSORFLOW_MAX_EX)
OP(NotEqualNode , true , NOT_EQUAL_EX)
OP(LogicalAndNode , true , LOGICAL_AND_EX)
+OP(RSQRTNode , true , RSQRT_EX)
+OP(ReLUNode , true , RELU)
OP(PermuteNode , false , NOT_AVAILABLE)
--- /dev/null
+/*
+ * Copyright (c) 2019 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 "RSQRTNode.h"
+
+#include <cassert>
+
+#include "NodeVisitor.h"
+
+namespace neurun
+{
+namespace model
+{
+namespace operation
+{
+
+void RSQRTNode::accept(NodeVisitor &&v) const { v.visit(*this); }
+
+RSQRTNode::RSQRTNode(const operand::IndexSet &inputs, const operand::IndexSet &outputs)
+ : model::operation::Node{OperandConstraint::createExact(1u), inputs, outputs}
+{
+}
+
+} // namespace operation
+} // namespace model
+} // namespace neurun
--- /dev/null
+/*
+ * Copyright (c) 2019 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_RSQRT_NODE_H__
+#define __NEURUN_MODEL_OPERATION_RSQRT_NODE_H__
+
+#include "model/operation/Node.h"
+
+namespace neurun
+{
+namespace model
+{
+namespace operation
+{
+
+class RSQRTNode : public model::operation::Node
+{
+public:
+ enum Input
+ {
+ INPUT = 0
+ };
+
+public:
+ RSQRTNode(const operand::IndexSet &inputs, const operand::IndexSet &outputs);
+
+public:
+ virtual void accept(NodeVisitor &&) const override;
+ virtual std::string getName() const override { return "RSQRT"; }
+};
+
+} // namespace operation
+} // namespace model
+} // namespace neurun
+
+#endif // __NEURUN_MODEL_OPERATION_RSQRT_NODE_H__
--- /dev/null
+/*
+ * Copyright (c) 2019 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 "ReLUNode.h"
+
+#include <cassert>
+
+#include "NodeVisitor.h"
+
+namespace neurun
+{
+namespace model
+{
+namespace operation
+{
+
+void ReLUNode::accept(NodeVisitor &&v) const { v.visit(*this); }
+
+ReLUNode::ReLUNode(const operand::IndexSet &inputs, const operand::IndexSet &outputs)
+ : model::operation::Node{OperandConstraint::createExact(1u), inputs, outputs}
+{
+}
+
+} // namespace operation
+} // namespace model
+} // namespace neurun
--- /dev/null
+/*
+ * Copyright (c) 2019 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_RELU_NODE_H__
+#define __NEURUN_MODEL_OPERATION_RELU_NODE_H__
+
+#include "model/operation/Node.h"
+
+namespace neurun
+{
+namespace model
+{
+namespace operation
+{
+
+class ReLUNode : public model::operation::Node
+{
+public:
+ enum Input
+ {
+ INPUT = 0
+ };
+
+public:
+ ReLUNode(const operand::IndexSet &inputs, const operand::IndexSet &outputs);
+
+public:
+ virtual void accept(NodeVisitor &&) const override;
+ virtual std::string getName() const override { return "ReLU"; }
+};
+
+} // namespace operation
+} // namespace model
+} // namespace neurun
+
+#endif // __NEURUN_MODEL_OPERATION_RELU_NODE_H__
GeneratedTests.reduce_min*
GeneratedTests.relu1*
GeneratedTests.relu6*
-GeneratedTests.relu*
GeneratedTests.resize_bilinear*
GeneratedTests.rnn*
-GeneratedTests.rsqrt*
GeneratedTests.mean*
GeneratedTests.pad*
GeneratedTests.space_to_depth*
not_equal
softmax
reduce_max
+relu
reshape
+rsqrt
strided_slice
sub/broadcast
tanh