diff options
Diffstat (limited to 'compiler/locomotiv')
21 files changed, 247 insertions, 44 deletions
diff --git a/compiler/locomotiv/src/Node/BiasAdd.cpp b/compiler/locomotiv/src/Node/BiasAdd.cpp index dfe32ca92..b84fa7e3c 100644 --- a/compiler/locomotiv/src/Node/BiasAdd.cpp +++ b/compiler/locomotiv/src/Node/BiasAdd.cpp @@ -41,10 +41,12 @@ std::unique_ptr<NodeData> calc(const NodeData *input_data, const NodeData *bias_ } // namespace -namespace locomotiv +namespace { -void NodeExecution::execute(loco::BiasAdd<loco::Domain::Tensor> *bias_add) +using namespace locomotiv; + +void execute_node(loco::BiasAdd<loco::Domain::Tensor> *bias_add) { validate(bias_add, "BiasAdd is nullptr"); @@ -63,7 +65,7 @@ void NodeExecution::execute(loco::BiasAdd<loco::Domain::Tensor> *bias_add) annot_domain(bias_add, annot_domain(bias_add->value())); } -void NodeExecution::execute(loco::BiasAdd<loco::Domain::Feature> *bias_add) +void execute_node(loco::BiasAdd<loco::Domain::Feature> *bias_add) { validate(bias_add, "BiasAdd is nullptr"); @@ -82,7 +84,7 @@ void NodeExecution::execute(loco::BiasAdd<loco::Domain::Feature> *bias_add) annot_domain(bias_add, loco::Domain::Feature); } -} // namespace locomotiv +} // namespace namespace { @@ -123,3 +125,18 @@ std::unique_ptr<NodeData> calc(const NodeData *input_data, const NodeData *bias_ } } // namespace + +namespace locomotiv +{ + +void NodeExecution::execute(loco::BiasAdd<loco::Domain::Tensor> *bias_add) +{ + execute_node(bias_add); +} + +void NodeExecution::execute(loco::BiasAdd<loco::Domain::Feature> *bias_add) +{ + execute_node(bias_add); +} + +} // namespace locomotiv diff --git a/compiler/locomotiv/src/Node/BiasEncode.cpp b/compiler/locomotiv/src/Node/BiasEncode.cpp index c2f2b44c0..21f00a495 100644 --- a/compiler/locomotiv/src/Node/BiasEncode.cpp +++ b/compiler/locomotiv/src/Node/BiasEncode.cpp @@ -23,10 +23,12 @@ #include <stdexcept> #include <cassert> -namespace locomotiv +namespace { -void NodeExecution::execute(loco::BiasEncode *bias_enc) +using namespace locomotiv; + +void execute_node(loco::BiasEncode *bias_enc) { auto input_data = annot_data(bias_enc->input()); @@ -60,4 +62,11 @@ void NodeExecution::execute(loco::BiasEncode *bias_enc) annot_domain(bias_enc, loco::Domain::Bias); } +} // namespace + +namespace locomotiv +{ + +void NodeExecution::execute(loco::BiasEncode *bias_enc) { execute_node(bias_enc); } + } // namespace locomotiv diff --git a/compiler/locomotiv/src/Node/ConstGen.cpp b/compiler/locomotiv/src/Node/ConstGen.cpp index 0360b9fef..96ffbc257 100644 --- a/compiler/locomotiv/src/Node/ConstGen.cpp +++ b/compiler/locomotiv/src/Node/ConstGen.cpp @@ -53,10 +53,12 @@ inline uint32_t offset_by_index(const Shape &shape, const Index &index) } // namespace -namespace locomotiv +namespace { -void NodeExecution::execute(loco::ConstGen *constgen) +using namespace locomotiv; + +void execute_node(loco::ConstGen *constgen) { uint32_t volume = 1; @@ -113,4 +115,11 @@ void NodeExecution::execute(loco::ConstGen *constgen) annot_domain(constgen, loco::Domain::Tensor); } +} // namespace + +namespace locomotiv +{ + +void NodeExecution::execute(loco::ConstGen *constgen) { execute_node(constgen); } + } // namespace locomotiv diff --git a/compiler/locomotiv/src/Node/Conv2D.cpp b/compiler/locomotiv/src/Node/Conv2D.cpp index 2e4185574..cdf0dfd56 100644 --- a/compiler/locomotiv/src/Node/Conv2D.cpp +++ b/compiler/locomotiv/src/Node/Conv2D.cpp @@ -139,10 +139,12 @@ Buffer<RET_T> calc_conv2D(const loco::Conv2D *conv2d, const Buffer<IFM_T> *input } // namespace -namespace locomotiv +namespace { -void NodeExecution::execute(loco::Conv2D *conv2d) +using namespace locomotiv; + +void execute_node(loco::Conv2D *conv2d) { auto ifm_data = annot_data(conv2d->ifm()); auto ker_data = annot_data(conv2d->ker()); @@ -176,4 +178,11 @@ void NodeExecution::execute(loco::Conv2D *conv2d) annot_domain(conv2d, loco::Domain::Feature); } +} // namespace + +namespace locomotiv +{ + +void NodeExecution::execute(loco::Conv2D *conv2d) { execute_node(conv2d); } + } // namespace locomotiv diff --git a/compiler/locomotiv/src/Node/DepthwiseConv2D.cpp b/compiler/locomotiv/src/Node/DepthwiseConv2D.cpp index 92d5aa161..f39cd177e 100644 --- a/compiler/locomotiv/src/Node/DepthwiseConv2D.cpp +++ b/compiler/locomotiv/src/Node/DepthwiseConv2D.cpp @@ -143,10 +143,12 @@ Buffer<RET_T> calc_dw_conv2d(const loco::DepthwiseConv2D *dw_conv2d, const Buffe } // namespace -namespace locomotiv +namespace { -void NodeExecution::execute(loco::DepthwiseConv2D *dw_conv2d) +using namespace locomotiv; + +void execute_node(loco::DepthwiseConv2D *dw_conv2d) { auto ifm_data = annot_data(dw_conv2d->ifm()); auto ker_data = annot_data(dw_conv2d->ker()); @@ -182,4 +184,11 @@ void NodeExecution::execute(loco::DepthwiseConv2D *dw_conv2d) annot_domain(dw_conv2d, loco::Domain::Feature); } +} // namespace + +namespace locomotiv +{ + +void NodeExecution::execute(loco::DepthwiseConv2D *dw_conv2d) { execute_node(dw_conv2d); } + } // namespace locomotiv diff --git a/compiler/locomotiv/src/Node/DepthwiseFilterEncode.cpp b/compiler/locomotiv/src/Node/DepthwiseFilterEncode.cpp index 17004901f..03f5bf833 100644 --- a/compiler/locomotiv/src/Node/DepthwiseFilterEncode.cpp +++ b/compiler/locomotiv/src/Node/DepthwiseFilterEncode.cpp @@ -79,10 +79,12 @@ std::unique_ptr<locomotiv::NodeData> dw_filter_encode(const loco::DepthwiseFilte } // namespace -namespace locomotiv +namespace { -void NodeExecution::execute(loco::DepthwiseFilterEncode *enc) +using namespace locomotiv; + +void execute_node(loco::DepthwiseFilterEncode *enc) { auto input_data = annot_data(enc->input()); @@ -110,4 +112,11 @@ void NodeExecution::execute(loco::DepthwiseFilterEncode *enc) annot_domain(enc, loco::Domain::DepthwiseFilter); } +} // namespace + +namespace locomotiv +{ + +void NodeExecution::execute(loco::DepthwiseFilterEncode *enc) { execute_node(enc); } + } // namespace locomotiv diff --git a/compiler/locomotiv/src/Node/FeatureDecode.cpp b/compiler/locomotiv/src/Node/FeatureDecode.cpp index 8a56a56b2..8776e1b42 100644 --- a/compiler/locomotiv/src/Node/FeatureDecode.cpp +++ b/compiler/locomotiv/src/Node/FeatureDecode.cpp @@ -72,10 +72,12 @@ std::unique_ptr<locomotiv::NodeData> feature_decode(const loco::FeatureDecode *n } // namespace -namespace locomotiv +namespace { -void NodeExecution::execute(loco::FeatureDecode *dec) +using namespace locomotiv; + +void execute_node(loco::FeatureDecode *dec) { auto input_data = annot_data(dec->input()); @@ -109,4 +111,11 @@ void NodeExecution::execute(loco::FeatureDecode *dec) annot_domain(dec, loco::Domain::Tensor); } +} // namespace + +namespace locomotiv +{ + +void NodeExecution::execute(loco::FeatureDecode *dec) { execute_node(dec); } + } // namespace locomotiv diff --git a/compiler/locomotiv/src/Node/FilterEncode.cpp b/compiler/locomotiv/src/Node/FilterEncode.cpp index cd9d708dc..0e2ac918f 100644 --- a/compiler/locomotiv/src/Node/FilterEncode.cpp +++ b/compiler/locomotiv/src/Node/FilterEncode.cpp @@ -74,10 +74,12 @@ std::unique_ptr<locomotiv::NodeData> filter_encode(const loco::FilterEncode *nod } // namespace -namespace locomotiv +namespace { -void NodeExecution::execute(loco::FilterEncode *enc) +using namespace locomotiv; + +void execute_node(loco::FilterEncode *enc) { auto input_data = annot_data(enc->input()); @@ -111,4 +113,11 @@ void NodeExecution::execute(loco::FilterEncode *enc) annot_domain(enc, loco::Domain::Filter); } +} // namespace + +namespace locomotiv +{ + +void NodeExecution::execute(loco::FilterEncode *enc) { execute_node(enc); } + } // namespace locomotiv diff --git a/compiler/locomotiv/src/Node/Forward.cpp b/compiler/locomotiv/src/Node/Forward.cpp index eb7d44a59..9095ecf00 100644 --- a/compiler/locomotiv/src/Node/Forward.cpp +++ b/compiler/locomotiv/src/Node/Forward.cpp @@ -23,10 +23,12 @@ #include <stdexcept> #include <cassert> -namespace locomotiv +namespace { -void NodeExecution::execute(loco::Forward *forward) +using namespace locomotiv; + +void execute_node(loco::Forward *forward) { auto input_data = annot_data(forward->input()); @@ -59,4 +61,11 @@ void NodeExecution::execute(loco::Forward *forward) annot_domain(forward, annot_domain(forward->input())); } +} // namespace + +namespace locomotiv +{ + +void NodeExecution::execute(loco::Forward *forward) { execute_node(forward); } + } // namespace locomotiv diff --git a/compiler/locomotiv/src/Node/MatMul.cpp b/compiler/locomotiv/src/Node/MatMul.cpp index 77b7315a9..e5d149ac5 100644 --- a/compiler/locomotiv/src/Node/MatMul.cpp +++ b/compiler/locomotiv/src/Node/MatMul.cpp @@ -82,10 +82,12 @@ template <typename T> Buffer<T> calc_mat_mul(const Buffer<T> *lhs_buf, const Buf } // namespace -namespace locomotiv +namespace { -void NodeExecution::execute(loco::MatMul *mat_mul) +using namespace locomotiv; + +void execute_node(loco::MatMul *mat_mul) { auto lhs_data = annot_data(mat_mul->lhs()); auto rhs_data = annot_data(mat_mul->rhs()); @@ -130,4 +132,11 @@ void NodeExecution::execute(loco::MatMul *mat_mul) annot_domain(mat_mul, loco::Domain::Matrix); } +} // namespace + +namespace locomotiv +{ + +void NodeExecution::execute(loco::MatMul *mat_mul) { execute_node(mat_mul); } + } // namespace locomotiv diff --git a/compiler/locomotiv/src/Node/MatrixDecode.cpp b/compiler/locomotiv/src/Node/MatrixDecode.cpp index c591676ae..0310015f1 100644 --- a/compiler/locomotiv/src/Node/MatrixDecode.cpp +++ b/compiler/locomotiv/src/Node/MatrixDecode.cpp @@ -68,10 +68,12 @@ std::unique_ptr<locomotiv::NodeData> matrix_decode(const loco::MatrixDecode *nod } // namespace -namespace locomotiv +namespace { -void NodeExecution::execute(loco::MatrixDecode *matrix_dec) +using namespace locomotiv; + +void execute_node(loco::MatrixDecode *matrix_dec) { auto input_data = annot_data(matrix_dec->input()); @@ -106,4 +108,11 @@ void NodeExecution::execute(loco::MatrixDecode *matrix_dec) annot_domain(matrix_dec, loco::Domain::Tensor); } +} // namespace + +namespace locomotiv +{ + +void NodeExecution::execute(loco::MatrixDecode *matrix_dec) { execute_node(matrix_dec); } + } // namespace locomotiv diff --git a/compiler/locomotiv/src/Node/MaxPool2D.cpp b/compiler/locomotiv/src/Node/MaxPool2D.cpp index 5d92f89f5..8dce1cb1e 100644 --- a/compiler/locomotiv/src/Node/MaxPool2D.cpp +++ b/compiler/locomotiv/src/Node/MaxPool2D.cpp @@ -129,10 +129,12 @@ nncc::core::ADT::tensor::Buffer<T> maxPool2D(const loco::MaxPool2D *maxpool2d, } // namespace -namespace locomotiv +namespace { -void NodeExecution::execute(loco::MaxPool2D *maxpool2d) +using namespace locomotiv; + +void execute_node(loco::MaxPool2D *maxpool2d) { auto ifm_data = annot_data(maxpool2d->ifm()); @@ -164,4 +166,11 @@ void NodeExecution::execute(loco::MaxPool2D *maxpool2d) annot_domain(maxpool2d, loco::Domain::Feature); } +} // namespace + +namespace locomotiv +{ + +void NodeExecution::execute(loco::MaxPool2D *maxpool2d) { execute_node(maxpool2d); } + } // namespace locomotiv diff --git a/compiler/locomotiv/src/Node/Pull.cpp b/compiler/locomotiv/src/Node/Pull.cpp index c482d8b04..fe5d7c2e1 100644 --- a/compiler/locomotiv/src/Node/Pull.cpp +++ b/compiler/locomotiv/src/Node/Pull.cpp @@ -24,10 +24,12 @@ #include <cassert> #include <stdexcept> -namespace locomotiv +namespace { -void NodeExecution::execute(loco::Pull *pull) +using namespace locomotiv; + +void execute_node(loco::Pull *pull) { // TODO Remove deprecated code #if 0 @@ -69,4 +71,11 @@ void NodeExecution::execute(loco::Pull *pull) annot_domain(pull, loco::Domain::Tensor); } +} // namespace + +namespace locomotiv +{ + +void NodeExecution::execute(loco::Pull *pull) { execute_node(pull); } + } // namespace locomotiv diff --git a/compiler/locomotiv/src/Node/Push.cpp b/compiler/locomotiv/src/Node/Push.cpp index fc5808b15..4e1c6c3b8 100644 --- a/compiler/locomotiv/src/Node/Push.cpp +++ b/compiler/locomotiv/src/Node/Push.cpp @@ -23,10 +23,12 @@ #include <stdexcept> #include <cassert> -namespace locomotiv +namespace { -void NodeExecution::execute(loco::Push *push) +using namespace locomotiv; + +void execute_node(loco::Push *push) { auto from_data = annot_data(push->from()); @@ -58,4 +60,11 @@ void NodeExecution::execute(loco::Push *push) annot_domain(push, loco::Domain::Tensor); } +} // namespace + +namespace locomotiv +{ + +void NodeExecution::execute(loco::Push *push) { execute_node(push); } + } // namespace locomotiv diff --git a/compiler/locomotiv/src/Node/Reshape.cpp b/compiler/locomotiv/src/Node/Reshape.cpp index ac1672024..a9c07bee1 100644 --- a/compiler/locomotiv/src/Node/Reshape.cpp +++ b/compiler/locomotiv/src/Node/Reshape.cpp @@ -36,10 +36,12 @@ using nncc::core::ADT::tensor::num_elements; #include <cstring> #include <vector> -namespace locomotiv +namespace { -void NodeExecution::execute(loco::Reshape<loco::ReshapeType::Fixed> *reshape) +using namespace locomotiv; + +void execute_node(loco::Reshape<loco::ReshapeType::Fixed> *reshape) { auto input_data = annot_data(reshape->input()); @@ -87,4 +89,14 @@ void NodeExecution::execute(loco::Reshape<loco::ReshapeType::Fixed> *reshape) annot_domain(reshape, annot_domain(reshape->input())); } +} // namespace + +namespace locomotiv +{ + +void NodeExecution::execute(loco::Reshape<loco::ReshapeType::Fixed> *reshape) +{ + execute_node(reshape); +} + } // namespace locomotiv diff --git a/compiler/locomotiv/src/Node/Softmax.cpp b/compiler/locomotiv/src/Node/Softmax.cpp index 352598b27..0018eb66f 100644 --- a/compiler/locomotiv/src/Node/Softmax.cpp +++ b/compiler/locomotiv/src/Node/Softmax.cpp @@ -65,10 +65,12 @@ Shape reduce_shape(const Shape &shape, uint32_t axis) } // namespace -namespace locomotiv +namespace { -void NodeExecution::execute(loco::TensorSoftmax *softmax) +using namespace locomotiv; + +void execute_node(loco::TensorSoftmax *softmax) { auto input_data = annot_data(softmax->input()); @@ -119,4 +121,11 @@ void NodeExecution::execute(loco::TensorSoftmax *softmax) annot_domain(softmax, annot_domain(softmax->input())); } +} // namespace + +namespace locomotiv +{ + +void NodeExecution::execute(loco::TensorSoftmax *softmax) { execute_node(softmax); } + } // namespace locomotiv diff --git a/compiler/locomotiv/src/Node/TensorBroadcast.cpp b/compiler/locomotiv/src/Node/TensorBroadcast.cpp index 010ca6821..38e5a7aa9 100644 --- a/compiler/locomotiv/src/Node/TensorBroadcast.cpp +++ b/compiler/locomotiv/src/Node/TensorBroadcast.cpp @@ -34,10 +34,12 @@ using nncc::core::ADT::tensor::Shape; #include <cassert> #include <stdexcept> -namespace locomotiv +namespace { -void NodeExecution::execute(loco::TensorBroadcast *tensor_broadcast) +using namespace locomotiv; + +void execute_node(loco::TensorBroadcast *tensor_broadcast) { auto input_data = annot_data(tensor_broadcast->input()); @@ -103,4 +105,14 @@ void NodeExecution::execute(loco::TensorBroadcast *tensor_broadcast) annot_domain(tensor_broadcast, loco::Domain::Tensor); } +} // namespace + +namespace locomotiv +{ + +void NodeExecution::execute(loco::TensorBroadcast *tensor_broadcast) +{ + execute_node(tensor_broadcast); +} + } // namespace locomotiv diff --git a/compiler/locomotiv/src/Node/TensorConcat.cpp b/compiler/locomotiv/src/Node/TensorConcat.cpp index 3187a7f75..188bb635b 100644 --- a/compiler/locomotiv/src/Node/TensorConcat.cpp +++ b/compiler/locomotiv/src/Node/TensorConcat.cpp @@ -35,10 +35,12 @@ using nncc::core::ADT::tensor::Shape; #include <cassert> #include <stdexcept> -namespace locomotiv +namespace { -void NodeExecution::execute(loco::TensorConcat *tensor_concat) +using namespace locomotiv; + +void execute_node(loco::TensorConcat *tensor_concat) { validate(tensor_concat, "TensorConcat is nullptr"); @@ -112,4 +114,11 @@ void NodeExecution::execute(loco::TensorConcat *tensor_concat) annot_domain(tensor_concat, loco::Domain::Tensor); } +} // namespace + +namespace locomotiv +{ + +void NodeExecution::execute(loco::TensorConcat *tensor_concat) { execute_node(tensor_concat); } + } // namespace locomotiv diff --git a/compiler/locomotiv/src/Node/TensorConstantPad.cpp b/compiler/locomotiv/src/Node/TensorConstantPad.cpp index cd81a3a4d..5d4ad5d24 100644 --- a/compiler/locomotiv/src/Node/TensorConstantPad.cpp +++ b/compiler/locomotiv/src/Node/TensorConstantPad.cpp @@ -31,10 +31,12 @@ using nncc::core::ADT::tensor::IndexEnumerator; using nncc::core::ADT::tensor::LexicalLayout; using nncc::core::ADT::tensor::make_buffer; -namespace locomotiv +namespace { -void NodeExecution::execute(loco::TensorConstantPad *pad) +using namespace locomotiv; + +void execute_node(loco::TensorConstantPad *pad) { validate(pad, "TensorConstantPad is nullptr"); @@ -112,4 +114,11 @@ void NodeExecution::execute(loco::TensorConstantPad *pad) annot_domain(pad, annot_domain(pad->input())); } +} // namespace + +namespace locomotiv +{ + +void NodeExecution::execute(loco::TensorConstantPad *pad) { execute_node(pad); } + } // namespace locomotiv diff --git a/compiler/locomotiv/src/Node/TensorReduce.cpp b/compiler/locomotiv/src/Node/TensorReduce.cpp index a60ebd890..1f619a31a 100644 --- a/compiler/locomotiv/src/Node/TensorReduce.cpp +++ b/compiler/locomotiv/src/Node/TensorReduce.cpp @@ -115,10 +115,12 @@ void apply(Buffer<T> &lhs, const Buffer<T> &rhs, const loco::TensorReduce &node) } // namespace -namespace locomotiv +namespace { -void NodeExecution::execute(loco::TensorReduce *node) +using namespace locomotiv; + +void execute_node(loco::TensorReduce *node) { auto input_data = annot_data(node->input()); validate(input_data, "Input not ready"); @@ -149,4 +151,11 @@ void NodeExecution::execute(loco::TensorReduce *node) annot_domain(node, annot_domain(node->input())); } +} // namespace + +namespace locomotiv +{ + +void NodeExecution::execute(loco::TensorReduce *node) { execute_node(node); } + } // namespace locomotiv diff --git a/compiler/locomotiv/src/Node/TransposedConv2D.cpp b/compiler/locomotiv/src/Node/TransposedConv2D.cpp index 3ea4f071d..bec15a5df 100644 --- a/compiler/locomotiv/src/Node/TransposedConv2D.cpp +++ b/compiler/locomotiv/src/Node/TransposedConv2D.cpp @@ -147,10 +147,12 @@ Buffer<RET_T> calc_tr_conv2D(const loco::TransposedConv2D *tr_conv2d, } // namespace -namespace locomotiv +namespace { -void NodeExecution::execute(loco::TransposedConv2D *tr_conv2d) +using namespace locomotiv; + +void execute_node(loco::TransposedConv2D *tr_conv2d) { auto ifm_data = annot_data(tr_conv2d->ifm()); auto ker_data = annot_data(tr_conv2d->ker()); @@ -186,4 +188,11 @@ void NodeExecution::execute(loco::TransposedConv2D *tr_conv2d) annot_domain(tr_conv2d, loco::Domain::Feature); } +} // namespace + +namespace locomotiv +{ + +void NodeExecution::execute(loco::TransposedConv2D *tr_conv2d) { execute_node(tr_conv2d); } + } // namespace locomotiv |