From 9817f7e1d17538a97d15e5ef55827a1bfd43639e 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: Wed, 29 Aug 2018 14:41:05 +0900 Subject: [PATCH] [neurun] Update Dumper class (#2513) As we have unified graph operation nodes, this commit updates class `Dumper` accordingly. Signed-off-by: Hanjoung Lee --- runtimes/neurun/src/codegen/Dumper.cc | 54 +++++++++++++++++------------------ runtimes/neurun/src/codegen/Dumper.h | 20 ++++++------- runtimes/neurun/src/compilation.cc | 3 +- 3 files changed, 38 insertions(+), 39 deletions(-) diff --git a/runtimes/neurun/src/codegen/Dumper.cc b/runtimes/neurun/src/codegen/Dumper.cc index 1ff1b90..d130bd8 100644 --- a/runtimes/neurun/src/codegen/Dumper.cc +++ b/runtimes/neurun/src/codegen/Dumper.cc @@ -9,79 +9,79 @@ namespace neurun namespace codegen { -using namespace ::internal::tflite::op; +using namespace neurun::graph::operation; -void Dumper::visit(const Conv2D::implicit::Node &node) +void Dumper::visit(const Conv2D::Implicit::Node &node) { VERBOSE(LIR) << "* Conv2D(Implicit)" << std::endl; - VERBOSE(LIR) << " - Inputs : IFM(" << node.param().ifm_index << ") Kernel(" - << node.param().ker_index << ") Bias(" << node.param().bias_index << ")" - << std::endl; - VERBOSE(LIR) << " - Output : OFM(" << node.param().ofm_index << ")" << std::endl; + VERBOSE(LIR) << " - Inputs : IFM(" << node.getInputs().at(0).value() << ") Kernel(" + << node.getInputs().at(1).value() << ") Bias(" << node.getInputs().at(2).value() + << ")" << std::endl; + VERBOSE(LIR) << " - Output : OFM(" << node.getOutputs().at(0).value() << ")" << std::endl; } -void Dumper::visit(const MaxPool2D::implicit::Node &node) +void Dumper::visit(const MaxPool2D::Implicit::Node &node) { VERBOSE(LIR) << "* MaxPool2D(Implicit)" << std::endl; - VERBOSE(LIR) << " - Inputs : IFM(" << node.param().ifm_index << ")" << std::endl; - VERBOSE(LIR) << " - Output : OFM(" << node.param().ofm_index << ")" << std::endl; + VERBOSE(LIR) << " - Inputs : IFM(" << node.getInputs().at(0).value() << ")" << std::endl; + VERBOSE(LIR) << " - Output : OFM(" << node.getOutputs().at(0).value() << ")" << std::endl; } -void Dumper::visit(const AvgPool2D::implicit::Node &node) +void Dumper::visit(const AvgPool2D::Implicit::Node &node) { VERBOSE(LIR) << "* AvgPool2D(Implicit)" << std::endl; - VERBOSE(LIR) << " - Inputs : IFM(" << node.param().ifm_index << ")" << std::endl; - VERBOSE(LIR) << " - Output : OFM(" << node.param().ofm_index << ")" << std::endl; + VERBOSE(LIR) << " - Inputs : IFM(" << node.getInputs().at(0).value() << ")" << std::endl; + VERBOSE(LIR) << " - Output : OFM(" << node.getOutputs().at(0).value() << ")" << std::endl; } void Dumper::visit(const Concat::Node &node) { VERBOSE(LIR) << "* Concat" << std::endl; std::string inputs; - for (auto i : node.param().ifm_indexes) + for (auto i : node.getInputs().list()) { - inputs += std::to_string(i) + ","; + inputs += std::to_string(i.value()) + ","; } VERBOSE(LIR) << " - Inputs : IFM(" << inputs << ")" << std::endl; - VERBOSE(LIR) << " - Output : OFM(" << node.param().ofm_index << ")" << std::endl; + VERBOSE(LIR) << " - Output : OFM(" << node.getOutputs().at(0).value() << ")" << std::endl; } void Dumper::visit(const FullyConnected::Node &node) { VERBOSE(LIR) << "* FullyConnected" << std::endl; - VERBOSE(LIR) << " - Inputs : IFM(" << node.param().input_index << ") Weight(" - << node.param().weight_index << ") Bias(" << node.param().bias_index << ")" - << std::endl; - VERBOSE(LIR) << " - Output : OFM(" << node.param().output_index << ")" << std::endl; + VERBOSE(LIR) << " - Inputs : IFM(" << node.getInputs().at(0).value() << ") Weight(" + << node.getInputs().at(1).value() << ") Bias(" << node.getInputs().at(2).value() + << ")" << std::endl; + VERBOSE(LIR) << " - Output : OFM(" << node.getOutputs().at(0).value() << ")" << std::endl; } void Dumper::visit(const Reshape::Node &node) { VERBOSE(LIR) << "* Reshape" << std::endl; - VERBOSE(LIR) << " - Inputs : IFM(" << node.param().input_index << ") Shape(" + VERBOSE(LIR) << " - Inputs : IFM(" << node.getInputs().at(0).value() << ") Shape(" << node.param().shape_index << ")" << std::endl; - VERBOSE(LIR) << " - Output : OFM(" << node.param().output_index << ")" << std::endl; + VERBOSE(LIR) << " - Output : OFM(" << node.getOutputs().at(0).value() << ")" << std::endl; } void Dumper::visit(const Softmax::Node &node) { VERBOSE(LIR) << "* Softmax" << std::endl; - VERBOSE(LIR) << " - Inputs : IFM(" << node.param().input_index << ")" << std::endl; - VERBOSE(LIR) << " - Output : OFM(" << node.param().output_index << ")" << std::endl; + VERBOSE(LIR) << " - Inputs : IFM(" << node.getInputs().at(0).value() << ")" << std::endl; + VERBOSE(LIR) << " - Output : OFM(" << node.getOutputs().at(0).value() << ")" << std::endl; } void Dumper::visit(const NOP::Node &node) { VERBOSE(LIR) << "* NOP" << std::endl; std::string inputs, outputs; - for (auto i : node.param().ifm_indexes) + for (auto i : node.getInputs().list()) { - inputs += std::to_string(i) + ","; + inputs += std::to_string(i.value()) + ","; } VERBOSE(LIR) << " - Inputs : IFM(" << inputs << ")" << std::endl; - for (auto i : node.param().ofm_indexes) + for (auto i : node.getOutputs().list()) { - outputs += std::to_string(i) + ","; + outputs += std::to_string(i.value()) + ","; } VERBOSE(LIR) << " - Outputs : OFM(" << outputs << ")" << std::endl; } diff --git a/runtimes/neurun/src/codegen/Dumper.h b/runtimes/neurun/src/codegen/Dumper.h index 413feb7..2ef1ca2 100644 --- a/runtimes/neurun/src/codegen/Dumper.h +++ b/runtimes/neurun/src/codegen/Dumper.h @@ -1,27 +1,27 @@ #ifndef __NEURUN_CODEGEN_DUMPER_H__ #define __NEURUN_CODEGEN_DUMPER_H__ -#include "internal/op/NodeVisitor.h" +#include "graph/operation/NodeVisitor.h" namespace neurun { namespace codegen { -class Dumper : public ::internal::tflite::op::NodeVisitor +class Dumper : public graph::operation::NodeVisitor { public: Dumper() = default; public: - void visit(const ::internal::tflite::op::Conv2D::implicit::Node &node) override; - void visit(const ::internal::tflite::op::MaxPool2D::implicit::Node &node) override; - void visit(const ::internal::tflite::op::AvgPool2D::implicit::Node &node) override; - void visit(const ::internal::tflite::op::Concat::Node &node) override; - void visit(const ::internal::tflite::op::FullyConnected::Node &node) override; - void visit(const ::internal::tflite::op::Reshape::Node &node) override; - void visit(const ::internal::tflite::op::Softmax::Node &node) override; - void visit(const ::internal::tflite::op::NOP::Node &node) override; + void visit(const graph::operation::Conv2D::Implicit::Node &node) override; + void visit(const graph::operation::MaxPool2D::Implicit::Node &node) override; + void visit(const graph::operation::AvgPool2D::Implicit::Node &node) override; + void visit(const graph::operation::Concat::Node &node) override; + void visit(const graph::operation::FullyConnected::Node &node) override; + void visit(const graph::operation::Reshape::Node &node) override; + void visit(const graph::operation::Softmax::Node &node) override; + void visit(const graph::operation::NOP::Node &node) override; }; } // namespace codegen diff --git a/runtimes/neurun/src/compilation.cc b/runtimes/neurun/src/compilation.cc index 8a61f36..51fafc0 100644 --- a/runtimes/neurun/src/compilation.cc +++ b/runtimes/neurun/src/compilation.cc @@ -40,8 +40,7 @@ int ANeuralNetworksCompilation::finish() auto linear = plan.model().linearize(); // Dump ops - // TODO Update Dumper with neurun::graph::operation::Node version - // linear->accept(neurun::codegen::Dumper{}); + linear->accept(neurun::codegen::Dumper{}); ::internal::BackendManager backend_manager{plan}; neurun::codegen::BackendResolver backend_resolver{backend_manager}; -- 2.7.4