[GPU] Fix FC 3D input size propagation and bias fusion (#10249)
This commit is contained in:
1 parent
d94cff59a3
commit
bc21e52912
2 files changed
+22
-3
No files matched your search
@@ -285,8 +285,21 @@ void prepare_primitive_fusing::fuse_bias(program &p) {
|
||||
if (!is_bias)
|
||||
continue;
|
||||
|
||||
auto is_3d_fully_connected = [](program_node& node) {
|
||||
if (!node.is_type<fully_connected>())
|
||||
return false;
|
||||
|
||||
return node.as<fully_connected>().get_primitive()->input_size == 3;
|
||||
};
|
||||
|
||||
size_t out_features = static_cast<size_t>(node->get_output_layout().size.feature[0]);
|
||||
|
||||
// Change out_features value to proper dimension for 3D FC case
|
||||
if (is_3d_fully_connected(node->get_dependency(0)))
|
||||
out_features = static_cast<size_t>(node->get_dependency(0).get_output_layout().size.spatial[1]);
|
||||
else if (is_3d_fully_connected(node->get_dependency(1)))
|
||||
out_features = static_cast<size_t>(node->get_dependency(1).get_output_layout().size.spatial[1]);
|
||||
|
||||
int bias_idx = -1;
|
||||
for (size_t i = 0; i < eltw_node.get_dependencies().size(); i++) {
|
||||
auto& dep = eltw_node.get_dependency(i);
|
||||
@@ -448,7 +461,10 @@ void prepare_primitive_fusing::fuse_bias(program &p) {
|
||||
desc->input[0],
|
||||
desc->weights,
|
||||
bias_name,
|
||||
fc.get_output_layout().data_type);
|
||||
fc.get_output_layout().data_type,
|
||||
desc->ext_prim_id,
|
||||
desc->output_padding,
|
||||
desc->input_size);
|
||||
|
||||
auto& new_fc_node = p.get_or_create(fc_with_bias_prim);
|
||||
fuse_bias_f(fc, new_fc_node, bias_node, eltw_node);
|
||||
|
||||
@@ -84,7 +84,7 @@ public:
|
||||
layout get_bias_layout(fully_connected_test_params& p) {
|
||||
if (p.out_shape.spatial[1] > 1) {
|
||||
// 3d case
|
||||
return layout{ p.default_type, format::bfyx, tensor{ 1, p.out_shape.spatial[1], 1, 1 } };
|
||||
return layout{ p.default_type, format::bfyx, tensor{ 1, 1, 1, p.out_shape.spatial[1] } };
|
||||
}
|
||||
else {
|
||||
return layout{ p.default_type, format::bfyx, tensor{ 1, p.out_shape.feature[0], 1, 1 } };
|
||||
@@ -207,7 +207,7 @@ TEST_P(fc_fp32_bias, basic) {
|
||||
input_layout("input", get_input_layout(p)),
|
||||
data("weights", get_mem(get_weights_layout(p))),
|
||||
data("bias", get_mem(get_bias_layout(p))),
|
||||
fully_connected("fc_prim", "input", "weights", ""),
|
||||
fully_connected("fc_prim", "input", "weights", "", "", padding(), get_output_dim_size(p)),
|
||||
eltwise("bias_add", { "fc_prim", "bias" }, eltwise_mode::sum),
|
||||
reorder("reorder_bfyx", "bias_add", p.default_format, data_types::f32)
|
||||
);
|
||||
@@ -220,6 +220,9 @@ INSTANTIATE_TEST_SUITE_P(fusings_gpu, fc_fp32_bias, ::testing::ValuesIn(std::vec
|
||||
fully_connected_test_params{ CASE_FC_FP32_1, 2, 3 },
|
||||
fully_connected_test_params{ CASE_FC_FP32_2, 2, 3 },
|
||||
fully_connected_test_params{ CASE_FC_FP32_3, 2, 3 },
|
||||
fully_connected_test_params{ CASE_FC_FP32_3D_1, 2, 3 },
|
||||
fully_connected_test_params{ CASE_FC_FP32_3D_2, 2, 3 },
|
||||
fully_connected_test_params{ CASE_FC_FP32_3D_3, 2, 3 },
|
||||
}));
|
||||
|
||||
class fc_int8_scale : public FullyConnectedFusingTest {};
|
||||
|
||||
Reference in new issue
Block a user