From f5c6c16c44161fdfb0c1177dd2f70dcbc29b3150 Mon Sep 17 00:00:00 2001 From: Your Name Date: Wed, 18 Dec 2024 16:02:45 -0500 Subject: [PATCH 1/4] Enable cpp core guidlines checks. --- CMakeLists.txt | 1 - 1 file changed, 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index e00ad7010e1..ac9f39868c4 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -208,7 +208,6 @@ rocm_enable_clang_tidy( -clang-diagnostic-disabled-macro-expansion -clang-diagnostic-extern-c-compat -clang-diagnostic-unused-command-line-argument - -cppcoreguidelines-avoid-capture-default-when-capturing-this -cppcoreguidelines-avoid-const-or-ref-data-members -cppcoreguidelines-avoid-do-while -cppcoreguidelines-explicit-virtual-functions From 06659187a5bc0593a505f667fcee3b4e4f600a88 Mon Sep 17 00:00:00 2001 From: Your Name Date: Fri, 20 Dec 2024 17:09:21 -0500 Subject: [PATCH 2/4] Enable cppcoreguidelines-rvalue-reference-param-not-moved check --- CMakeLists.txt | 1 - src/program.cpp | 9 +++++---- test/ref/add.cpp | 3 ++- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index ac9f39868c4..8291f5a3a6b 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -221,7 +221,6 @@ rocm_enable_clang_tidy( -cppcoreguidelines-pro-type-reinterpret-cast -cppcoreguidelines-pro-type-union-access -cppcoreguidelines-pro-type-vararg - -cppcoreguidelines-rvalue-reference-param-not-moved -cppcoreguidelines-special-member-functions -cppcoreguidelines-use-default-member-init -cppcoreguidelines-virtual-class-destructor diff --git a/src/program.cpp b/src/program.cpp index 2d43f3f8d55..dd21cad557d 100644 --- a/src/program.cpp +++ b/src/program.cpp @@ -894,15 +894,16 @@ void program::mark(const parameter_map& params, marker&& m) eval(params); this->finish(); // Start marking - m.mark_start(*this); + auto moved_marker = std::move(m); + moved_marker.mark_start(*this); generic_eval(*this, ctx, params, [&](auto ins, auto f) { argument result; - m.mark_start(ins); + moved_marker.mark_start(ins); result = f(); - m.mark_stop(ins); + moved_marker.mark_stop(ins); return result; }); - m.mark_stop(*this); + moved_marker.mark_stop(*this); } void program::perf_report( diff --git a/test/ref/add.cpp b/test/ref/add.cpp index 525e74dfa11..01fe6f2a9c3 100644 --- a/test/ref/add.cpp +++ b/test/ref/add.cpp @@ -171,9 +171,10 @@ TEST_CASE(fp32_fp16_test) }; auto test_case = [&](std::vector&& op_names) { + auto local_op_names = std::move(op_names); std::vector gold_res = {2.0, 4.0, 6.0, 8.0, 10.0, 12.0}; auto p = create_program(); - migraphx::quantize_fp16(p, op_names); + migraphx::quantize_fp16(p, local_op_names); p.compile(migraphx::make_target("ref")); auto result = p.eval({}).back(); std::vector res; From 450216550f8e43a3b639d43dc853cf7f7a01daee Mon Sep 17 00:00:00 2001 From: Your Name Date: Fri, 20 Dec 2024 17:27:12 -0500 Subject: [PATCH 3/4] Fix format --- test/ref/add.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/ref/add.cpp b/test/ref/add.cpp index 01fe6f2a9c3..4ae73466847 100644 --- a/test/ref/add.cpp +++ b/test/ref/add.cpp @@ -171,7 +171,7 @@ TEST_CASE(fp32_fp16_test) }; auto test_case = [&](std::vector&& op_names) { - auto local_op_names = std::move(op_names); + auto local_op_names = std::move(op_names); std::vector gold_res = {2.0, 4.0, 6.0, 8.0, 10.0, 12.0}; auto p = create_program(); migraphx::quantize_fp16(p, local_op_names); From 4ccbb4f9bb87945e7ad8518471c3865dc8cd9385 Mon Sep 17 00:00:00 2001 From: Your Name Date: Mon, 30 Dec 2024 17:37:22 -0500 Subject: [PATCH 4/4] Resolve comments --- src/include/migraphx/program.hpp | 2 +- src/program.cpp | 12 +++++------- test/ref/add.cpp | 5 ++--- 3 files changed, 8 insertions(+), 11 deletions(-) diff --git a/src/include/migraphx/program.hpp b/src/include/migraphx/program.hpp index 87de258a44b..2a82f381c21 100644 --- a/src/include/migraphx/program.hpp +++ b/src/include/migraphx/program.hpp @@ -112,7 +112,7 @@ struct MIGRAPHX_EXPORT program std::size_t batch = 1, bool detailed = false) const; - void mark(const parameter_map& params, marker&& m); + void mark(const parameter_map& params, marker m); value to_value() const; void from_value(const value& v); diff --git a/src/program.cpp b/src/program.cpp index dd21cad557d..5cfb62baf39 100644 --- a/src/program.cpp +++ b/src/program.cpp @@ -887,23 +887,21 @@ std::string perf_group(instruction_ref ins, bool detailed) return result; } -void program::mark(const parameter_map& params, marker&& m) +void program::mark(const parameter_map& params, marker m) { auto& ctx = this->impl->contexts; // Run once by itself eval(params); this->finish(); - // Start marking - auto moved_marker = std::move(m); - moved_marker.mark_start(*this); + m.mark_start(*this); generic_eval(*this, ctx, params, [&](auto ins, auto f) { argument result; - moved_marker.mark_start(ins); + m.mark_start(ins); result = f(); - moved_marker.mark_stop(ins); + m.mark_stop(ins); return result; }); - moved_marker.mark_stop(*this); + m.mark_stop(*this); } void program::perf_report( diff --git a/test/ref/add.cpp b/test/ref/add.cpp index 4ae73466847..148e9b5b08a 100644 --- a/test/ref/add.cpp +++ b/test/ref/add.cpp @@ -170,11 +170,10 @@ TEST_CASE(fp32_fp16_test) return p; }; - auto test_case = [&](std::vector&& op_names) { - auto local_op_names = std::move(op_names); + auto test_case = [&](const std::vector& op_names) { std::vector gold_res = {2.0, 4.0, 6.0, 8.0, 10.0, 12.0}; auto p = create_program(); - migraphx::quantize_fp16(p, local_op_names); + migraphx::quantize_fp16(p, op_names); p.compile(migraphx::make_target("ref")); auto result = p.eval({}).back(); std::vector res;