Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
gaoqiong
MIGraphX
Commits
51c34a3b
Commit
51c34a3b
authored
Jan 31, 2023
by
Alan Turner
Browse files
Merge remote-tracking branch 'origin/develop' into ck-gsg
parents
e3d0c287
fd412736
Changes
46
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
243 additions
and
2 deletions
+243
-2
test/onnx/trilu_row_one_test.onnx
test/onnx/trilu_row_one_test.onnx
+13
-0
test/onnx/trilu_test.onnx
test/onnx/trilu_test.onnx
+13
-0
test/onnx/verify_onnx.cpp
test/onnx/verify_onnx.cpp
+69
-0
test/op_shape_test.cpp
test/op_shape_test.cpp
+71
-0
test/ref_ops_test.cpp
test/ref_ops_test.cpp
+72
-0
tools/build_and_test_onnxrt.sh
tools/build_and_test_onnxrt.sh
+5
-2
No files found.
test/onnx/trilu_row_one_test.onnx
0 → 100644
View file @
51c34a3b
trilu_row_one_test:\
x
ky"Trilutrilu_row_one_test*
:BkZ
x
b
y
B
\ No newline at end of file
test/onnx/trilu_test.onnx
0 → 100644
View file @
51c34a3b
trilu_test:E
xy"Trilu
trilu_testZ
x
b
y
B
\ No newline at end of file
test/onnx/verify_onnx.cpp
View file @
51c34a3b
...
...
@@ -1458,4 +1458,73 @@ TEST_CASE(where_test)
EXPECT
(
migraphx
::
verify_range
(
result_vector
,
gold
));
}
std
::
vector
<
float
>
gen_trilu_test
(
const
migraphx
::
shape
&
s
,
const
migraphx
::
program
&
p
)
{
// input data filled with values 1 to nelements
std
::
vector
<
float
>
x_data
(
s
.
elements
());
std
::
iota
(
x_data
.
begin
(),
x_data
.
end
(),
1
);
migraphx
::
parameter_map
pp
;
pp
[
"x"
]
=
migraphx
::
argument
(
s
,
x_data
.
data
());
auto
result
=
p
.
eval
(
pp
).
back
();
std
::
vector
<
float
>
result_vector
;
result
.
visit
([
&
](
auto
output
)
{
result_vector
.
assign
(
output
.
begin
(),
output
.
end
());
});
return
result_vector
;
}
TEST_CASE
(
trilu_test
)
{
migraphx
::
program
p
=
migraphx
::
parse_onnx
(
"trilu_test.onnx"
);
std
::
vector
<
float
>
result_vector
=
gen_trilu_test
({
migraphx
::
shape
::
float_type
,
{
3
,
4
}},
p
);
std
::
vector
<
float
>
gold
=
{
1
,
2
,
3
,
4
,
0
,
6
,
7
,
8
,
0
,
0
,
11
,
12
};
EXPECT
(
migraphx
::
verify_range
(
result_vector
,
gold
));
}
TEST_CASE
(
trilu_batch_diff_k_test
)
{
migraphx
::
program
p
=
migraphx
::
parse_onnx
(
"trilu_batch_diff_k_test.onnx"
);
std
::
vector
<
float
>
result_vector
=
gen_trilu_test
({
migraphx
::
shape
::
float_type
,
{
2
,
2
,
3
}},
p
);
std
::
vector
<
float
>
gold
=
{
0
,
0
,
3
,
0
,
0
,
0
,
0
,
0
,
9
,
0
,
0
,
0
};
EXPECT
(
migraphx
::
verify_range
(
result_vector
,
gold
));
}
TEST_CASE
(
trilu_lower_test
)
{
migraphx
::
program
p
=
migraphx
::
parse_onnx
(
"trilu_lower_test.onnx"
);
std
::
vector
<
float
>
result_vector
=
gen_trilu_test
({
migraphx
::
shape
::
float_type
,
{
3
,
4
}},
p
);
std
::
vector
<
float
>
gold
=
{
0
,
0
,
0
,
0
,
5
,
0
,
0
,
0
,
9
,
10
,
0
,
0
};
EXPECT
(
migraphx
::
verify_range
(
result_vector
,
gold
));
}
TEST_CASE
(
trilu_out_k_test
)
{
migraphx
::
program
p
=
migraphx
::
parse_onnx
(
"trilu_out_k_test.onnx"
);
std
::
vector
<
float
>
result_vector
=
gen_trilu_test
({
migraphx
::
shape
::
float_type
,
{
3
,
4
}},
p
);
std
::
vector
<
float
>
gold
(
12
,
0
);
EXPECT
(
migraphx
::
verify_range
(
result_vector
,
gold
));
}
TEST_CASE
(
trilu_row_one_test
)
{
migraphx
::
program
p
=
migraphx
::
parse_onnx
(
"trilu_row_one_test.onnx"
);
std
::
vector
<
float
>
result_vector
=
gen_trilu_test
({
migraphx
::
shape
::
float_type
,
{
1
,
4
}},
p
);
std
::
vector
<
float
>
gold
=
{
0
,
2
,
3
,
4
};
EXPECT
(
migraphx
::
verify_range
(
result_vector
,
gold
));
}
int
main
(
int
argc
,
const
char
*
argv
[])
{
test
::
run
(
argc
,
argv
);
}
test/op_shape_test.cpp
View file @
51c34a3b
...
...
@@ -831,6 +831,77 @@ TEST_CASE(gather)
}
}
TEST_CASE
(
gather_dyn0
)
{
// Insert dynamic index into dynamic shape
migraphx
::
shape
input
{
migraphx
::
shape
::
float_type
,
{{
2
,
3
,
2
},
{
3
,
4
,
3
},
{
6
,
9
,
7
},
{
12
,
14
,
13
}}};
migraphx
::
shape
indices
{
migraphx
::
shape
::
int32_type
,
{{
2
,
7
,
3
},
{
3
,
3
,
0
}}};
int
axis
=
1
;
expect_shape
(
migraphx
::
shape
{
migraphx
::
shape
::
float_type
,
{{
2
,
3
,
2
},
{
2
,
7
,
3
},
{
3
,
3
,
0
},
{
6
,
9
,
7
},
{
12
,
14
,
13
}}},
migraphx
::
make_op
(
"gather"
,
{{
"axis"
,
axis
}}),
input
,
indices
);
}
TEST_CASE
(
gather_dyn1
)
{
// Insert static index into dynamic shape
migraphx
::
shape
input
{
migraphx
::
shape
::
float_type
,
{{
2
,
3
,
2
},
{
3
,
4
,
3
},
{
6
,
9
,
7
},
{
12
,
14
,
13
}}};
migraphx
::
shape
indices
{
migraphx
::
shape
::
int32_type
,
{
2
,
3
}};
int
axis
=
1
;
expect_shape
(
migraphx
::
shape
{
migraphx
::
shape
::
float_type
,
{{
2
,
3
,
2
},
{
2
,
2
,
0
},
{
3
,
3
,
0
},
{
6
,
9
,
7
},
{
12
,
14
,
13
}}},
migraphx
::
make_op
(
"gather"
,
{{
"axis"
,
axis
}}),
input
,
indices
);
}
TEST_CASE
(
gather_dyn2
)
{
// Insert scalar (static) index into dynamic shape
migraphx
::
shape
input
{
migraphx
::
shape
::
float_type
,
{{
2
,
3
,
2
},
{
3
,
4
,
3
},
{
6
,
9
,
7
},
{
12
,
14
,
13
}}};
std
::
vector
<
std
::
size_t
>
mins
;
std
::
vector
<
std
::
size_t
>
maxes
;
std
::
vector
<
std
::
size_t
>
opts
;
migraphx
::
shape
indices
{
migraphx
::
shape
::
int32_type
,
mins
,
maxes
,
opts
};
int
axis
=
1
;
expect_shape
(
migraphx
::
shape
{
migraphx
::
shape
::
float_type
,
{{
2
,
3
,
2
},
{
6
,
9
,
7
},
{
12
,
14
,
13
}}},
migraphx
::
make_op
(
"gather"
,
{{
"axis"
,
axis
}}),
input
,
indices
);
}
TEST_CASE
(
gather_dyn3
)
{
// Insert dynamic index into static shape, axis 1
migraphx
::
shape
input
{
migraphx
::
shape
::
float_type
,
{
2
,
3
,
6
,
12
}};
migraphx
::
shape
indices
{
migraphx
::
shape
::
int32_type
,
{{
2
,
3
,
2
},
{
3
,
4
,
3
}}};
int
axis
=
1
;
expect_shape
(
migraphx
::
shape
{
migraphx
::
shape
::
float_type
,
{{
2
,
2
,
0
},
{
2
,
3
,
2
},
{
3
,
4
,
3
},
{
6
,
6
,
0
},
{
12
,
12
,
0
}}},
migraphx
::
make_op
(
"gather"
,
{{
"axis"
,
axis
}}),
input
,
indices
);
}
TEST_CASE
(
gather_dyn4
)
{
// Insert dynamic index into static shape, axis 0
migraphx
::
shape
input
{
migraphx
::
shape
::
float_type
,
{
2
,
3
,
6
,
12
}};
migraphx
::
shape
indices
{
migraphx
::
shape
::
int32_type
,
{{
2
,
3
,
2
},
{
3
,
4
,
3
}}};
int
axis
=
0
;
expect_shape
(
migraphx
::
shape
{
migraphx
::
shape
::
float_type
,
{{
2
,
3
,
2
},
{
3
,
4
,
3
},
{
3
,
3
,
0
},
{
6
,
6
,
0
},
{
12
,
12
,
0
}}},
migraphx
::
make_op
(
"gather"
,
{{
"axis"
,
axis
}}),
input
,
indices
);
}
TEST_CASE
(
get_tuple_elem_test
)
{
migraphx
::
shape
s0
{
migraphx
::
shape
::
bool_type
,
{
1
,
1
}};
...
...
test/ref_ops_test.cpp
View file @
51c34a3b
...
...
@@ -2524,6 +2524,78 @@ TEST_CASE(gather_test)
}
}
TEST_CASE
(
gather_dyn_test0
)
{
// Dynamic data, static indices
migraphx
::
program
p
;
auto
*
mm
=
p
.
get_main_module
();
migraphx
::
shape
s
{
migraphx
::
shape
::
int32_type
,
{{
2
,
5
,
0
},
{
3
,
3
,
0
}}};
auto
x
=
mm
->
add_parameter
(
"x"
,
s
);
std
::
vector
<
int
>
indices
{
1
,
2
};
migraphx
::
shape
s_ind
{
migraphx
::
shape
::
int32_type
,
{
1
,
2
}};
auto
ind
=
mm
->
add_parameter
(
"indices"
,
s_ind
);
mm
->
add_instruction
(
migraphx
::
make_op
(
"gather"
,
{{
"axis"
,
1
}}),
x
,
ind
);
migraphx
::
shape
sresult
{
migraphx
::
shape
::
int32_type
,
{{
2
,
5
,
0
},
{
1
,
1
,
0
},
{
2
,
2
,
0
}}};
EXPECT
(
p
.
get_output_shapes
().
back
()
==
sresult
);
p
.
compile
(
migraphx
::
ref
::
target
{});
migraphx
::
shape
input_fixed_shape
{
migraphx
::
shape
::
int32_type
,
{
2
,
3
}};
migraphx
::
shape
input_indices
{
migraphx
::
shape
::
int32_type
,
{
1
,
2
}};
migraphx
::
parameter_map
params
;
std
::
vector
<
int
>
data
(
2
*
3
);
std
::
iota
(
data
.
begin
(),
data
.
end
(),
0
);
params
[
"x"
]
=
migraphx
::
argument
(
input_fixed_shape
,
data
.
data
());
params
[
"indices"
]
=
migraphx
::
argument
(
input_indices
,
indices
.
data
());
auto
result
=
p
.
eval
(
params
).
back
();
std
::
vector
<
int
>
gold
=
{
1
,
2
,
4
,
5
};
std
::
vector
<
int
>
results_vector
(
2
*
1
*
2
);
result
.
visit
([
&
](
auto
output
)
{
results_vector
.
assign
(
output
.
begin
(),
output
.
end
());
});
EXPECT
(
migraphx
::
verify_range
(
results_vector
,
gold
));
migraphx
::
shape
sfinal
{
migraphx
::
shape
::
int32_type
,
{
2
,
1
,
2
}};
EXPECT
(
result
.
get_shape
()
==
sfinal
);
}
TEST_CASE
(
gather_dyn_test1
)
{
// Dynamic data, dynamic indices
migraphx
::
program
p
;
auto
*
mm
=
p
.
get_main_module
();
migraphx
::
shape
s
{
migraphx
::
shape
::
int32_type
,
{{
2
,
5
,
0
},
{
4
,
4
,
0
}}};
auto
x
=
mm
->
add_parameter
(
"x"
,
s
);
migraphx
::
shape
s_ind
{
migraphx
::
shape
::
int32_type
,
{{
1
,
8
,
7
},
{
2
,
3
,
3
}}};
auto
ind
=
mm
->
add_parameter
(
"indices"
,
s_ind
);
mm
->
add_instruction
(
migraphx
::
make_op
(
"gather"
,
{{
"axis"
,
0
}}),
x
,
ind
);
migraphx
::
shape
sresult
{
migraphx
::
shape
::
int32_type
,
{{
1
,
8
,
7
},
{
2
,
3
,
3
},
{
4
,
4
,
0
}}};
EXPECT
(
p
.
get_output_shapes
().
back
()
==
sresult
);
p
.
compile
(
migraphx
::
ref
::
target
{});
migraphx
::
shape
input_fixed_shape
{
migraphx
::
shape
::
int32_type
,
{
3
,
4
}};
migraphx
::
shape
input_indices_shape
{
migraphx
::
shape
::
int32_type
,
{
1
,
2
}};
std
::
vector
<
int
>
indices
{
2
,
0
};
migraphx
::
parameter_map
params
;
std
::
vector
<
int
>
data
(
3
*
4
);
std
::
iota
(
data
.
begin
(),
data
.
end
(),
0
);
params
[
"x"
]
=
migraphx
::
argument
(
input_fixed_shape
,
data
.
data
());
params
[
"indices"
]
=
migraphx
::
argument
(
input_indices_shape
,
indices
.
data
());
auto
result
=
p
.
eval
(
params
).
back
();
std
::
vector
<
int
>
gold
=
{
8
,
9
,
10
,
11
,
0
,
1
,
2
,
3
};
std
::
vector
<
int
>
results_vector
(
1
*
2
*
4
);
result
.
visit
([
&
](
auto
output
)
{
results_vector
.
assign
(
output
.
begin
(),
output
.
end
());
});
EXPECT
(
migraphx
::
verify_range
(
results_vector
,
gold
));
migraphx
::
shape
sfinal
{
migraphx
::
shape
::
int32_type
,
{
1
,
2
,
4
}};
EXPECT
(
result
.
get_shape
()
==
sfinal
);
}
TEST_CASE
(
gathernd_test
)
{
{
...
...
tools/build_and_test_onnxrt.sh
View file @
51c34a3b
...
...
@@ -26,5 +26,8 @@ pip3 install -r requirements.txt
# Add newer cmake to the path
export
PATH
=
"/opt/cmake/bin:
$PATH
"
export
CXXFLAGS
=
"-D__HIP_PLATFORM_HCC__=1 -w"
./build.sh
--config
Release
--update
--build
--parallel
--cmake_extra_defines
ONNXRUNTIME_VERSION
=
$(
cat
./VERSION_NUMBER
)
--test
--use_migraphx
# pip3 install /code/onnxruntime/build/Linux/Release/dist/*.whl
./build.sh
--config
Release
--cmake_extra_defines
CMAKE_HIP_COMPILER
=
/opt/rocm/llvm/bin/clang++
--update
--build
--parallel
--cmake_extra_defines
ONNXRUNTIME_VERSION
=
$(
cat
./VERSION_NUMBER
)
--skip_tests
--rocm_home
/opt/rocm
--use_migraphx
--migraphx_home
/opt/rocm
--rocm_version
=
`
cat
/opt/rocm/.info/version-dev
`
cd
build/Linux/Release
#Add test launcher for onnxrt tests
../../../tools/ci_build/github/pai/migraphx_test_launcher.sh
Prev
1
2
3
Next
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment