From 8f37c8035fb27900f8924ec3f487e3d99f0e649f Mon Sep 17 00:00:00 2001 From: Hyeongseok Oh Date: Fri, 26 Jul 2024 16:13:20 +0900 Subject: [PATCH] [oenrt] Remove supportLayout function in backend config (#13524) This commit removes supportLayout function from IConfig interface. ONE-DCO-1.0-Signed-off-by: Hyeongseok Oh --- runtime/onert/backend/acl_cl/Config.cc | 2 -- runtime/onert/backend/acl_cl/Config.h | 1 - runtime/onert/backend/acl_neon/Config.cc | 2 -- runtime/onert/backend/acl_neon/Config.h | 1 - runtime/onert/backend/cpu/Config.cc | 2 -- runtime/onert/backend/cpu/Config.h | 1 - runtime/onert/backend/ruy/Config.cc | 2 -- runtime/onert/backend/ruy/Config.h | 1 - runtime/onert/backend/train/Config.cc | 2 -- runtime/onert/backend/train/Config.h | 1 - runtime/onert/backend/trix/Config.cc | 2 -- runtime/onert/backend/trix/Config.h | 1 - runtime/onert/backend/xnnpack/Config.cc | 2 -- runtime/onert/backend/xnnpack/Config.h | 1 - runtime/onert/core/include/backend/IConfig.h | 8 -------- runtime/onert/core/src/backend/builtin/Config.cc | 5 ----- runtime/onert/core/src/backend/builtin/Config.h | 1 - runtime/onert/core/src/compiler/HEScheduler.test.cc | 9 --------- runtime/onert/core/src/compiler/LoweredGraph.cc | 7 ++----- .../core/src/compiler/train/LoweredTrainableGraph.cc | 7 ++----- runtime/onert/core/src/exec/ExecTime.test.cc | 4 ---- 21 files changed, 4 insertions(+), 58 deletions(-) diff --git a/runtime/onert/backend/acl_cl/Config.cc b/runtime/onert/backend/acl_cl/Config.cc index a4b9bbe3ce7..52196f35db6 100644 --- a/runtime/onert/backend/acl_cl/Config.cc +++ b/runtime/onert/backend/acl_cl/Config.cc @@ -47,8 +47,6 @@ bool Config::initialize() return true; } -ir::Layout Config::supportLayout(const ir::IOperation &, ir::Layout) { return ir::Layout::NHWC; } - } // namespace acl_cl } // namespace backend } // namespace onert diff --git a/runtime/onert/backend/acl_cl/Config.h b/runtime/onert/backend/acl_cl/Config.h index 1fa1aeb00ff..9e77fce63b7 100644 --- a/runtime/onert/backend/acl_cl/Config.h +++ b/runtime/onert/backend/acl_cl/Config.h @@ -35,7 +35,6 @@ class Config : public IConfig std::string id() override { return "acl_cl"; } bool initialize() override; bool supportPermutation() override { return true; } - ir::Layout supportLayout(const ir::IOperation &node, ir::Layout frontend_layout) override; bool supportDynamicTensor() override { return false; } bool supportFP16() override { return true; } void sync() const override { arm_compute::CLScheduler::get().sync(); } diff --git a/runtime/onert/backend/acl_neon/Config.cc b/runtime/onert/backend/acl_neon/Config.cc index 598827f9a07..380ebc10a8b 100644 --- a/runtime/onert/backend/acl_neon/Config.cc +++ b/runtime/onert/backend/acl_neon/Config.cc @@ -27,8 +27,6 @@ namespace acl_neon bool Config::initialize() { return true; } -ir::Layout Config::supportLayout(const ir::IOperation &, ir::Layout) { return ir::Layout::NHWC; } - } // namespace acl_neon } // namespace backend } // namespace onert diff --git a/runtime/onert/backend/acl_neon/Config.h b/runtime/onert/backend/acl_neon/Config.h index ffd9b21e32d..86748bb2f3d 100644 --- a/runtime/onert/backend/acl_neon/Config.h +++ b/runtime/onert/backend/acl_neon/Config.h @@ -33,7 +33,6 @@ class Config : public IConfig public: std::string id() override { return "acl_neon"; } bool initialize() override; - ir::Layout supportLayout(const ir::IOperation &node, ir::Layout frontend_layout) override; bool supportPermutation() override { return true; } bool supportDynamicTensor() override { return false; } bool supportFP16() override { return false; } diff --git a/runtime/onert/backend/cpu/Config.cc b/runtime/onert/backend/cpu/Config.cc index f80c2caf1e2..cea8095b15c 100644 --- a/runtime/onert/backend/cpu/Config.cc +++ b/runtime/onert/backend/cpu/Config.cc @@ -25,8 +25,6 @@ namespace cpu bool Config::initialize() { return true; } -ir::Layout Config::supportLayout(const ir::IOperation &, ir::Layout) { return ir::Layout::NHWC; } - } // namespace cpu } // namespace backend } // namespace onert diff --git a/runtime/onert/backend/cpu/Config.h b/runtime/onert/backend/cpu/Config.h index 841a839d148..7245e1ca35e 100644 --- a/runtime/onert/backend/cpu/Config.h +++ b/runtime/onert/backend/cpu/Config.h @@ -33,7 +33,6 @@ class Config : public IConfig public: std::string id() override { return "cpu"; } bool initialize() override; - ir::Layout supportLayout(const ir::IOperation &node, ir::Layout frontend_layout) override; bool supportPermutation() override { return true; } bool supportDynamicTensor() override { return true; } bool supportFP16() override { return false; } diff --git a/runtime/onert/backend/ruy/Config.cc b/runtime/onert/backend/ruy/Config.cc index fbeb2f7f048..bf07aa71924 100644 --- a/runtime/onert/backend/ruy/Config.cc +++ b/runtime/onert/backend/ruy/Config.cc @@ -25,8 +25,6 @@ namespace ruy bool Config::initialize() { return true; } -ir::Layout Config::supportLayout(const ir::IOperation &, ir::Layout) { return ir::Layout::NHWC; } - } // namespace ruy } // namespace backend } // namespace onert diff --git a/runtime/onert/backend/ruy/Config.h b/runtime/onert/backend/ruy/Config.h index fa6415b14e9..a5b4c41a8c5 100644 --- a/runtime/onert/backend/ruy/Config.h +++ b/runtime/onert/backend/ruy/Config.h @@ -33,7 +33,6 @@ class Config : public IConfig public: std::string id() override { return "ruy"; } bool initialize() override; - ir::Layout supportLayout(const ir::IOperation &node, ir::Layout frontend_layout) override; bool supportPermutation() override { return true; } bool supportDynamicTensor() override { return true; } bool supportFP16() override { return false; } diff --git a/runtime/onert/backend/train/Config.cc b/runtime/onert/backend/train/Config.cc index 57a68adc4bb..2b65a29de40 100644 --- a/runtime/onert/backend/train/Config.cc +++ b/runtime/onert/backend/train/Config.cc @@ -25,8 +25,6 @@ namespace train bool Config::initialize() { return true; } -ir::Layout Config::supportLayout(const ir::IOperation &, ir::Layout) { return ir::Layout::NHWC; } - } // namespace train } // namespace backend } // namespace onert diff --git a/runtime/onert/backend/train/Config.h b/runtime/onert/backend/train/Config.h index c8cf52b4d1d..a8751b369c3 100644 --- a/runtime/onert/backend/train/Config.h +++ b/runtime/onert/backend/train/Config.h @@ -32,7 +32,6 @@ class Config : public IConfig public: std::string id() override { return "train"; } bool initialize() override; - ir::Layout supportLayout(const ir::IOperation &node, ir::Layout frontend_layout) override; bool supportPermutation() override { return true; } bool supportDynamicTensor() override { return false; } bool supportFP16() override { return false; } diff --git a/runtime/onert/backend/trix/Config.cc b/runtime/onert/backend/trix/Config.cc index b536fd58cb5..e3a7a3034d0 100644 --- a/runtime/onert/backend/trix/Config.cc +++ b/runtime/onert/backend/trix/Config.cc @@ -25,8 +25,6 @@ namespace trix bool Config::initialize() { return true; } -ir::Layout Config::supportLayout(const ir::IOperation &, ir::Layout) { return ir::Layout::NHWC; } - } // namespace trix } // namespace backend } // namespace onert diff --git a/runtime/onert/backend/trix/Config.h b/runtime/onert/backend/trix/Config.h index 310c57b2936..d29b319f1bc 100644 --- a/runtime/onert/backend/trix/Config.h +++ b/runtime/onert/backend/trix/Config.h @@ -33,7 +33,6 @@ class Config : public IConfig public: std::string id() override { return "trix"; } bool initialize() override; - ir::Layout supportLayout(const ir::IOperation &node, ir::Layout frontend_layout) override; bool supportPermutation() override { return true; } bool supportDynamicTensor() override { return false; } bool supportFP16() override { return false; } diff --git a/runtime/onert/backend/xnnpack/Config.cc b/runtime/onert/backend/xnnpack/Config.cc index cc27f717f7c..85f96486958 100644 --- a/runtime/onert/backend/xnnpack/Config.cc +++ b/runtime/onert/backend/xnnpack/Config.cc @@ -37,8 +37,6 @@ bool Config::initialize() return true; } -ir::Layout Config::supportLayout(const ir::IOperation &, ir::Layout) { return ir::Layout::NHWC; } - } // namespace xnnpack } // namespace backend } // namespace onert diff --git a/runtime/onert/backend/xnnpack/Config.h b/runtime/onert/backend/xnnpack/Config.h index 4c5fba587ac..ea59479bad9 100644 --- a/runtime/onert/backend/xnnpack/Config.h +++ b/runtime/onert/backend/xnnpack/Config.h @@ -36,7 +36,6 @@ class Config : public IConfig public: std::string id() override { return "xnnpack"; } bool initialize() override; - ir::Layout supportLayout(const ir::IOperation &node, ir::Layout frontend_layout) override; bool supportPermutation() override { return true; } bool supportDynamicTensor() override { return true; } bool supportFP16() override { return false; } diff --git a/runtime/onert/core/include/backend/IConfig.h b/runtime/onert/core/include/backend/IConfig.h index e297c5f1edd..d530bb2f6fc 100644 --- a/runtime/onert/core/include/backend/IConfig.h +++ b/runtime/onert/core/include/backend/IConfig.h @@ -45,14 +45,6 @@ struct IConfig * @return false Initialization failed, so it cannot use this backend */ virtual bool initialize() = 0; - /** - * @brief Returns supported layout for the given \p node and \p frontend_layout - * - * @param node IOperation - * @param frontend_layout The layout defined in the model - * @return ir::Layout The layout that the backend kernel actually uses - */ - virtual ir::Layout supportLayout(const ir::IOperation &node, ir::Layout frontend_layout) = 0; /** * @brief The function that is called after each Operation run on profiling mode. * This may be useful for profiling GPU-based or special computing units. diff --git a/runtime/onert/core/src/backend/builtin/Config.cc b/runtime/onert/core/src/backend/builtin/Config.cc index e5f6d4c210f..be47d8a0753 100644 --- a/runtime/onert/core/src/backend/builtin/Config.cc +++ b/runtime/onert/core/src/backend/builtin/Config.cc @@ -27,11 +27,6 @@ std::string Config::ID = "builtin"; bool Config::initialize() { return true; } -ir::Layout Config::supportLayout(const ir::IOperation &, ir::Layout frontend_layout) -{ - return frontend_layout; -} - } // namespace builtin } // namespace backend } // namespace onert diff --git a/runtime/onert/core/src/backend/builtin/Config.h b/runtime/onert/core/src/backend/builtin/Config.h index 196b299d3cf..b3b29f6fa07 100644 --- a/runtime/onert/core/src/backend/builtin/Config.h +++ b/runtime/onert/core/src/backend/builtin/Config.h @@ -34,7 +34,6 @@ class Config : public IConfig static std::string ID; std::string id() override { return ID; } bool initialize() override; - ir::Layout supportLayout(const ir::IOperation &node, ir::Layout frontend_layout) override; bool supportPermutation() override { return false; } bool supportDynamicTensor() override { diff --git a/runtime/onert/core/src/compiler/HEScheduler.test.cc b/runtime/onert/core/src/compiler/HEScheduler.test.cc index 505fbbb4867..75a21fa724b 100644 --- a/runtime/onert/core/src/compiler/HEScheduler.test.cc +++ b/runtime/onert/core/src/compiler/HEScheduler.test.cc @@ -43,7 +43,6 @@ struct MockConfigCPU : public IConfig std::string id() override { return "cpu"; } bool initialize() override { return true; }; bool supportPermutation() override { return false; } - Layout supportLayout(const IOperation &, Layout) override { return Layout::UNKNOWN; } bool supportDynamicTensor() override { return false; } bool supportFP16() override { return false; } }; @@ -70,10 +69,6 @@ struct MockConfigGPU : public IConfig std::string id() override { return "gpu"; } bool initialize() override { return true; }; bool supportPermutation() override { return false; } - ir::Layout supportLayout(const ir::IOperation &, ir::Layout) override - { - return ir::Layout::UNKNOWN; - } bool supportDynamicTensor() override { return false; } bool supportFP16() override { return false; } }; @@ -92,10 +87,6 @@ struct MockConfigNPU : public IConfig std::string id() override { return "npu"; } bool initialize() override { return true; }; bool supportPermutation() override { return false; } - ir::Layout supportLayout(const ir::IOperation &, ir::Layout) override - { - return ir::Layout::UNKNOWN; - } bool supportDynamicTensor() override { return false; } bool supportFP16() override { return false; } }; diff --git a/runtime/onert/core/src/compiler/LoweredGraph.cc b/runtime/onert/core/src/compiler/LoweredGraph.cc index 46a45e44ade..8789d6e9a57 100644 --- a/runtime/onert/core/src/compiler/LoweredGraph.cc +++ b/runtime/onert/core/src/compiler/LoweredGraph.cc @@ -129,11 +129,8 @@ void LoweredGraph::makeLowerInfo(const compiler::BackendResolver &backend_resolv throw std::runtime_error{"Fail to find backend for " + op.name() + " operation"}; } - auto frontend_layout = _graph.layout(); - - // The layout of each backend should be set at another place - // TODO Change setting layout of each backend at another place - auto backend_layout = backend->config()->supportLayout(op, frontend_layout); + // Backend layout is always NHWC + auto backend_layout = ir::Layout::NHWC; for (auto &&ind : op.getInputs() | ir::Remove::UNDEFINED) { diff --git a/runtime/onert/core/src/compiler/train/LoweredTrainableGraph.cc b/runtime/onert/core/src/compiler/train/LoweredTrainableGraph.cc index 8b368c44084..80728ce8c8d 100644 --- a/runtime/onert/core/src/compiler/train/LoweredTrainableGraph.cc +++ b/runtime/onert/core/src/compiler/train/LoweredTrainableGraph.cc @@ -157,11 +157,8 @@ void LoweredTrainableGraph::makeLowerInfo(const compiler::BackendResolver &backe throw std::runtime_error{"Fail to find backend for " + op.name() + " operation"}; } - auto frontend_layout = _trainable_graph.layout(); - - // The layout of each backend should be set at another place - // TODO Change setting layout of each backend at another place - auto backend_layout = backend->config()->supportLayout(op, frontend_layout); + // Backend layout is always NHWC + auto backend_layout = ir::Layout::NHWC; for (auto &&ind : op.getInputs() | ir::Remove::UNDEFINED) { diff --git a/runtime/onert/core/src/exec/ExecTime.test.cc b/runtime/onert/core/src/exec/ExecTime.test.cc index 939184e4e41..6941d3aa3da 100644 --- a/runtime/onert/core/src/exec/ExecTime.test.cc +++ b/runtime/onert/core/src/exec/ExecTime.test.cc @@ -34,10 +34,6 @@ struct MockConfig : public IConfig std::string id() override { return "b1"; } bool initialize() override { return true; }; bool supportPermutation() override { return false; } - ir::Layout supportLayout(const ir::IOperation &, ir::Layout) override - { - return ir::Layout::UNKNOWN; - } bool supportDynamicTensor() override { return false; } bool supportFP16() override { return false; } };