Skip to content

Commit

Permalink
[IE CLDNN] Disable crop optimization only when the node is inside a l…
Browse files Browse the repository at this point in the history
…oop body program (openvinotoolkit#6192)
  • Loading branch information
yeonbok authored Jun 16, 2021
1 parent 5c55d39 commit b8313c4
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ void prepare_buffer_fusing::run(program_impl& p) {
}

if (node.get_dependencies().size() == 1 && node.get_users().size() > 0) {
if (node.get_dependency(0).is_type<lstm_elt>()) {
if (p.is_loop_body() && node.get_dependency(0).is_type<lstm_elt>()) {
return;
}
// optimization is available for cropping across depth(features) only
Expand Down
2 changes: 1 addition & 1 deletion inference-engine/thirdparty/clDNN/src/include/loop_inst.h
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ struct typed_program_node<loop> : public typed_program_node_base<loop> {
auto opts = get_program().get_options();
std::vector<primitive_id> output_names_vec(output_names.begin(), output_names.end());
opts.set_option(build_option::outputs(output_names_vec));
body_program = program_impl::build_program(get_program().get_engine(), body, opts, false);
body_program = program_impl::build_program(get_program().get_engine(), body, opts, false, false, true);
}

const primitive_id& get_trip_count_id() const { return get_primitive()->trip_count_id; }
Expand Down
8 changes: 6 additions & 2 deletions inference-engine/thirdparty/clDNN/src/include/program_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,8 @@ struct program_impl {
topology_impl const& topology,
build_options const& options,
bool is_internal,
bool no_optimizations = false);
bool no_optimizations = false,
bool is_body_program = false);
/* constructor used to build a program from subset of nodes of other program (used in propagate_constants) */
program_impl(engine& engine_ref,
std::set<std::shared_ptr<program_node>> const& nodes,
Expand All @@ -153,6 +154,7 @@ struct program_impl {
std::vector<program_node*>& get_outputs() {
return outputs;
} // ToDo: redesign reorder-inputs pass to make it const as_well as get_engine and get options
bool is_loop_body() const { return is_body_program; }
bool is_debug_build() const { return options.get<build_option_type::debug>()->enabled(); }
const nodes_ordering& get_processing_order() const;
nodes_ordering& get_processing_order();
Expand Down Expand Up @@ -228,7 +230,8 @@ struct program_impl {
const topology_impl& topology,
const build_options& options,
bool is_internal = false,
bool no_optimizations = false);
bool no_optimizations = false,
bool is_body_program = false);
static ptr build_program(engine& engine,
const std::set<std::shared_ptr<program_node>>& nodes,
const build_options& options,
Expand All @@ -253,6 +256,7 @@ struct program_impl {
nodes_ordering processing_order;
std::unique_ptr<pass_manager> pm;
std::shared_ptr<kernel_selector::TuningCache> tuning_cache;
bool is_body_program;


std::map<primitive_id, std::shared_ptr<program_node>> nodes_map;
Expand Down
11 changes: 7 additions & 4 deletions inference-engine/thirdparty/clDNN/src/program.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,13 +84,15 @@ program_impl::program_impl(engine& engine_ref,
topology_impl const& topology,
build_options const& options,
bool is_internal,
bool no_optimizations)
bool no_optimizations,
bool is_body_program)
: _engine(engine_ref),
_stream(_engine.create_stream()),
program_state(_engine),
options(options),
processing_order(),
tuning_cache(nullptr) {
tuning_cache(nullptr),
is_body_program(is_body_program) {
init_primitives();
kernel_selector::KernelBase::ResetCounter();
set_options();
Expand Down Expand Up @@ -163,8 +165,9 @@ program_impl::ptr program_impl::build_program(engine& engine,
const topology_impl& topology,
const build_options& options,
bool is_internal,
bool no_optimizations) {
return std::make_shared<program_impl>(engine, topology, options, is_internal, no_optimizations);
bool no_optimizations,
bool is_body_program) {
return std::make_shared<program_impl>(engine, topology, options, is_internal, no_optimizations, is_body_program);
}

program_impl::ptr program_impl::build_program(engine& engine,
Expand Down

0 comments on commit b8313c4

Please sign in to comment.