From b3e7439ba2c6255de3f38a0576f220e2f0ac7192 Mon Sep 17 00:00:00 2001 From: Vladimir Paramuzov Date: Wed, 18 Aug 2021 09:31:04 +0300 Subject: [PATCH] [GPU] Get rid of memory alloc for input_layout in internal networks (#6897) --- .../thirdparty/clDNN/src/input_layout.cpp | 15 ++++++++++++++- .../clDNN/tests/test_cases/memory_test.cpp | 2 +- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/inference-engine/thirdparty/clDNN/src/input_layout.cpp b/inference-engine/thirdparty/clDNN/src/input_layout.cpp index ddc4c5470ac2e8..d7bfa069192fcd 100644 --- a/inference-engine/thirdparty/clDNN/src/input_layout.cpp +++ b/inference-engine/thirdparty/clDNN/src/input_layout.cpp @@ -12,6 +12,18 @@ #include #include +namespace { +bool has_optimized_users(input_layout_node const& node) { + for (auto& user : node.get_users()) { + if (user->can_be_optimized()) { + return true; + } + } + + return false; +} +} // namespace + namespace cldnn { primitive_type_id input_layout::type_id() { static primitive_type_base instance; @@ -23,7 +35,8 @@ input_layout_node::typed_program_node(const std::shared_ptr dprim, can_share_buffer(false); } -input_layout_inst::typed_primitive_inst(network& network, input_layout_node const& node) : parent(network, node) { +input_layout_inst::typed_primitive_inst(network& network, input_layout_node const& node) + : parent(network, node, !network.is_internal() || has_optimized_users(node)) { _has_valid_input = false; // by default input for 'input_layout' is invalid as long as user doesn't call set_data } diff --git a/inference-engine/thirdparty/clDNN/tests/test_cases/memory_test.cpp b/inference-engine/thirdparty/clDNN/tests/test_cases/memory_test.cpp index 861cd2672cd4e9..4582f2ad06340e 100644 --- a/inference-engine/thirdparty/clDNN/tests/test_cases/memory_test.cpp +++ b/inference-engine/thirdparty/clDNN/tests/test_cases/memory_test.cpp @@ -449,7 +449,7 @@ TEST(memory_pool, shared_dep_two_output) { network network(*engine, topo, bo); auto outputs = network.execute(); - EXPECT_EQ(engine->get_max_used_device_memory(), (uint64_t)256); + EXPECT_EQ(engine->get_max_used_device_memory(), (uint64_t)192); } TEST(memory_pool, non_opt_intermidate_opt_after) {