Unverified Commit 4de838c4 authored by Chris Austen's avatar Chris Austen Committed by GitHub
Browse files

Merge branch 'develop' into ck-integration-tuning

parents 05fbe698 c5d0c5b6
......@@ -12,7 +12,7 @@ on:
rocm_release:
description: ROCm Version
required: true
default: '5.4.2'
default: '5.5'
performance_reports_repo:
description: Repository where performance reports are stored
required: true
......@@ -48,7 +48,7 @@ jobs:
release:
uses: ROCmSoftwarePlatform/migraphx-benchmark/.github/workflows/perf-test.yml@main
with:
rocm_release: ${{ github.event.inputs.rocm_release || '5.4.2' }}
rocm_release: ${{ github.event.inputs.rocm_release || '5.5' }}
result_number: ${{ github.event.inputs.result_number || '10' }}
flags: ${{ github.event.inputs.flags || '-r' }}
performance_reports_repo: ${{ github.event.inputs.performance_reports_repo || 'ROCmSoftwarePlatform/migraphx-reports' }}
......
......@@ -56,12 +56,12 @@ inline std::vector<int64_t> sort_permutation(const Vector& data, Op op)
}
/*!
* Returns the permutation needed to apply to the shape to undo the current permutation
* Returns the inverse permutation that could be applied to undo the inputted permutation
*/
std::vector<int64_t> invert_permutation(const std::vector<int64_t>& permutation);
/*!
* Finds the permutation most likely from a transpose operator that has been applied to the shape.
* Finds the permutation that would make the shape not transposed (refering to shape.transposed())
*/
std::vector<int64_t> find_permutation(const shape& s);
std::vector<int64_t> find_permutation(const std::vector<shape>& shapes);
......
......@@ -156,8 +156,28 @@ struct shape
shape(const std::vector<shape>& subs);
/**
* Creates an output shape with dimensions equal to the input lengths and strides determined
* by the permutation argument such that find_permutation() of the output shape returns the
* inputted permuation.
*
* 2D example:
* parameters:
* l = [2, 3], perm = [1, 0]
* therefore:
* "original" shape = {lens = [3, 2], strides = [2, 1]}
* output_shape = {lens = [2, 3], strides = [1, 2]
*
* 3D example:
* parameters:
* l = [2, 3, 4], perm = [1, 2, 0]
* therefore:
* "original" shape = {lens = [3, 4, 2], strides = [8, 2, 1]}
* output_shape = {lens = [2, 3, 4], strides = [1, 8, 2]}
*/
static shape
from_permutation(type_t t, const std::vector<std::size_t>& l, const std::vector<int64_t>& perm);
type_t type() const;
const std::vector<std::size_t>& lens() const;
const std::vector<std::size_t>& strides() const;
......
......@@ -76,6 +76,8 @@ MIGRAPHX_DECLARE_ENV_VAR(MIGRAPHX_DISABLE_SCHEDULE_PASS)
MIGRAPHX_DECLARE_ENV_VAR(MIGRAPHX_DISABLE_REDUCE_FUSION)
MIGRAPHX_DECLARE_ENV_VAR(MIGRAPHX_ENABLE_NHWC)
MIGRAPHX_DECLARE_ENV_VAR(MIGRAPHX_ENABLE_CK)
MIGRAPHX_DECLARE_ENV_VAR(MIGRAPHX_DISABLE_FAST_GELU)
struct id_pass
{
std::string name() const { return "id"; }
......@@ -123,7 +125,7 @@ std::vector<pass> target::get_passes(migraphx::context& gctx, const compile_opti
inline_module{},
rewrite_pooling{},
dead_code_elimination{},
rewrite_gelu{},
enable_pass(not enabled(MIGRAPHX_DISABLE_FAST_GELU{}), rewrite_gelu{}),
optimize_module{},
enable_pass(enabled(MIGRAPHX_ENABLE_NHWC{}), layout_nhwc{}),
dead_code_elimination{},
......
......@@ -2612,7 +2612,7 @@ def if_else_test_inlined():
else_body = onnx.helper.make_graph([else_mul_node], 'else_body', [],
[else_out])
cond = np.array([0]).astype(np.bool)
cond = np.array([0]).astype(bool)
cond_tensor = helper.make_tensor(name="cond",
data_type=TensorProto.BOOL,
dims=cond.shape,
......@@ -2682,7 +2682,7 @@ def if_then_else_multi_output_shapes_inlined_test():
else_body = onnx.helper.make_graph([else_mul_node, else_sub_node],
'else_body', [], [else_out, else_out2])
cond = np.array([1]).astype(np.bool)
cond = np.array([1]).astype(bool)
cond_tensor = helper.make_tensor(name="cond",
data_type=TensorProto.BOOL,
dims=cond.shape,
......@@ -3117,7 +3117,7 @@ def if_then_test_inlined():
else_body = onnx.helper.make_graph([else_mul_node], 'else_body', [],
[else_out])
cond = np.array([1]).astype(np.bool)
cond = np.array([1]).astype(bool)
cond_tensor = helper.make_tensor(name="cond",
data_type=TensorProto.BOOL,
dims=cond.shape,
......@@ -6902,7 +6902,7 @@ def sum_type_test():
t_bool = helper.make_tensor(name="bool",
data_type=TensorProto.BOOL,
dims=valb.shape,
vals=valb.astype(np.bool))
vals=valb.astype(bool))
val = np.array([1, 1])
t_int8 = helper.make_tensor(name="int8",
......
......@@ -956,4 +956,67 @@ TEST_CASE(test_multi_index)
EXPECT(migraphx::verify_range(s.multi(34), std::vector<size_t>{1, 1, 4}));
}
TEST_CASE(find_permutation_2d_standard)
{
migraphx::shape s = {migraphx::shape::float_type, {2, 3}};
std::vector<int64_t> permutation = {0, 1};
EXPECT(migraphx::find_permutation(s) == permutation);
}
TEST_CASE(find_permutation_2d_transpose)
{
migraphx::shape s = {migraphx::shape::float_type, {2, 3}, {1, 2}};
std::vector<int64_t> permutation = {1, 0};
EXPECT(migraphx::find_permutation(s) == permutation);
}
TEST_CASE(find_permutation_3d)
{
migraphx::shape s = {migraphx::shape::float_type, {2, 3, 4}, {1, 8, 2}};
std::vector<int64_t> permutation = {1, 2, 0};
EXPECT(migraphx::find_permutation(s) == permutation);
}
TEST_CASE(find_permutation_4d)
{
// ori_lens = 2, 3, 4, 5
// ori_strides = 60, 20, 5, 1
// perm = 3, 2, 0, 1
// inv_perm = 2, 3, 1, 0
// out_strides = 5, 1, 20, 60
migraphx::shape s = {migraphx::shape::float_type, {5, 4, 2, 3}, {5, 1, 20, 60}};
std::vector<int64_t> permutation = {3, 2, 0, 1};
EXPECT(migraphx::find_permutation(s) == permutation);
}
TEST_CASE(from_2d_permutation)
{
std::vector<std::size_t> out_lens = {2, 3};
std::vector<int64_t> permutation = {1, 0};
migraphx::shape out_shape =
migraphx::shape::from_permutation(migraphx::shape::float_type, out_lens, permutation);
EXPECT(out_shape.lens() == out_lens);
EXPECT(migraphx::find_permutation(out_shape) == permutation);
}
TEST_CASE(from_3d_permutation)
{
std::vector<std::size_t> out_lens = {2, 3, 4};
std::vector<int64_t> permutation = {1, 2, 0};
migraphx::shape out_shape =
migraphx::shape::from_permutation(migraphx::shape::float_type, out_lens, permutation);
EXPECT(out_shape.lens() == out_lens);
EXPECT(migraphx::find_permutation(out_shape) == permutation);
}
TEST_CASE(from_4d_permutation)
{
std::vector<std::size_t> out_lens = {5, 4, 2, 3};
std::vector<int64_t> permutation = {3, 2, 0, 1};
migraphx::shape out_shape =
migraphx::shape::from_permutation(migraphx::shape::float_type, out_lens, permutation);
EXPECT(out_shape.lens() == out_lens);
EXPECT(migraphx::find_permutation(out_shape) == permutation);
}
int main(int argc, const char* argv[]) { test::run(argc, argv); }
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment