Skip to content

Commit

Permalink
use random mode for benchmarking gemm and convs
Browse files Browse the repository at this point in the history
  • Loading branch information
umangyadav committed Aug 15, 2024
1 parent 9c26b87 commit 5ca7bf3
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 8 deletions.
12 changes: 8 additions & 4 deletions src/targets/gpu/gemm_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -311,11 +311,13 @@ struct gemm_impl
{
// Create dummy arguments for the shapes, and call the overloaded method
std::vector<argument> input_args;
unsigned long seed = 0;
std::transform(input_shapes.begin(),
input_shapes.end(),
std::back_inserter(input_args),
[](const shape& x) { return to_gpu(generate_argument(x)); });

[&](const shape& x) {
return to_gpu(generate_argument(x, seed++, random_mode::random));
});
return validate(ctx, input_args, solution_idx);
}

Expand Down Expand Up @@ -448,12 +450,14 @@ struct gemm_impl
{
// tuning meta parameters
const int hot_calls = 40;

unsigned long seed = 0;
std::vector<argument> input_args;
std::transform(input_shapes.begin(),
input_shapes.end(),
std::back_inserter(input_args),
[](const shape& x) { return to_gpu(generate_argument(x)); });
[&](const shape& x) {
return to_gpu(generate_argument(x, seed++, random_mode::random));
});

// Get the solutions list in 2 rocBLAS steps:
// 1. Find out how many solutions there are and allocate the array
Expand Down
11 changes: 7 additions & 4 deletions src/targets/gpu/include/migraphx/gpu/convolution.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,7 @@ struct miopen_convolution
const auto& x_shape = inputs[0];
const auto& w_shape = inputs[1];

unsigned long seed = 0;
#ifdef MIGRAPHX_HAS_FIND_2_API
{
auto conv_problem = make_obj<miopen_problem>(
Expand All @@ -192,8 +193,10 @@ struct miopen_convolution
// MIOpen has APIs to pass pre-allocated buffers starting from rocm-5.6
preallocate = true;
#endif
auto x = preallocate ? to_gpu(generate_argument(x_shape)) : argument{inputs[0]};
auto w = preallocate ? to_gpu(generate_argument(w_shape)) : argument{inputs[1]};
auto x = preallocate ? to_gpu(generate_argument(x_shape, seed++, random_mode::random))
: argument{inputs[0]};
auto w = preallocate ? to_gpu(generate_argument(w_shape, seed++, random_mode::random))
: argument{inputs[1]};
auto y = preallocate ? allocate_gpu(output_shape) : argument{inputs[2]};
auto workspace =
preallocate ? allocate_gpu(workspace_shape) : migraphx::argument(workspace_shape);
Expand Down Expand Up @@ -233,8 +236,8 @@ struct miopen_convolution
return shape{shape::int8_type, {workspace_size}};
}
#else
auto x = to_gpu(generate_argument(x_shape));
auto w = to_gpu(generate_argument(w_shape));
auto x = to_gpu(generate_argument(x_shape, seed++, random_mode::random));
auto w = to_gpu(generate_argument(w_shape, seed++, random_mode::random));
auto y = allocate_gpu(output_shape);
auto workspace = allocate_gpu(workspace_shape);
int algo_count = 1;
Expand Down

0 comments on commit 5ca7bf3

Please sign in to comment.