From 38d67b13ce7e4cf1f43df35cac3a23f8d9225b7e Mon Sep 17 00:00:00 2001 From: =?utf8?q?=EC=9D=B4=ED=95=9C=EC=A2=85/=EB=8F=99=EC=9E=91=EC=A0=9C?= =?utf8?q?=EC=96=B4Lab=28SR=29/Engineer/=EC=82=BC=EC=84=B1=EC=A0=84?= =?utf8?q?=EC=9E=90?= Date: Thu, 4 Oct 2018 19:30:48 +0900 Subject: [PATCH] [neurun] Introduce Enum `Input` for the rest ops (#2947) Introduce Enum `Input` for Reshape and Softmax to avoid using magic numbers from input list. Signed-off-by: Hanjoung Lee --- runtimes/neurun/src/backend/acl_cl/StageGenerator.cc | 4 ++-- runtimes/neurun/src/backend/cpu/StageGenerator.cc | 4 ++-- runtimes/neurun/src/graph/operation/Reshape.h | 5 +++++ runtimes/neurun/src/graph/operation/Softmax.h | 5 +++++ 4 files changed, 14 insertions(+), 4 deletions(-) diff --git a/runtimes/neurun/src/backend/acl_cl/StageGenerator.cc b/runtimes/neurun/src/backend/acl_cl/StageGenerator.cc index 513bf27..b27368b 100644 --- a/runtimes/neurun/src/backend/acl_cl/StageGenerator.cc +++ b/runtimes/neurun/src/backend/acl_cl/StageGenerator.cc @@ -467,7 +467,7 @@ Stage StageGenerator::generate(const graph::operation::FullyConnected::Node &nod Stage StageGenerator::generate(const graph::operation::Reshape::Node &node) { const auto output_index{node.getOutputs().at(0)}; - const auto input_index{node.getInputs().at(0)}; + const auto input_index{node.getInputs().at(graph::operation::Reshape::Input::INPUT)}; struct Param { @@ -497,7 +497,7 @@ Stage StageGenerator::generate(const graph::operation::Reshape::Node &node) Stage StageGenerator::generate(const graph::operation::Softmax::Node &node) { const auto output_index{node.getOutputs().at(0)}; - const auto input_index{node.getInputs().at(0)}; + const auto input_index{node.getInputs().at(graph::operation::Softmax::Input::INPUT)}; const auto scale_index{node.param().scale_index}; assert(_ctx.at(scale_index).shape().rank() == 0); diff --git a/runtimes/neurun/src/backend/cpu/StageGenerator.cc b/runtimes/neurun/src/backend/cpu/StageGenerator.cc index 6f24fe3..fad147c 100644 --- a/runtimes/neurun/src/backend/cpu/StageGenerator.cc +++ b/runtimes/neurun/src/backend/cpu/StageGenerator.cc @@ -449,7 +449,7 @@ Stage StageGenerator::generate(const graph::operation::FullyConnected::Node &nod Stage StageGenerator::generate(const graph::operation::Reshape::Node &node) { const auto output_index{node.getOutputs().at(0)}; - const auto input_index{node.getInputs().at(0)}; + const auto input_index{node.getInputs().at(graph::operation::Reshape::Input::INPUT)}; struct Param { @@ -488,7 +488,7 @@ Stage StageGenerator::generate(const graph::operation::Softmax::Node &node) VERBOSE(Softmax) << "generate CPU Softmax" << std::endl; const auto output_index{node.getOutputs().at(0)}; - const auto input_index{node.getInputs().at(0)}; + const auto input_index{node.getInputs().at(graph::operation::Softmax::Input::INPUT)}; const auto scale_index{node.param().scale_index}; struct Param diff --git a/runtimes/neurun/src/graph/operation/Reshape.h b/runtimes/neurun/src/graph/operation/Reshape.h index b86cfc9..ede243a 100644 --- a/runtimes/neurun/src/graph/operation/Reshape.h +++ b/runtimes/neurun/src/graph/operation/Reshape.h @@ -30,6 +30,11 @@ namespace operation namespace Reshape { +enum Input +{ + INPUT = 0 +}; + class Node : public graph::operation::Node { public: diff --git a/runtimes/neurun/src/graph/operation/Softmax.h b/runtimes/neurun/src/graph/operation/Softmax.h index 8ab44f8..a1575bc 100644 --- a/runtimes/neurun/src/graph/operation/Softmax.h +++ b/runtimes/neurun/src/graph/operation/Softmax.h @@ -30,6 +30,11 @@ namespace operation namespace Softmax { +enum Input +{ + INPUT = 0 +}; + struct Param { operand::Index scale_index; -- 2.7.4