Skip to content

Commit

Permalink
[GPU] Fixes after review
Browse files Browse the repository at this point in the history
  • Loading branch information
Lyamin-Roman committed Jun 15, 2023
1 parent 7f0d050 commit f44ca5c
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ struct kernel_impl_params {
void save(BinaryOutputBuffer& ob) const;
void load(BinaryInputBuffer& ib);
const program& get_program() const {
OPENVINO_ASSERT(prog != nullptr, "[GPU] Program pointer in kernel_impl_params in not initialized");
OPENVINO_ASSERT(prog != nullptr, "[GPU] Program pointer in kernel_impl_params is not initialized");
return *prog;
}
stream& get_stream() const { return *strm; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ struct reorder : public primitive_base<reorder> {

/// @brief Requested memory format.
format output_format;
/// @brief Primitive id to get mean subtract values. Ignored if subtract_per_featrue is set.
/// @brief Primitive id to get mean subtract values. Ignored if subtract_per_feature is set.
primitive_id mean;
/// @brief Array of mean subtract values.
std::vector<float> subtract_per_feature;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,12 +60,16 @@ void post_optimize_weights::optimize_weights(T& node, program& p) {
auto output_layout = node.get_output_layout();
auto weights_reorder_params = impl->get_weights_reorder_params();
for (auto i = offsets.weights_offset; i < offsets.bias_offset; i++) {
auto& prev_node = node.get_dependency(i);
program_node& prev_node = node.get_dependency(i);

if (weights_reorder_params != nullptr) {
if (prev_node.type() == reorder::type_id() &&
prev_node.get_users().size() == 1 &&
prev_node.get_dependencies().size() == 1) {
bool can_be_fused = prev_node.is_type<reorder>() &&
prev_node.get_users().size() == 1 &&
prev_node.get_dependencies().size() == 1 &&
!prev_node.has_fused_primitives() &&
!prev_node.as<reorder>().has_mean() &&
prev_node.as<reorder>().get_primitive()->subtract_per_feature.empty();
if (can_be_fused) {
data_types input_dtype = prev_node.get_input_layouts()[0].data_type;
auto updated_input_layout = weights_reorder_params->get_input_layout();
updated_input_layout.data_type = input_dtype;
Expand Down Expand Up @@ -100,18 +104,17 @@ void post_optimize_weights::optimize_weights(T& node, program& p) {

void post_optimize_weights::run(program& p) {
for (auto& node : p.get_processing_order()) {
if (node->type() == convolution::type_id()) {
if (node->is_type<convolution>()) {
optimize_weights(node->as<convolution>(), p);
}
if (node->type() == binary_convolution::type_id()) {
} else if (node->is_type<binary_convolution>()) {
optimize_weights(node->as<binary_convolution>(), p);
} else if (node->type() == deconvolution::type_id()) {
} else if (node->is_type<deconvolution>()) {
optimize_weights(node->as<deconvolution>(), p);
} else if (node->type() == deformable_conv::type_id()) {
} else if (node->is_type<deformable_conv>()) {
optimize_weights(node->as<deformable_conv>(), p);
} else if (node->type() == fully_connected::type_id()) {
} else if (node->is_type<fully_connected>()) {
optimize_weights(node->as<fully_connected>(), p);
} else if (node->type() == lstm_dynamic_input::type_id()) {
} else if (node->is_type<lstm_dynamic_input>()) {
optimize_weights(node->as<lstm_dynamic_input>(), p);
}
}
Expand Down
15 changes: 3 additions & 12 deletions src/plugins/intel_gpu/src/graph/impls/ocl/reorder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -114,19 +114,10 @@ struct reorder_impl : typed_primitive_impl_ocl<reorder> {
static std::unique_ptr<primitive_impl> create(const reorder_node& arg, const kernel_impl_params& impl_param) {
bool is_reorder_weights = format::is_weights_format(impl_param.get_input_layout().format) ||
format::is_weights_format(impl_param.get_output_layout().format);
if (!is_reorder_weights) {
if (arg.can_be_optimized()) {
return make_unique<reorder_impl>(kernel_selector::kernel_data{});
}
auto kernel_params = reorder_impl::get_kernel_params(reorder_impl::static_canonicalize_shapes(impl_param));
kernel_params.first.is_shape_agnostic = impl_param.is_dynamic();
kernel_params.first.set_dynamic_shape_offsets();
auto& kernel_selector = reorder_impl::kernel_selector_t::Instance();
auto best_kernel = kernel_selector.get_best_kernel(kernel_params.first, kernel_params.second);

return make_unique<reorder_impl>(best_kernel);
} else {
if (is_reorder_weights) {
return create_reorder_weigths(impl_param);
} else {
return typed_primitive_impl_ocl<reorder>::create<reorder_impl>(arg, impl_param);
}
}

Expand Down
2 changes: 2 additions & 0 deletions src/plugins/intel_gpu/src/graph/layout_optimizer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,8 @@ std::pair<std::shared_ptr<reorder>, bool> reorder_factory::get_reorder(primitive

std::pair<std::shared_ptr<primitive>, bool> reorder_factory::get_weights_reorder(primitive_id input_id,
std::shared_ptr<WeightsReorderParams> reorder_params) {
OPENVINO_ASSERT(reorder_params != nullptr, "[GPU] WeightsReorderParams is not initialized.");

cache_key ckey{ input_id, reorder_params->get_output_layout(), false };
auto itr = _cached_reorders.find(ckey);
if (itr != _cached_reorders.end()) {
Expand Down

0 comments on commit f44ca5c

Please sign in to comment.