Skip to content

Commit

Permalink
[GPU] Get rid of memory alloc for input_layout in internal networks (o…
Browse files Browse the repository at this point in the history
  • Loading branch information
vladimir-paramuzov authored and rnugmanx committed Aug 26, 2021
1 parent cbe04f8 commit b3e7439
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
15 changes: 14 additions & 1 deletion inference-engine/thirdparty/clDNN/src/input_layout.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,18 @@
#include <memory>
#include <algorithm>

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<input_layout> instance;
Expand All @@ -23,7 +35,8 @@ input_layout_node::typed_program_node(const std::shared_ptr<input_layout> 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
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit b3e7439

Please sign in to comment.