Skip to content

Conversation

gchinora
Copy link
Contributor

During the code review of the op-builder-PRs the demand of creating tests for the op-builders came up.
This is the first PR that covers those op-builders that has already been merged in #4005

@gchinora gchinora requested a review from causten as a code owner August 19, 2025 11:10
"batch axes that are not the outer-most axes, is not implemented",
{3, 3, 3},
{}));
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is missing tests for the valid inputs, are you going to add tests for those?

Copy link
Contributor Author

@gchinora gchinora Aug 21, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've just added a few positive test cases. Pls. let me know if you'd like to see some specific special case that needs to be tested.

*/
#include "test.hpp"

int main(int argc, const char* argv[]) { test::run(argc, argv); }
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this file can be removed as it doesnt have any tests.

Copy link
Contributor Author

@gchinora gchinora Aug 21, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The purpose of this file is equivalent with the main.cpp inside "./test/onnx/parse/" or "./test/onnx/verify". This serves merely for the "test_op_builder_test" binary to have an entry point that launches the test cases.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see the other tests dont have a main function.

@gchinora gchinora requested a review from pfultz2 August 21, 2025 15:50
const migraphx::value& options,
const std::vector<migraphx::instruction_ref>& params)
{
migraphx::module mm_op_built;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Paul! I recall that you've mentioned something about this implementation in the weekly meeting. Could you pls. describe here how would you like to see this to be done?

Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds comprehensive test coverage for op-builders in AMDMIGraphX, implementing tests for operators that were merged in PR #4005. The tests validate both successful operation building and error handling for invalid inputs.

  • Introduces a utility module for testing op-builders with standardized test patterns
  • Implements comprehensive test suites for GEMM, GELU, einsum, CELU, and other op-builders
  • Adds CMake build configuration to compile and run the op-builder tests

Reviewed Changes

Copilot reviewed 10 out of 10 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
test/op/include/op_builder_test_utils.hpp Utility header providing helper functions for testing op-builders
test/op/builder/gemm_test.cpp Test cases for GEMM op-builder with various parameter configurations
test/op/builder/gelu_test.cpp Test cases for GELU variants (quick, erf, tanh, split)
test/op/builder/einsum_test.cpp Extensive test suite for einsum operations covering matrix operations and error cases
test/op/builder/celu_test.cpp Test cases for CELU op-builder including error handling
test/op/builder/batchnorm_test.cpp Test cases for batch normalization op-builder
test/op/builder/mean_variance_normalization_test.cpp Test cases for mean variance normalization
test/op/builder/main.cpp Test runner entry point
test/op/CMakeLists.txt Build configuration for op-builder tests
test/CMakeLists.txt Updated to include op-builder test directory

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Comment on lines +38 to +44
const std::vector<migraphx::instruction_ref>& args{params.rbegin(), params.rend()};
mm_op_built.add_instructions(args);

const auto& params2 = mm_op_built.get_parameters();
const std::vector<migraphx::instruction_ref>& args2{params2.rbegin(), params2.rend()};

migraphx::op::builder::add(op_builder_name, mm_op_built, args2, options);
Copy link
Preview

Copilot AI Sep 3, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] The variable name args is confusing since it represents a reversed copy of params. Consider renaming to reversed_params or adding a comment explaining why the reversal is necessary.

Suggested change
const std::vector<migraphx::instruction_ref>& args{params.rbegin(), params.rend()};
mm_op_built.add_instructions(args);
const auto& params2 = mm_op_built.get_parameters();
const std::vector<migraphx::instruction_ref>& args2{params2.rbegin(), params2.rend()};
migraphx::op::builder::add(op_builder_name, mm_op_built, args2, options);
const std::vector<migraphx::instruction_ref> reversed_params{params.rbegin(), params.rend()};
mm_op_built.add_instructions(reversed_params);
const auto& params2 = mm_op_built.get_parameters();
const std::vector<migraphx::instruction_ref> reversed_params2{params2.rbegin(), params2.rend()};
migraphx::op::builder::add(op_builder_name, mm_op_built, reversed_params2, options);

Copilot uses AI. Check for mistakes.

{
migraphx::module mm;

const auto axes = {2, 2, 2};
Copy link
Preview

Copilot AI Sep 3, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The axes vector contains duplicate values (2, 2, 2) which doesn't match the test comment indicating 'axes attribute needs to be equal to input tensor rank - 1'. For a 4D tensor {2, 2, 2, 2}, this should likely be {1, 2, 3} or similar non-duplicate axis indices.

Suggested change
const auto axes = {2, 2, 2};
const auto axes = {1, 2, 3};

Copilot uses AI. Check for mistakes.

Comment on lines 130 to 133
auto split_left = mm.add_instruction(
migraphx::make_op("slice",
{{"axes", {-1}}, {"starts", {0}}, {"ends", {last_dim_size / 2}}}),
x);
Copy link
Preview

Copilot AI Sep 3, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] The indentation of the migraphx::make_op call is inconsistent. The parameters should be aligned properly within the function call.

Suggested change
auto split_left = mm.add_instruction(
migraphx::make_op("slice",
{{"axes", {-1}}, {"starts", {0}}, {"ends", {last_dim_size / 2}}}),
x);
auto split_left = mm.add_instruction(
migraphx::make_op(
"slice", {{"axes", {-1}}, {"starts", {0}}, {"ends", {last_dim_size / 2}}}),
x);

Copilot uses AI. Check for mistakes.

@TedThemistokleous TedThemistokleous added the roadmap Tasks to finish for a release label Sep 3, 2025
Copy link

codecov bot commented Sep 10, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.

Additional details and impacted files
@@            Coverage Diff            @@
##           develop    #4242    +/-   ##
=========================================
  Coverage    92.23%   92.23%            
=========================================
  Files          555      557     +2     
  Lines        25682    25924   +242     
=========================================
+ Hits         23686    23910   +224     
- Misses        1996     2014    +18     

see 27 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@CharlieL7 CharlieL7 self-requested a review September 17, 2025 13:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
roadmap Tasks to finish for a release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants