From 5bf1488ea79e88cfccc9381a473896579290f1cd Mon Sep 17 00:00:00 2001 From: Sergei Barannikov/AI Tools Lab /SRR/Engineer/Samsung Electronics Date: Tue, 3 Dec 2019 04:10:06 +0300 Subject: [PATCH] [neurun] Replace IObject with ITensor in CPU backend (#9337) Replace uses of `IObject` with `ITensor` in CPU backend Signed-off-by: Sergei Barannikov --- runtime/neurun/backend/cpu/KernelGenerator.cc | 14 +++++++------- runtime/neurun/backend/cpu/kernel/PermuteLayer.cc | 4 ++-- runtime/neurun/backend/cpu/kernel/PermuteLayer.h | 8 ++++---- 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/runtime/neurun/backend/cpu/KernelGenerator.cc b/runtime/neurun/backend/cpu/KernelGenerator.cc index e2ba9cf..580f550 100644 --- a/runtime/neurun/backend/cpu/KernelGenerator.cc +++ b/runtime/neurun/backend/cpu/KernelGenerator.cc @@ -492,14 +492,14 @@ void KernelGenerator::visit(const model::operation::Permute &node) output_backend_ctx->tensor_builder->preVisit(node); - auto output_object = output_backend_ctx->tensor_builder->wrapTensor(output_index); - auto input_object = input_backend_ctx->tensor_builder->wrapTensor(input_index); + auto output_object = output_backend_ctx->tensor_builder->tensorAt(output_index); + auto input_object = input_backend_ctx->tensor_builder->tensorAt(input_index); auto fn = nnfw::cpp14::make_unique<::neurun::backend::cpu::kernel::PermuteLayer>(); // TODO Support NCHW frontend auto out_shape = shape; - if (shape.rank() == 4 && output_object->ptr()->layout() == model::Layout::NCHW) + if (shape.rank() == 4 && output_object->layout() == model::Layout::NCHW) { out_shape.dim(1) = shape.dim(3); out_shape.dim(2) = shape.dim(1); @@ -509,13 +509,13 @@ void KernelGenerator::visit(const model::operation::Permute &node) const auto permute_type = node.getPermuteType(); // Check Permutation Type const auto inferPermuteType = [&]() { - if (input_object->ptr()->layout() == model::Layout::NHWC && - output_object->ptr()->layout() == model::Layout::NCHW) + if (input_object->layout() == model::Layout::NHWC && + output_object->layout() == model::Layout::NCHW) { return model::operation::Permute::Type::NHWC_TO_NCHW; } - else if (input_object->ptr()->layout() == model::Layout::NCHW && - output_object->ptr()->layout() == model::Layout::NHWC) + else if (input_object->layout() == model::Layout::NCHW && + output_object->layout() == model::Layout::NHWC) { return model::operation::Permute::Type::NCHW_TO_NHWC; } diff --git a/runtime/neurun/backend/cpu/kernel/PermuteLayer.cc b/runtime/neurun/backend/cpu/kernel/PermuteLayer.cc index 86d3ba6..1520f99 100644 --- a/runtime/neurun/backend/cpu/kernel/PermuteLayer.cc +++ b/runtime/neurun/backend/cpu/kernel/PermuteLayer.cc @@ -27,8 +27,8 @@ namespace kernel using Type = model::operation::Permute::Type; -void PermuteLayer::configure(std::shared_ptr<::neurun::backend::operand::IObject> input, - std::shared_ptr<::neurun::backend::operand::IObject> output, +void PermuteLayer::configure(std::shared_ptr input, + std::shared_ptr output, const model::Shape &output_shape, Type type, model::DataType dataType) { _input = input; diff --git a/runtime/neurun/backend/cpu/kernel/PermuteLayer.h b/runtime/neurun/backend/cpu/kernel/PermuteLayer.h index cd2f1eb..40a355c 100644 --- a/runtime/neurun/backend/cpu/kernel/PermuteLayer.h +++ b/runtime/neurun/backend/cpu/kernel/PermuteLayer.h @@ -43,8 +43,8 @@ public: PermuteLayer() = default; public: - void configure(std::shared_ptr<::neurun::backend::operand::IObject> input, - std::shared_ptr<::neurun::backend::operand::IObject> output, + void configure(std::shared_ptr input, + std::shared_ptr output, const model::Shape &output_shape, model::operation::Permute::Type type, model::DataType dataType); void run(); @@ -196,8 +196,8 @@ private: } private: - std::shared_ptr<::neurun::backend::operand::IObject> _input{nullptr}; - std::shared_ptr<::neurun::backend::operand::IObject> _output{nullptr}; + std::shared_ptr _input{nullptr}; + std::shared_ptr _output{nullptr}; model::Shape _output_shape{}; model::operation::Permute::Type _type{model::operation::Permute::Type::COPY}; model::DataType _dataType{model::DataType::FLOAT32}; -- 2.7.4