Skip to content

Commit

Permalink
Refactor #1
Browse files Browse the repository at this point in the history
  • Loading branch information
tomdol committed Mar 21, 2023
1 parent be21af4 commit 987f4a4
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 63 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,11 @@ ov::pass::ConvertInterpolate11ToInterpolate4::ConvertInterpolate11ToInterpolate4
ov::op::util::InterpolateBase::ShapeCalcMode::SCALES) {
v4_input_scales = interpolate_v11->input_value(1);
v4_input_output_shape = opset4::Constant::create(element::i32, Shape{}, {1});
copy_runtime_info(interpolate_v11, v4_input_output_shape.get_node_shared_ptr());
} else {
v4_input_output_shape = interpolate_v11->input_value(1);
v4_input_scales = opset4::Constant::create(element::f32, Shape{}, {1.0f});
copy_runtime_info(interpolate_v11, v4_input_scales.get_node_shared_ptr());
}

if (interpolate_v11->get_input_size() == 3) { // with axes input
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,47 @@

using namespace testing;

TEST_F(TransformationTestsF, ConvertInterpolate11ToInterpolate4_scales) {
{
auto attributes = ov::opset11::Interpolate::InterpolateAttrs{};
attributes.shape_calculation_mode = ov::opset11::Interpolate::ShapeCalcMode::SCALES;
attributes.pads_begin = {0, 0};
attributes.pads_end = {0, 0};
namespace {
constexpr bool WITH_AXES = true;
constexpr bool WITHOUT_AXES = false;

const auto input = std::make_shared<ov::opset11::Parameter>(ov::element::i32, ov::Shape{1, 2, 10, 10});
const auto scales = std::make_shared<ov::opset11::Parameter>(ov::element::f32, ov::Shape{2});
std::shared_ptr<ov::Model> create_v11_model(const bool with_axes,
const ov::opset11::Interpolate::ShapeCalcMode shape_calc_mode) {
auto attributes = ov::opset11::Interpolate::InterpolateAttrs{};
attributes.shape_calculation_mode = shape_calc_mode;
attributes.pads_begin = {0, 0};
attributes.pads_end = {0, 0};

const auto input = std::make_shared<ov::opset11::Parameter>(ov::element::i32, ov::Shape{1, 2, 10, 10});
std::shared_ptr<ov::opset11::Parameter> scales_or_sizes;
std::shared_ptr<ov::opset11::Interpolate> interpolate;

const size_t num_scales_or_sizes = with_axes ? 2 : 4;
if (shape_calc_mode == ov::opset11::Interpolate::ShapeCalcMode::SCALES) {
scales_or_sizes = std::make_shared<ov::opset11::Parameter>(ov::element::f32, ov::Shape{num_scales_or_sizes});
} else {
scales_or_sizes = std::make_shared<ov::opset11::Parameter>(ov::element::i32, ov::Shape{num_scales_or_sizes});
}

ov::ParameterVector model_params;
model_params.push_back(input);
model_params.push_back(scales_or_sizes);
if (with_axes) {
const auto axes = std::make_shared<ov::opset11::Parameter>(ov::element::i32, ov::Shape{2});
const auto interpolate = std::make_shared<ov::opset11::Interpolate>(input, scales, axes, attributes);
interpolate->set_friendly_name("interpolate11");
model_params.push_back(axes);
interpolate = std::make_shared<ov::opset11::Interpolate>(input, scales_or_sizes, axes, attributes);
} else {
interpolate = std::make_shared<ov::opset11::Interpolate>(input, scales_or_sizes, attributes);
}
interpolate->set_friendly_name("interpolate11");

return std::make_shared<ov::Model>(interpolate->outputs(), model_params);
}
} // namespace

function = std::make_shared<ov::Model>(interpolate->outputs(), ov::ParameterVector{input, scales, axes});
TEST_F(TransformationTestsF, ConvertInterpolate11ToInterpolate4_scales) {
{
function = create_v11_model(WITH_AXES, ov::opset11::Interpolate::ShapeCalcMode::SCALES);
manager.register_pass<ov::pass::ConvertInterpolate11ToInterpolate4>();
}

Expand All @@ -53,18 +80,7 @@ TEST_F(TransformationTestsF, ConvertInterpolate11ToInterpolate4_scales) {

TEST_F(TransformationTestsF, ConvertInterpolate11ToInterpolate4_sizes) {
{
auto attributes = ov::opset11::Interpolate::InterpolateAttrs{};
attributes.shape_calculation_mode = ov::opset11::Interpolate::ShapeCalcMode::SIZES;
attributes.pads_begin = {0, 0};
attributes.pads_end = {0, 0};

const auto input = std::make_shared<ov::opset11::Parameter>(ov::element::i32, ov::Shape{1, 2, 10, 10});
const auto sizes = std::make_shared<ov::opset11::Parameter>(ov::element::i32, ov::Shape{2});
const auto axes = std::make_shared<ov::opset11::Parameter>(ov::element::i32, ov::Shape{2});
const auto interpolate = std::make_shared<ov::opset11::Interpolate>(input, sizes, axes, attributes);
interpolate->set_friendly_name("interpolate11");

function = std::make_shared<ov::Model>(interpolate->outputs(), ov::ParameterVector{input, sizes, axes});
function = create_v11_model(WITH_AXES, ov::opset11::Interpolate::ShapeCalcMode::SIZES);
manager.register_pass<ov::pass::ConvertInterpolate11ToInterpolate4>();
}

Expand All @@ -90,17 +106,7 @@ TEST_F(TransformationTestsF, ConvertInterpolate11ToInterpolate4_sizes) {

TEST_F(TransformationTestsF, ConvertInterpolate11ToInterpolate4_no_axes) {
{
auto attributes = ov::opset11::Interpolate::InterpolateAttrs{};
attributes.shape_calculation_mode = ov::opset11::Interpolate::ShapeCalcMode::SCALES;
attributes.pads_begin = {0, 0};
attributes.pads_end = {0, 0};

const auto input = std::make_shared<ov::opset11::Parameter>(ov::element::i32, ov::Shape{1, 2, 10, 10});
const auto scales = std::make_shared<ov::opset11::Parameter>(ov::element::f32, ov::Shape{4});
const auto interpolate = std::make_shared<ov::opset11::Interpolate>(input, scales, attributes);
interpolate->set_friendly_name("interpolate11");

function = std::make_shared<ov::Model>(interpolate->outputs(), ov::ParameterVector{input, scales});
function = create_v11_model(WITHOUT_AXES, ov::opset11::Interpolate::ShapeCalcMode::SCALES);
manager.register_pass<ov::pass::ConvertInterpolate11ToInterpolate4>();
}

Expand All @@ -123,17 +129,7 @@ TEST_F(TransformationTestsF, ConvertInterpolate11ToInterpolate4_no_axes) {

TEST_F(TransformationTestsF, ConvertInterpolate11ToInterpolate4_sizes_no_axes) {
{
auto attributes = ov::opset11::Interpolate::InterpolateAttrs{};
attributes.shape_calculation_mode = ov::opset11::Interpolate::ShapeCalcMode::SIZES;
attributes.pads_begin = {0, 0};
attributes.pads_end = {0, 0};

const auto input = std::make_shared<ov::opset11::Parameter>(ov::element::i32, ov::Shape{1, 2, 10, 10});
const auto sizes = std::make_shared<ov::opset11::Parameter>(ov::element::i32, ov::Shape{4});
const auto interpolate = std::make_shared<ov::opset11::Interpolate>(input, sizes, attributes);
interpolate->set_friendly_name("interpolate11");

function = std::make_shared<ov::Model>(interpolate->outputs(), ov::ParameterVector{input, sizes});
function = create_v11_model(WITHOUT_AXES, ov::opset11::Interpolate::ShapeCalcMode::SIZES);
manager.register_pass<ov::pass::ConvertInterpolate11ToInterpolate4>();
}

Expand All @@ -154,9 +150,10 @@ TEST_F(TransformationTestsF, ConvertInterpolate11ToInterpolate4_sizes_no_axes) {
}
}

TEST_F(TransformationTestsF, ConvertInterpolate11ToInterpolate4_bicubic_pillow) {
namespace {
std::shared_ptr<ov::Model> create_non_downgradeable_model(const ov::opset11::Interpolate::InterpolateMode mode) {
auto attributes = ov::opset11::Interpolate::InterpolateAttrs{};
attributes.mode = ov::opset11::Interpolate::InterpolateMode::BICUBIC_PILLOW;
attributes.mode = mode;
attributes.shape_calculation_mode = ov::opset11::Interpolate::ShapeCalcMode::SCALES;
attributes.pads_begin = {0, 0};
attributes.pads_end = {0, 0};
Expand All @@ -168,24 +165,16 @@ TEST_F(TransformationTestsF, ConvertInterpolate11ToInterpolate4_bicubic_pillow)
const auto interpolate = std::make_shared<ov::opset11::Interpolate>(input, scales, axes, attributes);
interpolate->set_friendly_name("interpolate11");

function = std::make_shared<ov::Model>(interpolate->outputs(), ov::ParameterVector{input, scales, axes});
return std::make_shared<ov::Model>(interpolate->outputs(), ov::ParameterVector{input, scales, axes});
}
} // namespace

TEST_F(TransformationTestsF, ConvertInterpolate11ToInterpolate4_bicubic_pillow) {
function = create_non_downgradeable_model(ov::opset11::Interpolate::InterpolateMode::BICUBIC_PILLOW);
manager.register_pass<ov::pass::ConvertInterpolate11ToInterpolate4>();
}

TEST_F(TransformationTestsF, ConvertInterpolate11ToInterpolate4_bilinear_pillow) {
auto attributes = ov::opset11::Interpolate::InterpolateAttrs{};
attributes.mode = ov::opset11::Interpolate::InterpolateMode::BILINEAR_PILLOW;
attributes.shape_calculation_mode = ov::opset11::Interpolate::ShapeCalcMode::SCALES;
attributes.pads_begin = {0, 0};
attributes.pads_end = {0, 0};

const auto input = std::make_shared<ov::opset11::Parameter>(ov::element::i32, ov::Shape{1, 2, 10, 10});
const auto scales = std::make_shared<ov::opset11::Parameter>(ov::element::f32, ov::Shape{2});
const auto axes = std::make_shared<ov::opset11::Parameter>(ov::element::i32, ov::Shape{2});

const auto interpolate = std::make_shared<ov::opset11::Interpolate>(input, scales, axes, attributes);
interpolate->set_friendly_name("interpolate11");

function = std::make_shared<ov::Model>(interpolate->outputs(), ov::ParameterVector{input, scales, axes});
function = create_non_downgradeable_model(ov::opset11::Interpolate::InterpolateMode::BILINEAR_PILLOW);
manager.register_pass<ov::pass::ConvertInterpolate11ToInterpolate4>();
}
2 changes: 1 addition & 1 deletion src/plugins/intel_gpu/thirdparty/onednn_gpu
Submodule onednn_gpu updated 44 files
+0 −7 README.md
+1 −1 cmake/options.cmake
+7 −0 doc/advanced/experimental.md
+3 −3 doc/build/build_options.md
+1 −1 examples/cpu_matmul_csr.cpp
+3 −3 include/oneapi/dnnl/dnnl.hpp
+12 −4 src/CMakeLists.txt
+15 −10 src/cpu/matmul/cpu_matmul_list.cpp
+1 −0 src/cpu/x64/brgemm/brgemm_utils.cpp
+2 −1 src/cpu/x64/brgemm/jit_brgemm_amx_uker.cpp
+4 −5 src/cpu/x64/jit_avx512_core_amx_conv_kernel.cpp
+5 −4 src/cpu/x64/jit_avx512_core_bf16_conv_kernel.cpp
+6 −2 src/cpu/x64/jit_brgemm_conv.cpp
+12 −10 src/cpu/x64/jit_brgemm_inner_product.cpp
+1 −1 src/cpu/x64/matmul/jit_uni_sparse_matmul.hpp
+14 −4 src/gpu/jit/codegen/kernel.hpp
+9 −4 src/gpu/jit/conv/config.cpp
+1 −0 src/gpu/jit/conv/config_plan.cpp
+29 −0 src/gpu/jit/conv/epilogue.cpp
+13 −8 src/gpu/jit/conv/post_ops.hpp
+1 −10 src/gpu/jit/ir/message.cpp
+13 −3 src/gpu/jit/ir/post_ops.hpp
+5 −1 src/gpu/ocl/gemm/gemm_with_post_ops.cpp
+14 −3 src/gpu/ocl/gen9_softmax.cl
+7 −3 src/gpu/ocl/gen9_softmax.hpp
+15 −0 src/graph/backend/dnnl/dnnl_backend.hpp
+6 −9 src/graph/backend/dnnl/kernels/conv.hpp
+5 −8 src/graph/backend/dnnl/kernels/convtranspose.hpp
+5 −8 src/graph/backend/dnnl/kernels/eltwise.hpp
+5 −7 src/graph/backend/dnnl/kernels/large_partition.hpp
+5 −8 src/graph/backend/dnnl/kernels/layernorm.hpp
+5 −8 src/graph/backend/dnnl/kernels/matmul.hpp
+5 −8 src/graph/backend/dnnl/kernels/pool.hpp
+5 −8 src/graph/backend/dnnl/kernels/quantize.hpp
+5 −8 src/graph/backend/dnnl/kernels/reorder.hpp
+5 −8 src/graph/backend/dnnl/kernels/softmax.hpp
+1 −0 tests/benchdnn/CMakeLists.txt
+3 −2 tests/benchdnn/graph/flex_rewrite.cpp
+1 −1 tests/benchdnn/inputs/matmul/test_matmul_sparse
+5 −0 tests/benchdnn/inputs/matmul/test_matmul_sparse_ci
+16 −3 tests/benchdnn/matmul/matmul.cpp
+2 −2 tests/gtests/graph/unit/backend/dnnl/test_matmul.cpp
+13 −1 tests/gtests/internals/test_env_vars_dnnl.cpp
+13 −1 tests/gtests/test_iface_primitive_cache.cpp

0 comments on commit 987f4a4

Please sign in to comment.