From 1de6452a8061180e6be1d96cac2ae9d1b0772e4a Mon Sep 17 00:00:00 2001 From: Ted Themistokleous Date: Fri, 23 Feb 2024 17:06:45 +0000 Subject: [PATCH 1/7] Remove list initialization for prefix_scan_sum This seems to cause an error as seeing in JIRA SWDEV-443633 --- src/targets/gpu/include/migraphx/gpu/prefix_scan_sum.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/targets/gpu/include/migraphx/gpu/prefix_scan_sum.hpp b/src/targets/gpu/include/migraphx/gpu/prefix_scan_sum.hpp index 87a9fa3ec7e..3b31729ac24 100644 --- a/src/targets/gpu/include/migraphx/gpu/prefix_scan_sum.hpp +++ b/src/targets/gpu/include/migraphx/gpu/prefix_scan_sum.hpp @@ -54,7 +54,7 @@ struct hip_prefix_scan_sum : oper shape compute_shape(const std::vector& inputs) const { - std::vector in_shapes{inputs}; + std::vector in_shapes(inputs); in_shapes.pop_back(); check_shapes{in_shapes, *this}.standard(); return op.normalize_compute_shape(in_shapes); From 8dadd8f846d22756eac297eef80ecc7fb0b78a96 Mon Sep 17 00:00:00 2001 From: Ted Themistokleous Date: Tue, 27 Feb 2024 00:33:29 +0000 Subject: [PATCH 2/7] Use explicit construction for shape with vector input of sub shapes Requied to change other parts of the code to handle this. Solves issue we were seeing with clang and our multinomial test. --- src/include/migraphx/builtin.hpp | 4 ++-- src/include/migraphx/op/if_op.hpp | 4 ++-- src/include/migraphx/op/loop.hpp | 4 ++-- src/include/migraphx/op/run_on_target.hpp | 4 ++-- src/include/migraphx/op/topk.hpp | 4 ++-- src/include/migraphx/op/unique.hpp | 4 ++-- src/include/migraphx/shape.hpp | 2 +- src/shape.cpp | 8 +++++--- src/targets/gpu/include/migraphx/gpu/prefix_scan_sum.hpp | 2 +- test/include/basic_ops.hpp | 4 ++-- test/op_shape_test.cpp | 5 +++-- test/run_loop_test.cpp | 4 ++-- 12 files changed, 26 insertions(+), 23 deletions(-) diff --git a/src/include/migraphx/builtin.hpp b/src/include/migraphx/builtin.hpp index bad8f422761..fb5d16c321c 100644 --- a/src/include/migraphx/builtin.hpp +++ b/src/include/migraphx/builtin.hpp @@ -1,7 +1,7 @@ /* * The MIT License (MIT) * - * Copyright (c) 2015-2023 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 @@ -98,7 +98,7 @@ struct returns else if(arg.size() == 1) return arg[0]; else - return arg; + return shape(arg); } argument compute(context&, const shape&, const std::vector&) const diff --git a/src/include/migraphx/op/if_op.hpp b/src/include/migraphx/op/if_op.hpp index ea03a192f83..0b8ae78d8b3 100644 --- a/src/include/migraphx/op/if_op.hpp +++ b/src/include/migraphx/op/if_op.hpp @@ -1,7 +1,7 @@ /* * The MIT License (MIT) * - * Copyright (c) 2015-2023 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 @@ -57,7 +57,7 @@ struct if_op MIGRAPHX_THROW("IF: output shapes of submodules must be the same."); } - return {out_shapes0}; + return shape(out_shapes0); } argument compute(const shape&, diff --git a/src/include/migraphx/op/loop.hpp b/src/include/migraphx/op/loop.hpp index 68e7dd0b420..969c16ef7cd 100644 --- a/src/include/migraphx/op/loop.hpp +++ b/src/include/migraphx/op/loop.hpp @@ -1,7 +1,7 @@ /* * The MIT License (MIT) * - * Copyright (c) 2015-2023 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 @@ -76,7 +76,7 @@ struct loop ins_out_shapes.push_back({out_s.type(), lens}); } - return {ins_out_shapes}; + return shape(ins_out_shapes); } struct ref_loop diff --git a/src/include/migraphx/op/run_on_target.hpp b/src/include/migraphx/op/run_on_target.hpp index 49a496f20ff..560cf4bae7c 100644 --- a/src/include/migraphx/op/run_on_target.hpp +++ b/src/include/migraphx/op/run_on_target.hpp @@ -1,7 +1,7 @@ /* * The MIT License (MIT) * - * Copyright (c) 2015-2023 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 @@ -62,7 +62,7 @@ struct run_on_target MIGRAPHX_THROW("RUN_ON_TARGET: Mismatched number of input parameters"); } auto mod_out_shapes = mod_input->get_output_shapes(); - return mod_out_shapes; + return shape(mod_out_shapes); } migraphx::argument diff --git a/src/include/migraphx/op/topk.hpp b/src/include/migraphx/op/topk.hpp index ad0bee79c5f..863119b82e5 100644 --- a/src/include/migraphx/op/topk.hpp +++ b/src/include/migraphx/op/topk.hpp @@ -1,7 +1,7 @@ /* * The MIT License (MIT) * - * Copyright (c) 2015-2022 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 @@ -69,7 +69,7 @@ struct topk shape s_val{type, lens}; shape s_ind{shape::int64_type, lens}; - return {{s_val, s_ind}}; + return shape({s_val, s_ind}); } template diff --git a/src/include/migraphx/op/unique.hpp b/src/include/migraphx/op/unique.hpp index 5f5efffa0f6..67afbbf09ad 100644 --- a/src/include/migraphx/op/unique.hpp +++ b/src/include/migraphx/op/unique.hpp @@ -1,7 +1,7 @@ /* * The MIT License (MIT) * - * Copyright (c) 2015-2023 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 @@ -239,7 +239,7 @@ struct unique // The three outputted Indices are just 1-D: shape sh_idx{shape::int64_type, {d_out[0]}}; - return {{sh_y, sh_idx, sh_idx, sh_idx}}; + return shape({sh_y, sh_idx, sh_idx, sh_idx}); } argument compute(const dyn_output& dyn_out, std::vector args) const diff --git a/src/include/migraphx/shape.hpp b/src/include/migraphx/shape.hpp index c5c17dbfb96..9c8776fbe96 100644 --- a/src/include/migraphx/shape.hpp +++ b/src/include/migraphx/shape.hpp @@ -169,7 +169,7 @@ struct MIGRAPHX_EXPORT shape { } - shape(const std::vector& subs); + explicit shape(const std::vector& subs); /** * Creates an output shape with dimensions equal to the input lengths and strides determined diff --git a/src/shape.cpp b/src/shape.cpp index 62222949935..a24fe86a6e5 100644 --- a/src/shape.cpp +++ b/src/shape.cpp @@ -95,7 +95,9 @@ struct shape_impl } } - shape_impl(const std::vector& subs) : m_type(shape::tuple_type), m_shapes(subs) {} + explicit shape_impl(const std::vector& subs) : m_type(shape::tuple_type), m_shapes(subs) + { + } shape::type_t m_type; std::vector m_lens = {}; @@ -530,7 +532,7 @@ shape shape::to_dynamic() const sub_shapes().cend(), std::back_inserter(subs), [](auto s) { return s.to_dynamic(); }); - return {subs}; + return shape(subs); } if(this->dynamic()) { @@ -548,7 +550,7 @@ shape shape::to_static(std::size_t x) const sub_shapes().cend(), std::back_inserter(subs), [&](auto s) { return s.to_static(x); }); - return {subs}; + return shape(subs); } if(not this->dynamic()) { diff --git a/src/targets/gpu/include/migraphx/gpu/prefix_scan_sum.hpp b/src/targets/gpu/include/migraphx/gpu/prefix_scan_sum.hpp index 3b31729ac24..67d230f9a93 100644 --- a/src/targets/gpu/include/migraphx/gpu/prefix_scan_sum.hpp +++ b/src/targets/gpu/include/migraphx/gpu/prefix_scan_sum.hpp @@ -1,7 +1,7 @@ /* * The MIT License (MIT) * - * Copyright (c) 2015-2023 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 diff --git a/test/include/basic_ops.hpp b/test/include/basic_ops.hpp index bf6807afbb1..3c5c9d37cc4 100644 --- a/test/include/basic_ops.hpp +++ b/test/include/basic_ops.hpp @@ -1,7 +1,7 @@ /* * The MIT License (MIT) * - * Copyright (c) 2015-2023 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 @@ -208,7 +208,7 @@ struct tuple_op std::string name() const { return "tuple_op"; } migraphx::shape compute_shape(const std::vector& inputs) const { - return {inputs}; + return migraphx::shape(inputs); } migraphx::argument compute(migraphx::context&, const migraphx::shape&, diff --git a/test/op_shape_test.cpp b/test/op_shape_test.cpp index 39cd2ab7f89..369f8ad21ea 100644 --- a/test/op_shape_test.cpp +++ b/test/op_shape_test.cpp @@ -4425,7 +4425,8 @@ TEST_CASE(test_unique_axis_negative) {migraphx::shape::int64_type, idx_dims}, {migraphx::shape::int64_type, idx_dims}}; - expect_shape(y_dyn_shape, migraphx::make_op("unique", {{"axis", -3}}), x_shape); + expect_shape( + migraphx::shape(y_dyn_shape), migraphx::make_op("unique", {{"axis", -3}}), x_shape); } TEST_CASE(test_unique_axis_none) @@ -4439,7 +4440,7 @@ TEST_CASE(test_unique_axis_none) {migraphx::shape::int64_type, idx_dims}, {migraphx::shape::int64_type, idx_dims}}; - expect_shape(y_dyn_shape, migraphx::make_op("unique"), x_shape); + expect_shape(migraphx::shape(y_dyn_shape), migraphx::make_op("unique"), x_shape); } TEST_CASE(test_unsqueeze) diff --git a/test/run_loop_test.cpp b/test/run_loop_test.cpp index 04923921fb0..7c1f148c17e 100644 --- a/test/run_loop_test.cpp +++ b/test/run_loop_test.cpp @@ -1,7 +1,7 @@ /* * The MIT License (MIT) * - * Copyright (c) 2015-2023 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 @@ -98,7 +98,7 @@ struct test_loop_op ins_out_shapes.push_back({out_s.type(), lens}); } - return {ins_out_shapes}; + return migraphx::shape(ins_out_shapes); } struct test_loop : public migraphx::op::loop::ref_loop From 46c2f0b59d73e0186abe1eb0250367e1b8ddb9b5 Mon Sep 17 00:00:00 2001 From: Ted Themistokleous Date: Tue, 27 Feb 2024 03:03:45 +0000 Subject: [PATCH 3/7] remove explicit on private class ctor --- src/shape.cpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/shape.cpp b/src/shape.cpp index a24fe86a6e5..79294debcb1 100644 --- a/src/shape.cpp +++ b/src/shape.cpp @@ -95,9 +95,7 @@ struct shape_impl } } - explicit shape_impl(const std::vector& subs) : m_type(shape::tuple_type), m_shapes(subs) - { - } + shape_impl(const std::vector& subs) : m_type(shape::tuple_type), m_shapes(subs) {} shape::type_t m_type; std::vector m_lens = {}; From 433fd5803cbeda0fa9cde0b8dc0fd9e743ae4d94 Mon Sep 17 00:00:00 2001 From: Ted Themistokleous Date: Tue, 27 Feb 2024 18:16:02 +0000 Subject: [PATCH 4/7] Move back to braced construction for vec of shapes in prefix_scan_sum compute_shape() --- src/targets/gpu/include/migraphx/gpu/prefix_scan_sum.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/targets/gpu/include/migraphx/gpu/prefix_scan_sum.hpp b/src/targets/gpu/include/migraphx/gpu/prefix_scan_sum.hpp index 67d230f9a93..cca8efd6057 100644 --- a/src/targets/gpu/include/migraphx/gpu/prefix_scan_sum.hpp +++ b/src/targets/gpu/include/migraphx/gpu/prefix_scan_sum.hpp @@ -54,7 +54,7 @@ struct hip_prefix_scan_sum : oper shape compute_shape(const std::vector& inputs) const { - std::vector in_shapes(inputs); + std::vector in_shapes{inputs}; in_shapes.pop_back(); check_shapes{in_shapes, *this}.standard(); return op.normalize_compute_shape(in_shapes); From 2e3f19d7bf31a5354cbd02018b9b36502900c72b Mon Sep 17 00:00:00 2001 From: Ted Themistokleous Date: Tue, 27 Feb 2024 19:29:45 +0000 Subject: [PATCH 5/7] Update license for type_traits.hpp --- src/include/migraphx/type_traits.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/include/migraphx/type_traits.hpp b/src/include/migraphx/type_traits.hpp index 58a50f87966..209b57c8b52 100644 --- a/src/include/migraphx/type_traits.hpp +++ b/src/include/migraphx/type_traits.hpp @@ -1,7 +1,7 @@ /* * The MIT License (MIT) * -* Copyright (c) 2015-2023 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 From 1050fdca5375468b9956918d7533b61bd5743278 Mon Sep 17 00:00:00 2001 From: Ted Themistokleous Date: Thu, 7 Mar 2024 00:36:52 +0000 Subject: [PATCH 6/7] Update vitis_ai_adapter with explicit shape() constructor --- src/targets/fpga/vitis_ai_adapter.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/targets/fpga/vitis_ai_adapter.cpp b/src/targets/fpga/vitis_ai_adapter.cpp index 1b29d17af1d..19457587e4c 100644 --- a/src/targets/fpga/vitis_ai_adapter.cpp +++ b/src/targets/fpga/vitis_ai_adapter.cpp @@ -37,7 +37,7 @@ x_model create_xmodel(migraphx::const_module_ref mod) { std::cout << "Calling an external function: create_xmodel!\n"; x_model xmodel; - xmodel.set_shape(mod->get_output_shapes()); + xmodel.set_shape(migraphx::shape(mod->get_output_shapes())); return xmodel; } From 718175e9bfaf6880597e0c3ec831b471f4ad0c23 Mon Sep 17 00:00:00 2001 From: Ted Themistokleous Date: Thu, 7 Mar 2024 00:45:05 +0000 Subject: [PATCH 7/7] Update license for vitis_ai_adapter.cpp --- src/targets/fpga/vitis_ai_adapter.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/targets/fpga/vitis_ai_adapter.cpp b/src/targets/fpga/vitis_ai_adapter.cpp index 19457587e4c..fa4ecdc680a 100644 --- a/src/targets/fpga/vitis_ai_adapter.cpp +++ b/src/targets/fpga/vitis_ai_adapter.cpp @@ -1,7 +1,7 @@ /* * The MIT License (MIT) * - * Copyright (c) 2015-2023 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