Skip to content

Commit

Permalink
new shape infer for lsm_cell, changes from review
Browse files Browse the repository at this point in the history
Signed-off-by: Michal Miotk <[email protected]>
  • Loading branch information
michal-miotk committed Nov 21, 2024
1 parent 63ee3b4 commit c99a348
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 33 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
//

#include "lstm_seq_inst.h"
#include "reshape_inst.h"
#include "intel_gpu/runtime/utils.hpp"
#include "impls/registry/implementation_manager.hpp"
#include "transformations/utils/utils.hpp"
Expand All @@ -20,7 +21,8 @@ struct LSTMSeqImplementationManager : public ImplementationManager {

bool validate_impl(const program_node& node) const override {
assert(node.is_type<lstm_seq>());
return node.get_input_layout(0).format == cldnn::format::bfyx || node.get_input_layout(0).format == cldnn::format::fbyx;
return node.get_input_layout(0).format == cldnn::format::bfyx || node.get_input_layout(0).format == cldnn::format::fbyx \
|| node.get_input_layout(0).format == cldnn::format::ybfx;
}

in_out_fmts_t query_formats(const program_node& node) const override {
Expand Down
4 changes: 1 addition & 3 deletions src/plugins/intel_gpu/src/graph/layout_optimizer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1088,7 +1088,7 @@ format layout_optimizer::get_expected_format(quantize_node const& node) {
return all_users_gemm;
};

auto use_onednn_impls = contains_onednn_impls_optimization_attribute(&node);
auto use_onednn_impls = has_all_enabled_onednn_impls_optimization_attribute();

if (use_onednn_impls) {
expected = format::any;
Expand Down Expand Up @@ -1445,8 +1445,6 @@ bool layout_optimizer::has_all_enabled_onednn_impls_optimization_attribute() {
is_enabled_onednn_for<pooling>() && is_enabled_onednn_for<reduce>() && is_enabled_onednn_for<reorder>();
}



void layout_optimizer::set_value_onednn(primitive_type_id p_type, bool val) {
_optimization_attributes.onednn_impls[p_type] = val;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,11 +149,11 @@ KERNEL(lstm_cell_and_seq_bfyx)(
}

unroll_for(uint j=block_num*VEC_SIZE;j<INPUT_SIZE;++j) { //leftovers
if (dir == 1) {
input_result += x[GET_IN0_IDX(b, real_seq_length-1-i, j)]*W[GET_IN3_IDX(dir, weight_idx, j)];
} else {
input_result += x[GET_IN0_IDX(b, i, j)]*W[GET_IN3_IDX(dir, weight_idx, j)];
}
if (dir == 1) {
input_result += x[GET_IN0_IDX(b, real_seq_length-1-i, j)]*W[GET_IN3_IDX(dir, weight_idx, j)];
} else {
input_result += x[GET_IN0_IDX(b, i, j)]*W[GET_IN3_IDX(dir, weight_idx, j)];
}
}
gate_output[k] = hidden_result + input_result + TO_ACCUMULATOR_TYPE(B[GET_IN5_IDX(dir, weight_idx)]);
switch(k){
Expand Down
17 changes: 0 additions & 17 deletions src/plugins/intel_gpu/src/plugin/ops/rnn.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,23 +80,6 @@ static void CreateLSTMCellOp(ProgramBuilder& p, const std::shared_ptr<ov::op::v4
cldnn::input_info(), "", layerName + "_md_write.1", clip, false, activations, \
activation_params, cldnn::lstm_weights_order::fizo, ov::op::RecurrentSequenceDirection::FORWARD, cldnn::padding(), \
static_cast<int>(op->get_output_size())));
} else {
auto mutable_precision_first = op->get_output_element_type(1);
cldnn::layout outLayout = cldnn::layout(
cldnn::element_type_to_data_type(mutable_precision_first),
cldnn::format::get_default_format(op->get_output_shape(1).size()),
tensor_from_dims(op->get_output_shape(1)));

cldnn::memory::ptr shared_memory = p.get_engine().allocate_memory(outLayout);
const cldnn::primitive_id mutable_id_1 = layerName + "_md_write.1";
const cldnn::mutable_data mutable_prim_1{mutable_id_1, shared_memory};
p.add_primitive(*op, mutable_prim_1);

p.add_primitive(*op, cldnn::lstm_cell(layerName+".out0", inputs[0], inputs[1], inputs[2], inputs[3], inputs[4], inputs[5], \
cldnn::input_info(), "", layerName + "_md_write.1", clip, false, activations, \
activation_params, cldnn::lstm_weights_order::fizo, ov::op::RecurrentSequenceDirection::FORWARD, cldnn::padding(), 1));

p.add_primitive(*op, cldnn::mutable_data(layerName + ".out1", {cldnn::input_info(layerName + ".out0")}, shared_memory));
}
}

Expand Down
6 changes: 0 additions & 6 deletions src/plugins/intel_gpu/src/plugin/plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -189,9 +189,6 @@ std::shared_ptr<ov::ICompiledModel> Plugin::compile_model(const std::shared_ptr<

ExecutionConfig config = m_configs_map.at(device_id);
config.set_user_property(orig_config);
if (context->get_engine().get_device_info().supports_immad) {
config.set_property(ov::intel_gpu::use_onednn(true));
}
config.apply_user_properties(context->get_engine().get_device_info());

set_cache_info(model, config);
Expand All @@ -213,9 +210,6 @@ std::shared_ptr<ov::ICompiledModel> Plugin::compile_model(const std::shared_ptr<

ExecutionConfig config = m_configs_map.at(device_id);
config.set_user_property(orig_config);
if (context_impl->get_engine().get_device_info().supports_immad) {
config.set_property(ov::intel_gpu::use_onednn(true));
}
config.apply_user_properties(context_impl->get_engine().get_device_info());

set_cache_info(model, config);
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/intel_gpu/src/plugin/program_builder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,7 @@ bool ProgramBuilder::requires_new_shape_infer(const std::shared_ptr<ov::Node>& o
return true;
}

if (ov::is_type<ov::op::v5::LSTMSequence>(op)) {
if (ov::is_type<ov::op::v5::LSTMSequence>(op) || ov::is_type<ov::op::v4::LSTMCell>(op)) {
return true;
}
// When input node has dynamic shape with 4 dimension, this function return false
Expand Down

0 comments on commit c99a348

Please sign in to comment.