From 2e238786550c505c52988c2a47337d58831100ba Mon Sep 17 00:00:00 2001 From: kahmed10 <15948690+kahmed10@users.noreply.github.com> Date: Sat, 11 Jan 2025 06:12:53 -0600 Subject: [PATCH 01/19] Fix memory_coloring pass when MIGRAPHX_NSTREAMS > 2 I noticed allocation segments reaching close to uint64 max value, which clearly would throw an out of memory error when trying to allocate on the GPU. This happened when MIGRAPHX_NSTREAMS was set to 2 or greater and the model somehow was large enough to trigger it. Changing from `auto` to `size_t` seems to fix the issue. --- src/memory_coloring.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/memory_coloring.cpp b/src/memory_coloring.cpp index 3753f549000..d7aa0349c72 100644 --- a/src/memory_coloring.cpp +++ b/src/memory_coloring.cpp @@ -177,9 +177,9 @@ struct allocation_segment { assert(ins->get_shape().bytes() > 0); // Compute alignment - auto n = 1 + (ins->get_shape().bytes() - 1) / alignment; + std::size_t n = 1 + (ins->get_shape().bytes() - 1) / alignment; assert(n > 0); - auto start = 0; + std::size_t start = 0; // Insert at end if it cant fit at the begining if(segments.empty() or segments.begin()->first <= n) { From be58a75efb4851bba3a31a6ac86464a2d25d02df Mon Sep 17 00:00:00 2001 From: kahmed10 <15948690+kahmed10@users.noreply.github.com> Date: Wed, 15 Jan 2025 16:22:49 +0000 Subject: [PATCH 02/19] update copyright and add test case --- src/memory_coloring.cpp | 2 +- test/memory_coloring_test.cpp | 14 ++++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/src/memory_coloring.cpp b/src/memory_coloring.cpp index d7aa0349c72..c8df8fa7bee 100644 --- a/src/memory_coloring.cpp +++ b/src/memory_coloring.cpp @@ -1,7 +1,7 @@ /* * The MIT License (MIT) * - * Copyright (c) 2015-2024 Advanced Micro Devices, Inc. All rights reserved. + * Copyright (c) 2015-2025 Advanced Micro Devices, Inc. All rights reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/test/memory_coloring_test.cpp b/test/memory_coloring_test.cpp index d6c615e033d..43b644b4865 100644 --- a/test/memory_coloring_test.cpp +++ b/test/memory_coloring_test.cpp @@ -3805,4 +3805,18 @@ TEST_CASE(test_tuple) CHECK(is_disjoint({a1, a2})); } +TEST_CASE(test_large_offsets) +{ + migraphx::module m; + + auto a1 = add_alloc(m, {migraphx::shape::float_type, {10000000000}}); + auto m1 = m.add_instruction(pass_op{}, a1); + auto a2 = add_alloc(m, {migraphx::shape::float_type, {10000000000}}); + m.add_instruction(pass_op{}, a2, m1); + run_pass(m); + CHECK(m.get_parameter_shape("scratch").bytes() == 80000000000); + CHECK(no_allocate(m)); + CHECK(is_disjoint({a1, a2})); +} + int main(int argc, const char* argv[]) { test::run(argc, argv); } From 031d500efd3928e3c16637469746d6dc8380040c Mon Sep 17 00:00:00 2001 From: kahmed10 <15948690+kahmed10@users.noreply.github.com> Date: Wed, 15 Jan 2025 16:24:02 +0000 Subject: [PATCH 03/19] update test copyright --- test/memory_coloring_test.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/memory_coloring_test.cpp b/test/memory_coloring_test.cpp index 43b644b4865..e4a82288278 100644 --- a/test/memory_coloring_test.cpp +++ b/test/memory_coloring_test.cpp @@ -1,7 +1,7 @@ /* * The MIT License (MIT) * - * Copyright (c) 2015-2023 Advanced Micro Devices, Inc. All rights reserved. + * Copyright (c) 2015-2025 Advanced Micro Devices, Inc. All rights reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal From 582b2817e479af8db188ee1cd496ea8dea07e53b Mon Sep 17 00:00:00 2001 From: kahmed10 <15948690+kahmed10@users.noreply.github.com> Date: Thu, 16 Jan 2025 03:30:05 +0000 Subject: [PATCH 04/19] fix convinteger bias parsing and updated test --- src/memory_coloring.cpp | 6 ++-- src/onnx/parse_convolution.cpp | 30 ++++++++++++------- test/memory_coloring_test.cpp | 16 +--------- test/onnx/convinteger_dual_bias_test.onnx | 24 ++++++++------- test/onnx/gen_onnx.py | 8 ++--- .../onnx/parse/convinteger_dual_bias_test.cpp | 30 ++++++++----------- 6 files changed, 53 insertions(+), 61 deletions(-) diff --git a/src/memory_coloring.cpp b/src/memory_coloring.cpp index c8df8fa7bee..3753f549000 100644 --- a/src/memory_coloring.cpp +++ b/src/memory_coloring.cpp @@ -1,7 +1,7 @@ /* * The MIT License (MIT) * - * Copyright (c) 2015-2025 Advanced Micro Devices, Inc. All rights reserved. + * Copyright (c) 2015-2024 Advanced Micro Devices, Inc. All rights reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -177,9 +177,9 @@ struct allocation_segment { assert(ins->get_shape().bytes() > 0); // Compute alignment - std::size_t n = 1 + (ins->get_shape().bytes() - 1) / alignment; + auto n = 1 + (ins->get_shape().bytes() - 1) / alignment; assert(n > 0); - std::size_t start = 0; + auto start = 0; // Insert at end if it cant fit at the begining if(segments.empty() or segments.begin()->first <= n) { diff --git a/src/onnx/parse_convolution.cpp b/src/onnx/parse_convolution.cpp index d8ba3d498b5..70ae790c01d 100644 --- a/src/onnx/parse_convolution.cpp +++ b/src/onnx/parse_convolution.cpp @@ -1,7 +1,7 @@ /* * The MIT License (MIT) * - * Copyright (c) 2015-2024 Advanced Micro Devices, Inc. All rights reserved. + * Copyright (c) 2015-2025 Advanced Micro Devices, Inc. All rights reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -141,10 +141,10 @@ struct parse_convolution : op_parser return all_zeros; } - static auto + static migraphx::operation qparam_broadcast_op(instruction_ref qparam, std::vector lens, std::size_t axis) { - if(qparam->get_shape().scalar()) + if(qparam->get_shape().elements() == 1) { return migraphx::make_op("multibroadcast", {{"out_lens", lens}}); } @@ -162,27 +162,37 @@ struct parse_convolution : op_parser const instruction_ref& w_zp, onnx_parser::node_info& info) { + // to handle the bias, apply the following transformation: + // conv(x-x_zp,w-w_zp) = conv(x,w) - conv(x_zp,w) - conv(x,w_zp) + conv(x_zp,w_zp) instruction_ref ret = input; + + // multibroadcast (or broadcast) zero points according to spec + // x_zp should be a scalar or literal with one element + // w_zp can be either a single element or a 1d tensor with size out_channels + migraphx::operation x_zp_bc = migraphx::make_op("multibroadcast", {{"out_lens", x->get_shape().lens()}}); + migraphx::operation w_zp_bc = qparam_broadcast_op(w_zp, weights->get_shape().lens(), 0); + if(not is_symmetric_zero_point(x_zp)) { - auto out_zp_1 = info.add_common_op(op.name(), x_zp, weights); + auto x_zp_mb = info.add_instruction(x_zp_bc, x_zp); + auto out_zp_1 = info.add_instruction(op, x_zp_mb, weights); ret = info.add_common_op("sub", ret, out_zp_1); } if(not is_symmetric_zero_point(w_zp)) { - auto out_zp_2 = info.add_common_op(op.name(), x, w_zp); + auto w_zp_mb = info.add_instruction(w_zp_bc, w_zp); + auto out_zp_2 = info.add_instruction(op, x, w_zp_mb); ret = info.add_common_op("sub", ret, out_zp_2); } if(not(is_symmetric_zero_point(x_zp)) and not(is_symmetric_zero_point(w_zp))) { - auto x_zp_bc = - info.add_instruction(qparam_broadcast_op(x_zp, x->get_shape().lens(), 0), x_zp); - auto w_zp_bc = info.add_instruction( - qparam_broadcast_op(w_zp, weights->get_shape().lens(), 0), w_zp); + auto x_zp_mb = + info.add_instruction(x_zp_bc, x_zp); + auto w_zp_mb = info.add_instruction(w_zp_bc, w_zp); - auto out_zp_3 = info.add_instruction(op, x_zp_bc, w_zp_bc); + auto out_zp_3 = info.add_instruction(op, x_zp_mb, w_zp_mb); ret = info.add_common_op("add", ret, out_zp_3); } diff --git a/test/memory_coloring_test.cpp b/test/memory_coloring_test.cpp index e4a82288278..d6c615e033d 100644 --- a/test/memory_coloring_test.cpp +++ b/test/memory_coloring_test.cpp @@ -1,7 +1,7 @@ /* * The MIT License (MIT) * - * Copyright (c) 2015-2025 Advanced Micro Devices, Inc. All rights reserved. + * Copyright (c) 2015-2023 Advanced Micro Devices, Inc. All rights reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -3805,18 +3805,4 @@ TEST_CASE(test_tuple) CHECK(is_disjoint({a1, a2})); } -TEST_CASE(test_large_offsets) -{ - migraphx::module m; - - auto a1 = add_alloc(m, {migraphx::shape::float_type, {10000000000}}); - auto m1 = m.add_instruction(pass_op{}, a1); - auto a2 = add_alloc(m, {migraphx::shape::float_type, {10000000000}}); - m.add_instruction(pass_op{}, a2, m1); - run_pass(m); - CHECK(m.get_parameter_shape("scratch").bytes() == 80000000000); - CHECK(no_allocate(m)); - CHECK(is_disjoint({a1, a2})); -} - int main(int argc, const char* argv[]) { test::run(argc, argv); } diff --git a/test/onnx/convinteger_dual_bias_test.onnx b/test/onnx/convinteger_dual_bias_test.onnx index 4b166872b7f..ca303d812fa 100644 --- a/test/onnx/convinteger_dual_bias_test.onnx +++ b/test/onnx/convinteger_dual_bias_test.onnx @@ -8,27 +8,29 @@ B strides@@ convinteger_dual_bias_testZ 0  - +  - -Z + + + +Z 1 - - - + +  -Z + +Z 2  Z 3 - + b 4  - - +  -B \ No newline at end of file + +B \ No newline at end of file diff --git a/test/onnx/gen_onnx.py b/test/onnx/gen_onnx.py index 3f492e70f2c..6cea5291419 100644 --- a/test/onnx/gen_onnx.py +++ b/test/onnx/gen_onnx.py @@ -1686,11 +1686,11 @@ def convinteger_bias_test(): @onnx_test() def convinteger_dual_bias_test(): - x = helper.make_tensor_value_info('0', TensorProto.INT8, [1, 3, 5, 5]) - y = helper.make_tensor_value_info('1', TensorProto.INT8, [1, 3, 2, 2]) + x = helper.make_tensor_value_info('0', TensorProto.INT8, [2, 3, 10, 10]) + y = helper.make_tensor_value_info('1', TensorProto.UINT8, [4, 2, 3, 3]) z = helper.make_tensor_value_info('2', TensorProto.INT8, [1]) - w = helper.make_tensor_value_info('3', TensorProto.INT8, [1]) - out = helper.make_tensor_value_info('4', TensorProto.INT32, [1, 1, 4, 4]) + w = helper.make_tensor_value_info('3', TensorProto.UINT8, [1]) + out = helper.make_tensor_value_info('4', TensorProto.INT32, [2, 4, 8, 8]) node = onnx.helper.make_node('ConvInteger', inputs=['0', '1', '2', '3'], diff --git a/test/onnx/parse/convinteger_dual_bias_test.cpp b/test/onnx/parse/convinteger_dual_bias_test.cpp index 97445ff6ab9..1a5a00d9ed5 100644 --- a/test/onnx/parse/convinteger_dual_bias_test.cpp +++ b/test/onnx/parse/convinteger_dual_bias_test.cpp @@ -1,7 +1,7 @@ /* * The MIT License (MIT) * - * Copyright (c) 2015-2024 Advanced Micro Devices, Inc. All rights reserved. + * Copyright (c) 2015-2025 Advanced Micro Devices, Inc. All rights reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -28,41 +28,35 @@ TEST_CASE(convinteger_dual_bias_test) { migraphx::program p; auto* mm = p.get_main_module(); - auto data = mm->add_parameter("0", {migraphx::shape::int8_type, {1, 3, 5, 5}}); - auto weight = mm->add_parameter("1", {migraphx::shape::int8_type, {1, 3, 2, 2}}); + auto data = mm->add_parameter("0", {migraphx::shape::int8_type, {2, 3, 10, 10}}); + auto weight = mm->add_parameter("1", {migraphx::shape::int8_type, {4, 2, 3, 3}}); auto data_bias = mm->add_parameter("2", {migraphx::shape::int8_type, {1}, {1}}); auto weight_bias = mm->add_parameter("3", {migraphx::shape::int8_type, {1}, {1}}); auto quant = mm->add_instruction(migraphx::make_op("quant_convolution"), data, weight); auto mbcast_data_bias = mm->add_instruction( - migraphx::make_op("multibroadcast", {{"out_lens", weight->get_shape().lens()}}), data_bias); + migraphx::make_op("multibroadcast", {{"out_lens", data->get_shape().lens()}}), data_bias); - auto quant_db_w = + auto quant_mb_w = mm->add_instruction(migraphx::make_op("quant_convolution"), mbcast_data_bias, weight); - auto quant_mb_w = mm->add_instruction( - migraphx::make_op("multibroadcast", {{"out_lens", quant->get_shape().lens()}}), quant_db_w); - quant = mm->add_instruction(migraphx::make_op("sub"), quant, quant_mb_w); auto mbcast_weight_bias = mm->add_instruction( - migraphx::make_op("multibroadcast", {{"out_lens", data->get_shape().lens()}}), weight_bias); + migraphx::make_op("multibroadcast", {{"out_lens", weight->get_shape().lens()}}), weight_bias); - auto quant_d_wb = + auto quant_md_wb = mm->add_instruction(migraphx::make_op("quant_convolution"), data, mbcast_weight_bias); - auto quant_md_wb = mm->add_instruction( - migraphx::make_op("multibroadcast", {{"out_lens", quant->get_shape().lens()}}), quant_d_wb); - quant = mm->add_instruction(migraphx::make_op("sub"), quant, quant_md_wb); - auto bcast_data_bias = mm->add_instruction( - migraphx::make_op("broadcast", {{"out_lens", data->get_shape().lens()}}), data_bias); - auto bcast_weight_bias = mm->add_instruction( - migraphx::make_op("broadcast", {{"out_lens", weight->get_shape().lens()}}), weight_bias); + mbcast_data_bias = mm->add_instruction( + migraphx::make_op("multibroadcast", {{"out_lens", data->get_shape().lens()}}), data_bias); + mbcast_weight_bias = mm->add_instruction( + migraphx::make_op("multibroadcast", {{"out_lens", weight->get_shape().lens()}}), weight_bias); auto bias_quant = mm->add_instruction( - migraphx::make_op("quant_convolution"), bcast_data_bias, bcast_weight_bias); + migraphx::make_op("quant_convolution"), mbcast_data_bias, mbcast_weight_bias); mm->add_instruction(migraphx::make_op("add"), quant, bias_quant); From a017473410ee253e4f1c8c4e14ae78cecef15ba4 Mon Sep 17 00:00:00 2001 From: kahmed10 <15948690+kahmed10@users.noreply.github.com> Date: Thu, 16 Jan 2025 03:30:19 +0000 Subject: [PATCH 05/19] formatting --- src/onnx/parse_convolution.cpp | 10 +++++----- test/onnx/parse/convinteger_dual_bias_test.cpp | 6 ++++-- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/src/onnx/parse_convolution.cpp b/src/onnx/parse_convolution.cpp index 70ae790c01d..ddc08293e30 100644 --- a/src/onnx/parse_convolution.cpp +++ b/src/onnx/parse_convolution.cpp @@ -169,27 +169,27 @@ struct parse_convolution : op_parser // multibroadcast (or broadcast) zero points according to spec // x_zp should be a scalar or literal with one element // w_zp can be either a single element or a 1d tensor with size out_channels - migraphx::operation x_zp_bc = migraphx::make_op("multibroadcast", {{"out_lens", x->get_shape().lens()}}); + migraphx::operation x_zp_bc = + migraphx::make_op("multibroadcast", {{"out_lens", x->get_shape().lens()}}); migraphx::operation w_zp_bc = qparam_broadcast_op(w_zp, weights->get_shape().lens(), 0); if(not is_symmetric_zero_point(x_zp)) { - auto x_zp_mb = info.add_instruction(x_zp_bc, x_zp); + auto x_zp_mb = info.add_instruction(x_zp_bc, x_zp); auto out_zp_1 = info.add_instruction(op, x_zp_mb, weights); ret = info.add_common_op("sub", ret, out_zp_1); } if(not is_symmetric_zero_point(w_zp)) { - auto w_zp_mb = info.add_instruction(w_zp_bc, w_zp); + auto w_zp_mb = info.add_instruction(w_zp_bc, w_zp); auto out_zp_2 = info.add_instruction(op, x, w_zp_mb); ret = info.add_common_op("sub", ret, out_zp_2); } if(not(is_symmetric_zero_point(x_zp)) and not(is_symmetric_zero_point(w_zp))) { - auto x_zp_mb = - info.add_instruction(x_zp_bc, x_zp); + auto x_zp_mb = info.add_instruction(x_zp_bc, x_zp); auto w_zp_mb = info.add_instruction(w_zp_bc, w_zp); auto out_zp_3 = info.add_instruction(op, x_zp_mb, w_zp_mb); diff --git a/test/onnx/parse/convinteger_dual_bias_test.cpp b/test/onnx/parse/convinteger_dual_bias_test.cpp index 1a5a00d9ed5..eb6d3d6dc2a 100644 --- a/test/onnx/parse/convinteger_dual_bias_test.cpp +++ b/test/onnx/parse/convinteger_dual_bias_test.cpp @@ -44,7 +44,8 @@ TEST_CASE(convinteger_dual_bias_test) quant = mm->add_instruction(migraphx::make_op("sub"), quant, quant_mb_w); auto mbcast_weight_bias = mm->add_instruction( - migraphx::make_op("multibroadcast", {{"out_lens", weight->get_shape().lens()}}), weight_bias); + migraphx::make_op("multibroadcast", {{"out_lens", weight->get_shape().lens()}}), + weight_bias); auto quant_md_wb = mm->add_instruction(migraphx::make_op("quant_convolution"), data, mbcast_weight_bias); @@ -54,7 +55,8 @@ TEST_CASE(convinteger_dual_bias_test) mbcast_data_bias = mm->add_instruction( migraphx::make_op("multibroadcast", {{"out_lens", data->get_shape().lens()}}), data_bias); mbcast_weight_bias = mm->add_instruction( - migraphx::make_op("multibroadcast", {{"out_lens", weight->get_shape().lens()}}), weight_bias); + migraphx::make_op("multibroadcast", {{"out_lens", weight->get_shape().lens()}}), + weight_bias); auto bias_quant = mm->add_instruction( migraphx::make_op("quant_convolution"), mbcast_data_bias, mbcast_weight_bias); From ac12de459338fbb67ee06b4d8afa9677fe09fe81 Mon Sep 17 00:00:00 2001 From: kahmed10 <15948690+kahmed10@users.noreply.github.com> Date: Thu, 16 Jan 2025 03:34:33 +0000 Subject: [PATCH 06/19] update onnx file --- test/onnx/convinteger_dual_bias_test.onnx | 4 ++-- test/onnx/gen_onnx.py | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/test/onnx/convinteger_dual_bias_test.onnx b/test/onnx/convinteger_dual_bias_test.onnx index ca303d812fa..d4a7628b775 100644 --- a/test/onnx/convinteger_dual_bias_test.onnx +++ b/test/onnx/convinteger_dual_bias_test.onnx @@ -15,7 +15,7 @@ B  Z 1 - +    @@ -26,7 +26,7 @@ Z Z 3 - + b 4  diff --git a/test/onnx/gen_onnx.py b/test/onnx/gen_onnx.py index 6cea5291419..a061d2dfff4 100644 --- a/test/onnx/gen_onnx.py +++ b/test/onnx/gen_onnx.py @@ -1687,9 +1687,9 @@ def convinteger_bias_test(): @onnx_test() def convinteger_dual_bias_test(): x = helper.make_tensor_value_info('0', TensorProto.INT8, [2, 3, 10, 10]) - y = helper.make_tensor_value_info('1', TensorProto.UINT8, [4, 2, 3, 3]) + y = helper.make_tensor_value_info('1', TensorProto.INT8, [4, 2, 3, 3]) z = helper.make_tensor_value_info('2', TensorProto.INT8, [1]) - w = helper.make_tensor_value_info('3', TensorProto.UINT8, [1]) + w = helper.make_tensor_value_info('3', TensorProto.INT8, [1]) out = helper.make_tensor_value_info('4', TensorProto.INT32, [2, 4, 8, 8]) node = onnx.helper.make_node('ConvInteger', From 276d9d43624937765fd39de9bc0700a3d5e2c60d Mon Sep 17 00:00:00 2001 From: kahmed10 <15948690+kahmed10@users.noreply.github.com> Date: Thu, 16 Jan 2025 03:42:13 +0000 Subject: [PATCH 07/19] cleanup qparam_broadcast_op function --- src/onnx/parse_convolution.cpp | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/onnx/parse_convolution.cpp b/src/onnx/parse_convolution.cpp index ddc08293e30..190c69a0ffe 100644 --- a/src/onnx/parse_convolution.cpp +++ b/src/onnx/parse_convolution.cpp @@ -148,10 +148,7 @@ struct parse_convolution : op_parser { return migraphx::make_op("multibroadcast", {{"out_lens", lens}}); } - else - { - return migraphx::make_op("broadcast", {{"out_lens", lens}, {"axis", axis}}); - } + return migraphx::make_op("broadcast", {{"out_lens", lens}, {"axis", axis}}); } static instruction_ref handle_quant_bias(const operation& op, From 9bf587b38de4bae0cfce32d693acbd9631fe070d Mon Sep 17 00:00:00 2001 From: kahmed10 <15948690+kahmed10@users.noreply.github.com> Date: Thu, 16 Jan 2025 13:11:39 +0000 Subject: [PATCH 08/19] fix test channels and fix simplify_algebra find_inner_broadcasts for layout --- src/simplify_algebra.cpp | 2 ++ test/onnx/convinteger_dual_bias_test.onnx | 2 +- test/onnx/gen_onnx.py | 2 +- test/onnx/parse/convinteger_dual_bias_test.cpp | 2 +- 4 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/simplify_algebra.cpp b/src/simplify_algebra.cpp index 4d3d59a0364..d51dc628fb9 100644 --- a/src/simplify_algebra.cpp +++ b/src/simplify_algebra.cpp @@ -761,6 +761,8 @@ struct find_inner_broadcast void apply(module& m, const match::matcher_result& r) const { auto ins = r.result; + if(ins->get_operator().name() == "layout") + return; const auto& broadcasts = ins->inputs(); if(broadcasts.empty()) return; diff --git a/test/onnx/convinteger_dual_bias_test.onnx b/test/onnx/convinteger_dual_bias_test.onnx index d4a7628b775..4ad76aa8ef5 100644 --- a/test/onnx/convinteger_dual_bias_test.onnx +++ b/test/onnx/convinteger_dual_bias_test.onnx @@ -17,7 +17,7 @@ Z 1   - +  Z 2 diff --git a/test/onnx/gen_onnx.py b/test/onnx/gen_onnx.py index 2d6ecb9edc9..c0db4e43f67 100644 --- a/test/onnx/gen_onnx.py +++ b/test/onnx/gen_onnx.py @@ -1687,7 +1687,7 @@ def convinteger_bias_test(): @onnx_test() def convinteger_dual_bias_test(): x = helper.make_tensor_value_info('0', TensorProto.INT8, [2, 3, 10, 10]) - y = helper.make_tensor_value_info('1', TensorProto.INT8, [4, 2, 3, 3]) + y = helper.make_tensor_value_info('1', TensorProto.INT8, [4, 3, 3, 3]) z = helper.make_tensor_value_info('2', TensorProto.INT8, [1]) w = helper.make_tensor_value_info('3', TensorProto.INT8, [1]) out = helper.make_tensor_value_info('4', TensorProto.INT32, [2, 4, 8, 8]) diff --git a/test/onnx/parse/convinteger_dual_bias_test.cpp b/test/onnx/parse/convinteger_dual_bias_test.cpp index eb6d3d6dc2a..fa554356093 100644 --- a/test/onnx/parse/convinteger_dual_bias_test.cpp +++ b/test/onnx/parse/convinteger_dual_bias_test.cpp @@ -29,7 +29,7 @@ TEST_CASE(convinteger_dual_bias_test) migraphx::program p; auto* mm = p.get_main_module(); auto data = mm->add_parameter("0", {migraphx::shape::int8_type, {2, 3, 10, 10}}); - auto weight = mm->add_parameter("1", {migraphx::shape::int8_type, {4, 2, 3, 3}}); + auto weight = mm->add_parameter("1", {migraphx::shape::int8_type, {4, 3, 3, 3}}); auto data_bias = mm->add_parameter("2", {migraphx::shape::int8_type, {1}, {1}}); auto weight_bias = mm->add_parameter("3", {migraphx::shape::int8_type, {1}, {1}}); From c956ea7371a6a68ec743739f7acba606c99fa10f Mon Sep 17 00:00:00 2001 From: kahmed10 <15948690+kahmed10@users.noreply.github.com> Date: Thu, 16 Jan 2025 15:19:05 +0000 Subject: [PATCH 09/19] update convinteger_bias_test --- test/onnx/convinteger_bias_test.onnx | 6 +++--- test/onnx/gen_onnx.py | 6 +++--- test/onnx/parse/convinteger_bias_test.cpp | 11 ++++------- 3 files changed, 10 insertions(+), 13 deletions(-) diff --git a/test/onnx/convinteger_bias_test.onnx b/test/onnx/convinteger_bias_test.onnx index e7d66aef429..a1dcc4b676a 100644 --- a/test/onnx/convinteger_bias_test.onnx +++ b/test/onnx/convinteger_bias_test.onnx @@ -7,13 +7,13 @@ strides@@ convinteger_bias_testZ 0  - +    Z 1  - +   Z @@ -23,7 +23,7 @@ b 3  -  +  B \ No newline at end of file diff --git a/test/onnx/gen_onnx.py b/test/onnx/gen_onnx.py index c0db4e43f67..2a3b29bc18a 100644 --- a/test/onnx/gen_onnx.py +++ b/test/onnx/gen_onnx.py @@ -1670,10 +1670,10 @@ def convinteger_no_bias_uint8_test(): @onnx_test() def convinteger_bias_test(): - x = helper.make_tensor_value_info('0', TensorProto.INT8, [1, 3, 32, 32]) - y = helper.make_tensor_value_info('1', TensorProto.INT8, [1, 3, 5, 5]) + x = helper.make_tensor_value_info('0', TensorProto.INT8, [2, 3, 32, 32]) + y = helper.make_tensor_value_info('1', TensorProto.INT8, [4, 3, 5, 5]) z = helper.make_tensor_value_info('2', TensorProto.INT8, [1]) - out = helper.make_tensor_value_info('3', TensorProto.INT32, [1, 2, 28, 28]) + out = helper.make_tensor_value_info('3', TensorProto.INT32, [2, 4, 28, 28]) node = onnx.helper.make_node('ConvInteger', inputs=['0', '1', '2'], diff --git a/test/onnx/parse/convinteger_bias_test.cpp b/test/onnx/parse/convinteger_bias_test.cpp index 38d9c42412f..741e784a8cb 100644 --- a/test/onnx/parse/convinteger_bias_test.cpp +++ b/test/onnx/parse/convinteger_bias_test.cpp @@ -28,24 +28,21 @@ TEST_CASE(convinteger_bias_test) { migraphx::program p; auto* mm = p.get_main_module(); - auto data = mm->add_parameter("0", {migraphx::shape::int8_type, {1, 3, 32, 32}}); - auto weights = mm->add_parameter("1", {migraphx::shape::int8_type, {1, 3, 5, 5}}); + auto data = mm->add_parameter("0", {migraphx::shape::int8_type, {2, 3, 32, 32}}); + auto weights = mm->add_parameter("1", {migraphx::shape::int8_type, {4, 3, 5, 5}}); auto data_bias = mm->add_parameter("2", {migraphx::shape::int8_type, {1}, {1}}); mm->add_literal(migraphx::literal{migraphx::shape{data->get_shape().type(), {1}, {0}}, {0}}); auto quant = mm->add_instruction(migraphx::make_op("quant_convolution"), data, weights); auto bcast_data_bias = mm->add_instruction( - migraphx::make_op("multibroadcast", {{"out_lens", weights->get_shape().lens()}}), + migraphx::make_op("multibroadcast", {{"out_lens", data->get_shape().lens()}}), data_bias); auto quant2 = mm->add_instruction(migraphx::make_op("quant_convolution"), bcast_data_bias, weights); - auto bcast_quant2 = mm->add_instruction( - migraphx::make_op("multibroadcast", {{"out_lens", quant->get_shape().lens()}}), quant2); - - mm->add_instruction(migraphx::make_op("sub"), quant, bcast_quant2); + mm->add_instruction(migraphx::make_op("sub"), quant, quant2); auto prog = optimize_onnx("convinteger_bias_test.onnx"); EXPECT(p == prog); From 0d68d629de233950d06c2f81beaaefaa68485265 Mon Sep 17 00:00:00 2001 From: kahmed10 <15948690+kahmed10@users.noreply.github.com> Date: Thu, 16 Jan 2025 15:19:12 +0000 Subject: [PATCH 10/19] formatting --- test/onnx/parse/convinteger_bias_test.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/test/onnx/parse/convinteger_bias_test.cpp b/test/onnx/parse/convinteger_bias_test.cpp index 741e784a8cb..551ec517631 100644 --- a/test/onnx/parse/convinteger_bias_test.cpp +++ b/test/onnx/parse/convinteger_bias_test.cpp @@ -36,8 +36,7 @@ TEST_CASE(convinteger_bias_test) auto quant = mm->add_instruction(migraphx::make_op("quant_convolution"), data, weights); auto bcast_data_bias = mm->add_instruction( - migraphx::make_op("multibroadcast", {{"out_lens", data->get_shape().lens()}}), - data_bias); + migraphx::make_op("multibroadcast", {{"out_lens", data->get_shape().lens()}}), data_bias); auto quant2 = mm->add_instruction(migraphx::make_op("quant_convolution"), bcast_data_bias, weights); From fd0931fbdf041c54b524c270beace3251d479c02 Mon Sep 17 00:00:00 2001 From: kahmed10 <15948690+kahmed10@users.noreply.github.com> Date: Thu, 16 Jan 2025 10:01:04 -0600 Subject: [PATCH 11/19] update license --- src/simplify_algebra.cpp | 2 +- test/onnx/parse/convinteger_bias_test.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/simplify_algebra.cpp b/src/simplify_algebra.cpp index d51dc628fb9..469d1dd50d6 100644 --- a/src/simplify_algebra.cpp +++ b/src/simplify_algebra.cpp @@ -1,7 +1,7 @@ /* * The MIT License (MIT) * - * Copyright (c) 2015-2024 Advanced Micro Devices, Inc. All rights reserved. + * Copyright (c) 2015-2025 Advanced Micro Devices, Inc. All rights reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/test/onnx/parse/convinteger_bias_test.cpp b/test/onnx/parse/convinteger_bias_test.cpp index 551ec517631..22534478b36 100644 --- a/test/onnx/parse/convinteger_bias_test.cpp +++ b/test/onnx/parse/convinteger_bias_test.cpp @@ -1,7 +1,7 @@ /* * The MIT License (MIT) * - * Copyright (c) 2015-2024 Advanced Micro Devices, Inc. All rights reserved. + * Copyright (c) 2015-2025 Advanced Micro Devices, Inc. All rights reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal From ada162564c3148b4b4a9a22a65bbde51d70dade5 Mon Sep 17 00:00:00 2001 From: kahmed10 <15948690+kahmed10@users.noreply.github.com> Date: Fri, 17 Jan 2025 05:23:27 +0000 Subject: [PATCH 12/19] reuse smaller test case for verify --- test/onnx/gen_onnx.py | 17 +++++++++++++++++ .../verify/quant_convolution_dual_bias_test.cpp | 3 ++- 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/test/onnx/gen_onnx.py b/test/onnx/gen_onnx.py index 2a3b29bc18a..880aac4fed0 100644 --- a/test/onnx/gen_onnx.py +++ b/test/onnx/gen_onnx.py @@ -1701,6 +1701,23 @@ def convinteger_dual_bias_test(): return ([node], [x, y, z, w], [out]) +@onnx_test() +def convinteger_dual_bias_simple_test(): + x = helper.make_tensor_value_info('0', TensorProto.INT8, [1, 3, 5, 5]) + y = helper.make_tensor_value_info('1', TensorProto.INT8, [1, 3, 2, 2]) + z = helper.make_tensor_value_info('2', TensorProto.INT8, [1]) + w = helper.make_tensor_value_info('3', TensorProto.INT8, [1]) + out = helper.make_tensor_value_info('4', TensorProto.INT32, [1, 1, 4, 4]) + + node = onnx.helper.make_node('ConvInteger', + inputs=['0', '1', '2', '3'], + outputs=['4'], + dilations=[1, 1], + strides=[1, 1]) + + return ([node], [x, y, z, w], [out]) + + @onnx_test() def convinteger_mismatched_input_types_test(): x = helper.make_tensor_value_info('0', TensorProto.INT8, [1, 3, 32, 32]) diff --git a/test/onnx/verify/quant_convolution_dual_bias_test.cpp b/test/onnx/verify/quant_convolution_dual_bias_test.cpp index 27a9518c4c1..c4c3d125bb7 100644 --- a/test/onnx/verify/quant_convolution_dual_bias_test.cpp +++ b/test/onnx/verify/quant_convolution_dual_bias_test.cpp @@ -28,7 +28,8 @@ TEST_CASE(quant_convolution_dual_zero_bias_test) { - migraphx::program p = read_onnx("convinteger_dual_bias_test.onnx"); + // TODO: use other dual_bias test, verify with other framework once convinteger supported + migraphx::program p = read_onnx("convinteger_dual_bias_simple_test.onnx"); p.compile(migraphx::make_target("ref")); migraphx::shape a{migraphx::shape::int8_type, {1, 3, 5, 5}}; From d90aae0e867c73066aacc1479ba66a314f8ded34 Mon Sep 17 00:00:00 2001 From: kahmed10 <15948690+kahmed10@users.noreply.github.com> Date: Fri, 17 Jan 2025 11:44:06 -0600 Subject: [PATCH 13/19] update license year --- test/onnx/verify/quant_convolution_dual_bias_test.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/onnx/verify/quant_convolution_dual_bias_test.cpp b/test/onnx/verify/quant_convolution_dual_bias_test.cpp index c4c3d125bb7..f2c7652f114 100644 --- a/test/onnx/verify/quant_convolution_dual_bias_test.cpp +++ b/test/onnx/verify/quant_convolution_dual_bias_test.cpp @@ -1,7 +1,7 @@ /* * The MIT License (MIT) * - * Copyright (c) 2015-2024 Advanced Micro Devices, Inc. All rights reserved. + * Copyright (c) 2015-2025 Advanced Micro Devices, Inc. All rights reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal From f388ed2b4c18123f70740e9b820f8fa7942a6930 Mon Sep 17 00:00:00 2001 From: kahmed10 <15948690+kahmed10@users.noreply.github.com> Date: Fri, 17 Jan 2025 11:45:20 -0600 Subject: [PATCH 14/19] add missing onnx file --- .../convinteger_dual_bias_simple_test.onnx | 34 +++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 test/onnx/convinteger_dual_bias_simple_test.onnx diff --git a/test/onnx/convinteger_dual_bias_simple_test.onnx b/test/onnx/convinteger_dual_bias_simple_test.onnx new file mode 100644 index 00000000000..0b7b6329af2 --- /dev/null +++ b/test/onnx/convinteger_dual_bias_simple_test.onnx @@ -0,0 +1,34 @@ + !convinteger_dual_bias_simple_test:à +B +0 +1 +2 +34" ConvInteger* + dilations@@ * +strides@@ !convinteger_dual_bias_simple_testZ +0 + + + + +Z +1 + + + + +Z +2 + + +Z +3 + + +b +4 + + + + +B \ No newline at end of file From 4c3f92e854a9f06e60a313b91f5300b8b8d87cfe Mon Sep 17 00:00:00 2001 From: kahmed10 <15948690+kahmed10@users.noreply.github.com> Date: Fri, 17 Jan 2025 21:29:24 +0000 Subject: [PATCH 15/19] fix filepath --- test/onnx/verify/quant_convolution_dual_bias_test.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/onnx/verify/quant_convolution_dual_bias_test.cpp b/test/onnx/verify/quant_convolution_dual_bias_test.cpp index f2c7652f114..504d088a3e2 100644 --- a/test/onnx/verify/quant_convolution_dual_bias_test.cpp +++ b/test/onnx/verify/quant_convolution_dual_bias_test.cpp @@ -83,7 +83,7 @@ TEST_CASE(quant_convolution_dual_zero_bias_test) TEST_CASE(quant_convolution_dual_non_zero_bias_test) { // github.com/microsoft/onnxruntime/blob/main/docs/ContribOperators.md#com.microsoft.QLinearMul - migraphx::program p = read_onnx("convinteger_dual_bias_test.onnx"); + migraphx::program p = read_onnx("convinteger_dual_bias_simple_test.onnx"); p.compile(migraphx::make_target("ref")); migraphx::shape a{migraphx::shape::int8_type, {1, 3, 5, 5}}; From 3ab07bc062357fdea40d57c4ee653e7ecf96dd72 Mon Sep 17 00:00:00 2001 From: kahmed10 <15948690+kahmed10@users.noreply.github.com> Date: Mon, 20 Jan 2025 21:55:54 +0000 Subject: [PATCH 16/19] update verify_onnx tests --- .../quant_convolution_dual_bias_test.cpp | 56 +++++++++++++------ ...lution_mismatched_input_dual_bias_test.cpp | 53 ++++++++++++------ tools/build_and_test_onnxrt.sh | 2 +- 3 files changed, 76 insertions(+), 35 deletions(-) diff --git a/test/onnx/verify/quant_convolution_dual_bias_test.cpp b/test/onnx/verify/quant_convolution_dual_bias_test.cpp index 504d088a3e2..d05fd8a2318 100644 --- a/test/onnx/verify/quant_convolution_dual_bias_test.cpp +++ b/test/onnx/verify/quant_convolution_dual_bias_test.cpp @@ -24,6 +24,9 @@ #include #include +#include +#include +#include #include TEST_CASE(quant_convolution_dual_zero_bias_test) @@ -114,22 +117,41 @@ TEST_CASE(quant_convolution_dual_non_zero_bias_test) std::vector result_vector; result.visit([&](auto output) { result_vector.assign(output.begin(), output.end()); }); - std::vector gold = {-6088, - 6248, - -6472, - 6632, - 6664, - -8264, - 8520, - -8713, - -3788, - -1446, - 1488, - -1586, - -712, - 745, - -914, - 1019}; + // create the following program to compare: + // conv(x-x_bias,w-w_bias) + // where datatypes for x,w,x_bias,w_bias are int32 + migraphx::program p2; + migraphx::module* mm = p2.get_main_module(); - EXPECT(migraphx::verify::verify_rms_range(result_vector, gold)); + migraphx::shape a_i32{migraphx::shape::int32_type, {1, 3, 5, 5}}; + migraphx::shape b_i32{migraphx::shape::int32_type, {1, 3, 2, 2}}; + + migraphx::shape bias_i32{migraphx::shape::int32_type, {1}, {1}}; + auto x = mm->add_parameter("0", a_i32); + auto weights = mm->add_parameter("1", b_i32); + auto x_bias = mm->add_parameter("2", bias_i32); + auto weights_bias = mm->add_parameter("3", bias_i32); + + auto sub_input = add_common_op(*mm, migraphx::make_op("sub"), {x, x_bias}); + auto sub_weights = add_common_op(*mm, migraphx::make_op("sub"), {weights, weights_bias}); + mm->add_instruction(migraphx::make_op("convolution"), sub_input, sub_weights); + + std::vector data_a_i32(data_a.begin(), data_a.end()); + std::vector data_b_i32(data_b.begin(), data_b.end()); + std::vector data_a_bias_i32 = {10}; + std::vector data_b_bias_i32 = {-2}; + + + migraphx::parameter_map pp2; + pp2["0"] = migraphx::argument(a_i32, data_a_i32.data()); + pp2["1"] = migraphx::argument(b_i32, data_b_i32.data()); + pp2["2"] = migraphx::argument(bias_i32, data_a_bias_i32.data()); + pp2["3"] = migraphx::argument(bias_i32, data_b_bias_i32.data()); + + auto result2 = p2.eval(pp2).back(); + + std::vector result_vector_i32; + result2.visit([&](auto output) { result_vector_i32.assign(output.begin(), output.end()); }); + + EXPECT(migraphx::verify::verify_rms_range(result_vector, result_vector_i32)); } diff --git a/test/onnx/verify/quant_convolution_mismatched_input_dual_bias_test.cpp b/test/onnx/verify/quant_convolution_mismatched_input_dual_bias_test.cpp index 127286001ad..c7968ffcab5 100644 --- a/test/onnx/verify/quant_convolution_mismatched_input_dual_bias_test.cpp +++ b/test/onnx/verify/quant_convolution_mismatched_input_dual_bias_test.cpp @@ -112,22 +112,41 @@ TEST_CASE(quant_convolution_mismatched_inputs_dual_non_zero_bias_test) std::vector result_vector; result.visit([&](auto output) { result_vector.assign(output.begin(), output.end()); }); - std::vector gold = {-6088, - 6248, - -6472, - 6632, - 6664, - -8264, - 8520, - -8713, - -3788, - -1446, - 1488, - -1586, - -712, - 745, - -914, - 1019}; + // create the following program to compare: + // conv(x-x_bias,w-w_bias) + // where datatypes for x,w,x_bias,w_bias are int32 + migraphx::program p2; + migraphx::module* mm = p2.get_main_module(); - EXPECT(migraphx::verify::verify_rms_range(result_vector, gold)); + migraphx::shape a_i32{migraphx::shape::int32_type, {1, 3, 5, 5}}; + migraphx::shape b_i32{migraphx::shape::int32_type, {1, 3, 2, 2}}; + + migraphx::shape bias_i32{migraphx::shape::int32_type, {1}, {1}}; + auto x = mm->add_parameter("0", a_i32); + auto weights = mm->add_parameter("1", b_i32); + auto x_bias = mm->add_parameter("2", bias_i32); + auto weights_bias = mm->add_parameter("3", bias_i32); + + auto sub_input = add_common_op(*mm, migraphx::make_op("sub"), {x, x_bias}); + auto sub_weights = add_common_op(*mm, migraphx::make_op("sub"), {weights, weights_bias}); + mm->add_instruction(migraphx::make_op("convolution"), sub_input, sub_weights); + + std::vector data_a_i32(data_a.begin(), data_a.end()); + std::vector data_b_i32(data_b.begin(), data_b.end()); + std::vector data_a_bias_i32 = {138}; + std::vector data_b_bias_i32 = {-2}; + + + migraphx::parameter_map pp2; + pp2["0"] = migraphx::argument(a_i32, data_a_i32.data()); + pp2["1"] = migraphx::argument(b_i32, data_b_i32.data()); + pp2["2"] = migraphx::argument(bias_i32, data_a_bias_i32.data()); + pp2["3"] = migraphx::argument(bias_i32, data_b_bias_i32.data()); + + auto result2 = p2.eval(pp2).back(); + + std::vector result_vector_i32; + result2.visit([&](auto output) { result_vector_i32.assign(output.begin(), output.end()); }); + + EXPECT(migraphx::verify::verify_rms_range(result_vector, result_vector_i32)); } diff --git a/tools/build_and_test_onnxrt.sh b/tools/build_and_test_onnxrt.sh index 19147c84ddb..fe20b7a42bf 100755 --- a/tools/build_and_test_onnxrt.sh +++ b/tools/build_and_test_onnxrt.sh @@ -31,7 +31,7 @@ pip3 install -r requirements-dev.txt # Add newer cmake to the path export PATH="/opt/cmake/bin:$PATH" export CXXFLAGS="-D__HIP_PLATFORM_AMD__=1 -w" -./build.sh --config Release --cmake_extra_defines CMAKE_HIP_COMPILER=/opt/rocm/llvm/bin/clang++ --update --build --build_wheel --parallel --cmake_extra_defines ONNXRUNTIME_VERSION=$(cat ./VERSION_NUMBER) --skip_tests --rocm_home /opt/rocm --use_migraphx --migraphx_home /opt/rocm --rocm_version=`cat /opt/rocm/.info/version-dev` --allow_running_as_root +./build.sh --config Release --cmake_extra_defines CMAKE_HIP_COMPILER=/opt/rocm/llvm/bin/clang++ --update --build --build_wheel --parallel --cmake_extra_defines ONNXRUNTIME_VERSION=$(cat ./VERSION_NUMBER) --skip_tests --rocm_home /opt/rocm --use_migraphx --use_rocm --migraphx_home /opt/rocm --rocm_version=`cat /opt/rocm/.info/version-dev` --allow_running_as_root cd build/Linux/Release #Add test launcher for onnxrt tests From f5a5f09f00ce423219413482b1396b2477897550 Mon Sep 17 00:00:00 2001 From: kahmed10 <15948690+kahmed10@users.noreply.github.com> Date: Mon, 20 Jan 2025 21:56:05 +0000 Subject: [PATCH 17/19] formatting --- test/onnx/verify/quant_convolution_dual_bias_test.cpp | 9 ++++----- ...quant_convolution_mismatched_input_dual_bias_test.cpp | 9 ++++----- 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/test/onnx/verify/quant_convolution_dual_bias_test.cpp b/test/onnx/verify/quant_convolution_dual_bias_test.cpp index d05fd8a2318..6fa2f409241 100644 --- a/test/onnx/verify/quant_convolution_dual_bias_test.cpp +++ b/test/onnx/verify/quant_convolution_dual_bias_test.cpp @@ -127,12 +127,12 @@ TEST_CASE(quant_convolution_dual_non_zero_bias_test) migraphx::shape b_i32{migraphx::shape::int32_type, {1, 3, 2, 2}}; migraphx::shape bias_i32{migraphx::shape::int32_type, {1}, {1}}; - auto x = mm->add_parameter("0", a_i32); - auto weights = mm->add_parameter("1", b_i32); - auto x_bias = mm->add_parameter("2", bias_i32); + auto x = mm->add_parameter("0", a_i32); + auto weights = mm->add_parameter("1", b_i32); + auto x_bias = mm->add_parameter("2", bias_i32); auto weights_bias = mm->add_parameter("3", bias_i32); - auto sub_input = add_common_op(*mm, migraphx::make_op("sub"), {x, x_bias}); + auto sub_input = add_common_op(*mm, migraphx::make_op("sub"), {x, x_bias}); auto sub_weights = add_common_op(*mm, migraphx::make_op("sub"), {weights, weights_bias}); mm->add_instruction(migraphx::make_op("convolution"), sub_input, sub_weights); @@ -141,7 +141,6 @@ TEST_CASE(quant_convolution_dual_non_zero_bias_test) std::vector data_a_bias_i32 = {10}; std::vector data_b_bias_i32 = {-2}; - migraphx::parameter_map pp2; pp2["0"] = migraphx::argument(a_i32, data_a_i32.data()); pp2["1"] = migraphx::argument(b_i32, data_b_i32.data()); diff --git a/test/onnx/verify/quant_convolution_mismatched_input_dual_bias_test.cpp b/test/onnx/verify/quant_convolution_mismatched_input_dual_bias_test.cpp index c7968ffcab5..baee005d5b6 100644 --- a/test/onnx/verify/quant_convolution_mismatched_input_dual_bias_test.cpp +++ b/test/onnx/verify/quant_convolution_mismatched_input_dual_bias_test.cpp @@ -122,12 +122,12 @@ TEST_CASE(quant_convolution_mismatched_inputs_dual_non_zero_bias_test) migraphx::shape b_i32{migraphx::shape::int32_type, {1, 3, 2, 2}}; migraphx::shape bias_i32{migraphx::shape::int32_type, {1}, {1}}; - auto x = mm->add_parameter("0", a_i32); - auto weights = mm->add_parameter("1", b_i32); - auto x_bias = mm->add_parameter("2", bias_i32); + auto x = mm->add_parameter("0", a_i32); + auto weights = mm->add_parameter("1", b_i32); + auto x_bias = mm->add_parameter("2", bias_i32); auto weights_bias = mm->add_parameter("3", bias_i32); - auto sub_input = add_common_op(*mm, migraphx::make_op("sub"), {x, x_bias}); + auto sub_input = add_common_op(*mm, migraphx::make_op("sub"), {x, x_bias}); auto sub_weights = add_common_op(*mm, migraphx::make_op("sub"), {weights, weights_bias}); mm->add_instruction(migraphx::make_op("convolution"), sub_input, sub_weights); @@ -136,7 +136,6 @@ TEST_CASE(quant_convolution_mismatched_inputs_dual_non_zero_bias_test) std::vector data_a_bias_i32 = {138}; std::vector data_b_bias_i32 = {-2}; - migraphx::parameter_map pp2; pp2["0"] = migraphx::argument(a_i32, data_a_i32.data()); pp2["1"] = migraphx::argument(b_i32, data_b_i32.data()); From 23013aebe84b88554a79e7865962bfc218cde972 Mon Sep 17 00:00:00 2001 From: kahmed10 <15948690+kahmed10@users.noreply.github.com> Date: Mon, 20 Jan 2025 16:07:03 -0600 Subject: [PATCH 18/19] revert build script --- tools/build_and_test_onnxrt.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/build_and_test_onnxrt.sh b/tools/build_and_test_onnxrt.sh index fe20b7a42bf..19147c84ddb 100755 --- a/tools/build_and_test_onnxrt.sh +++ b/tools/build_and_test_onnxrt.sh @@ -31,7 +31,7 @@ pip3 install -r requirements-dev.txt # Add newer cmake to the path export PATH="/opt/cmake/bin:$PATH" export CXXFLAGS="-D__HIP_PLATFORM_AMD__=1 -w" -./build.sh --config Release --cmake_extra_defines CMAKE_HIP_COMPILER=/opt/rocm/llvm/bin/clang++ --update --build --build_wheel --parallel --cmake_extra_defines ONNXRUNTIME_VERSION=$(cat ./VERSION_NUMBER) --skip_tests --rocm_home /opt/rocm --use_migraphx --use_rocm --migraphx_home /opt/rocm --rocm_version=`cat /opt/rocm/.info/version-dev` --allow_running_as_root +./build.sh --config Release --cmake_extra_defines CMAKE_HIP_COMPILER=/opt/rocm/llvm/bin/clang++ --update --build --build_wheel --parallel --cmake_extra_defines ONNXRUNTIME_VERSION=$(cat ./VERSION_NUMBER) --skip_tests --rocm_home /opt/rocm --use_migraphx --migraphx_home /opt/rocm --rocm_version=`cat /opt/rocm/.info/version-dev` --allow_running_as_root cd build/Linux/Release #Add test launcher for onnxrt tests From 314b6ba4fd3915ff9fae93a3e1a83fe980cac8b5 Mon Sep 17 00:00:00 2001 From: kahmed10 <15948690+kahmed10@users.noreply.github.com> Date: Mon, 20 Jan 2025 22:20:10 -0600 Subject: [PATCH 19/19] fix licensing --- .../quant_convolution_mismatched_input_dual_bias_test.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/onnx/verify/quant_convolution_mismatched_input_dual_bias_test.cpp b/test/onnx/verify/quant_convolution_mismatched_input_dual_bias_test.cpp index baee005d5b6..5876fd0d1d4 100644 --- a/test/onnx/verify/quant_convolution_mismatched_input_dual_bias_test.cpp +++ b/test/onnx/verify/quant_convolution_mismatched_input_dual_bias_test.cpp @@ -1,7 +1,7 @@ /* * The MIT License (MIT) * - * Copyright (c) 2015-2024 Advanced Micro Devices, Inc. All rights reserved. + * Copyright (c) 2015-2025 Advanced Micro Devices, Inc. All rights reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal