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
70d9faf7
Unverified
Commit
70d9faf7
authored
Dec 13, 2023
by
Chris Austen
Committed by
GitHub
Dec 13, 2023
Browse files
Merge branch 'develop' into mi200
parents
a56c531c
a60bdb67
Changes
442
Hide whitespace changes
Inline
Side-by-side
Showing
20 changed files
with
199 additions
and
93 deletions
+199
-93
test/verify/gemm_multi_3args_c25.cpp
test/verify/gemm_multi_3args_c25.cpp
+9
-4
test/verify/gemm_multi_dim_2.cpp
test/verify/gemm_multi_dim_2.cpp
+8
-3
test/verify/gemm_multi_dim_2_3.cpp
test/verify/gemm_multi_dim_2_3.cpp
+8
-3
test/verify/gemm_multi_transpose.cpp
test/verify/gemm_multi_transpose.cpp
+8
-3
test/verify/gemm_softmax_gemm_relu.cpp
test/verify/gemm_softmax_gemm_relu.cpp
+19
-12
test/verify/main.cpp
test/verify/main.cpp
+22
-11
test/verify/quant_conv.cpp
test/verify/quant_conv.cpp
+7
-3
test/verify/quant_conv_1.cpp
test/verify/quant_conv_1.cpp
+7
-3
test/verify/quant_conv_1d.cpp
test/verify/quant_conv_1d.cpp
+8
-3
test/verify/quant_conv_2.cpp
test/verify/quant_conv_2.cpp
+7
-3
test/verify/quant_conv_padding.cpp
test/verify/quant_conv_padding.cpp
+7
-3
test/verify/quant_conv_padding_stride.cpp
test/verify/quant_conv_padding_stride.cpp
+6
-3
test/verify/quant_dot_3args_1.cpp
test/verify/quant_dot_3args_1.cpp
+13
-5
test/verify/quant_dot_3args_2.cpp
test/verify/quant_dot_3args_2.cpp
+12
-5
test/verify/quant_dot_3args_3.cpp
test/verify/quant_dot_3args_3.cpp
+11
-5
test/verify/quant_dot_3args_4.cpp
test/verify/quant_dot_3args_4.cpp
+12
-5
test/verify/quant_dot_3args_5.cpp
test/verify/quant_dot_3args_5.cpp
+10
-4
test/verify/run_verify.cpp
test/verify/run_verify.cpp
+13
-10
test/verify/run_verify.hpp
test/verify/run_verify.hpp
+5
-3
test/verify/test_abs.cpp
test/verify/test_abs.cpp
+7
-2
No files found.
test/verify/gemm_multi_3args_c25.cpp
View file @
70d9faf7
...
...
@@ -28,15 +28,16 @@
#include <migraphx/generate.hpp>
#include <migraphx/make_op.hpp>
struct
gemm_multi_3args_c25
:
verify_program
<
gemm_multi_3args_c25
>
template
<
migraphx
::
shape
::
type_t
DType
>
struct
gemm_multi_3args_c25
:
verify_program
<
gemm_multi_3args_c25
<
DType
>>
{
migraphx
::
program
create_program
()
const
{
migraphx
::
program
p
;
auto
*
mm
=
p
.
get_main_module
();
migraphx
::
shape
m1_shape
{
migraphx
::
shape
::
float_t
ype
,
{
2
,
3
}};
migraphx
::
shape
m2_shape
{
migraphx
::
shape
::
float_t
ype
,
{
3
,
5
}};
migraphx
::
shape
m3_shape
{
migraphx
::
shape
::
float_t
ype
,
{
2
,
5
}};
migraphx
::
shape
m1_shape
{
DT
ype
,
{
2
,
3
}};
migraphx
::
shape
m2_shape
{
DT
ype
,
{
3
,
5
}};
migraphx
::
shape
m3_shape
{
DT
ype
,
{
2
,
5
}};
auto
l1
=
mm
->
add_parameter
(
"1"
,
m1_shape
);
auto
l2
=
mm
->
add_parameter
(
"2"
,
m2_shape
);
...
...
@@ -47,3 +48,7 @@ struct gemm_multi_3args_c25 : verify_program<gemm_multi_3args_c25>
return
p
;
}
};
template
struct
gemm_multi_3args_c25
<
migraphx
::
shape
::
float_type
>;
template
struct
gemm_multi_3args_c25
<
migraphx
::
shape
::
half_type
>;
template
struct
gemm_multi_3args_c25
<
migraphx
::
shape
::
fp8e4m3fnuz_type
>;
test/verify/gemm_multi_dim_2.cpp
View file @
70d9faf7
...
...
@@ -27,14 +27,15 @@
#include <migraphx/generate.hpp>
#include <migraphx/make_op.hpp>
struct
gemm_multi_dim_2
:
verify_program
<
gemm_multi_dim_2
>
template
<
migraphx
::
shape
::
type_t
DType
>
struct
gemm_multi_dim_2
:
verify_program
<
gemm_multi_dim_2
<
DType
>>
{
migraphx
::
program
create_program
()
const
{
migraphx
::
program
p
;
auto
*
mm
=
p
.
get_main_module
();
migraphx
::
shape
m1_shape
{
migraphx
::
shape
::
float_t
ype
,
{
2
,
2
,
3
}};
migraphx
::
shape
m2_shape
{
migraphx
::
shape
::
float_t
ype
,
{
2
,
3
,
4
}};
migraphx
::
shape
m1_shape
{
DT
ype
,
{
2
,
2
,
3
}};
migraphx
::
shape
m2_shape
{
DT
ype
,
{
2
,
3
,
4
}};
auto
l1
=
mm
->
add_parameter
(
"1"
,
m1_shape
);
auto
l2
=
mm
->
add_parameter
(
"2"
,
m2_shape
);
...
...
@@ -43,3 +44,7 @@ struct gemm_multi_dim_2 : verify_program<gemm_multi_dim_2>
return
p
;
}
};
template
struct
gemm_multi_dim_2
<
migraphx
::
shape
::
float_type
>;
template
struct
gemm_multi_dim_2
<
migraphx
::
shape
::
half_type
>;
template
struct
gemm_multi_dim_2
<
migraphx
::
shape
::
fp8e4m3fnuz_type
>;
test/verify/gemm_multi_dim_2_3.cpp
View file @
70d9faf7
...
...
@@ -27,14 +27,15 @@
#include <migraphx/generate.hpp>
#include <migraphx/make_op.hpp>
struct
gemm_multi_dim_2_3
:
verify_program
<
gemm_multi_dim_2_3
>
template
<
migraphx
::
shape
::
type_t
DType
>
struct
gemm_multi_dim_2_3
:
verify_program
<
gemm_multi_dim_2_3
<
DType
>>
{
migraphx
::
program
create_program
()
const
{
migraphx
::
program
p
;
auto
*
mm
=
p
.
get_main_module
();
migraphx
::
shape
m1_shape
{
migraphx
::
shape
::
float_t
ype
,
{
2
,
3
,
2
,
3
}};
migraphx
::
shape
m2_shape
{
migraphx
::
shape
::
float_t
ype
,
{
2
,
3
,
3
,
2
}};
migraphx
::
shape
m1_shape
{
DT
ype
,
{
2
,
3
,
2
,
3
}};
migraphx
::
shape
m2_shape
{
DT
ype
,
{
2
,
3
,
3
,
2
}};
auto
l1
=
mm
->
add_parameter
(
"1"
,
m1_shape
);
auto
l2
=
mm
->
add_parameter
(
"2"
,
m2_shape
);
...
...
@@ -43,3 +44,7 @@ struct gemm_multi_dim_2_3 : verify_program<gemm_multi_dim_2_3>
return
p
;
}
};
template
struct
gemm_multi_dim_2_3
<
migraphx
::
shape
::
float_type
>;
template
struct
gemm_multi_dim_2_3
<
migraphx
::
shape
::
half_type
>;
template
struct
gemm_multi_dim_2_3
<
migraphx
::
shape
::
fp8e4m3fnuz_type
>;
test/verify/gemm_multi_transpose.cpp
View file @
70d9faf7
...
...
@@ -28,14 +28,15 @@
#include <migraphx/generate.hpp>
#include <migraphx/make_op.hpp>
struct
gemm_multi_transpose
:
verify_program
<
gemm_multi_transpose
>
template
<
migraphx
::
shape
::
type_t
DType
>
struct
gemm_multi_transpose
:
verify_program
<
gemm_multi_transpose
<
DType
>>
{
migraphx
::
program
create_program
()
const
{
migraphx
::
program
p
;
auto
*
mm
=
p
.
get_main_module
();
migraphx
::
shape
m1_shape
{
migraphx
::
shape
::
float_t
ype
,
{
2
,
2
,
3
}};
migraphx
::
shape
m2_shape
{
migraphx
::
shape
::
float_t
ype
,
{
3
,
2
,
4
}};
migraphx
::
shape
m1_shape
{
DT
ype
,
{
2
,
2
,
3
}};
migraphx
::
shape
m2_shape
{
DT
ype
,
{
3
,
2
,
4
}};
auto
l1
=
mm
->
add_parameter
(
"1"
,
m1_shape
);
auto
l2
=
mm
->
add_parameter
(
"2"
,
m2_shape
);
auto
tl2
=
...
...
@@ -47,3 +48,7 @@ struct gemm_multi_transpose : verify_program<gemm_multi_transpose>
return
p
;
}
};
template
struct
gemm_multi_transpose
<
migraphx
::
shape
::
float_type
>;
template
struct
gemm_multi_transpose
<
migraphx
::
shape
::
half_type
>;
template
struct
gemm_multi_transpose
<
migraphx
::
shape
::
fp8e4m3fnuz_type
>;
test/verify/gemm_
add_broadcast_half
.cpp
→
test/verify/gemm_
softmax_gemm_relu
.cpp
View file @
70d9faf7
...
...
@@ -26,24 +26,31 @@
#include <migraphx/program.hpp>
#include <migraphx/generate.hpp>
#include <migraphx/make_op.hpp>
#include <migraphx/apply_alpha_beta.hpp>
struct
gemm_
add_broadcast_half
:
verify_program
<
gemm_
add_broadcast_half
>
struct
gemm_
softmax_gemm_relu
:
verify_program
<
gemm_
softmax_gemm_relu
>
{
migraphx
::
program
create_program
()
const
{
migraphx
::
program
p
;
auto
*
mm
=
p
.
get_main_module
();
migraphx
::
shape
m1_shape
{
migraphx
::
shape
::
half_type
,
{
1
,
2
,
3
}};
migraphx
::
shape
m2_shape
{
migraphx
::
shape
::
half_type
,
{
1
,
3
,
4
}};
migraphx
::
shape
m3_shape
{
migraphx
::
shape
::
half_type
,
{
1
,
1
,
4
}};
auto
l1
=
mm
->
add_parameter
(
"1"
,
m1_shape
);
auto
l2
=
mm
->
add_parameter
(
"2"
,
m2_shape
);
auto
l3
=
mm
->
add_parameter
(
"3"
,
m3_shape
);
auto
l3_b
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"multibroadcast"
,
{{
"out_lens"
,
{
1
,
2
,
4
}}}),
l3
);
migraphx
::
shape
m1_shape
{
migraphx
::
shape
::
half_type
,
{
1
,
12
,
256
,
256
}};
migraphx
::
shape
m2_shape
{
migraphx
::
shape
::
half_type
,
{
1
,
12
,
256
,
256
}};
auto
m2_elements
=
m2_shape
.
elements
();
auto
a
=
mm
->
add_parameter
(
"1"
,
m1_shape
);
auto
b
=
mm
->
add_parameter
(
"2"
,
m1_shape
);
auto
b1
=
mm
->
add_parameter
(
"3"
,
m1_shape
);
std
::
vector
<
float
>
eights
(
m2_elements
,
0.125
);
auto
eight
=
mm
->
add_literal
(
migraphx
::
literal
{
m2_shape
,
eights
});
std
::
vector
<
float
>
zeros
(
m2_elements
,
0
);
auto
zero
=
mm
->
add_literal
(
migraphx
::
literal
{
m2_shape
,
zeros
});
auto
dot
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"dot"
),
l1
,
l2
);
mm
->
add_instruction
(
migraphx
::
make_op
(
"add"
),
dot
,
l3_b
);
b
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"transpose"
,
{{
"permutation"
,
{
0
,
1
,
3
,
2
}}}),
b
);
auto
gemm1
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"dot"
),
a
,
b
);
auto
scale
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"mul"
),
gemm1
,
eight
);
auto
bias
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"add"
),
scale
,
zero
);
auto
softmax
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"softmax"
,
{{
"axis"
,
3
}}),
bias
);
auto
gemm2
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"dot"
),
softmax
,
b1
);
mm
->
add_instruction
(
migraphx
::
make_op
(
"relu"
),
gemm2
);
return
p
;
}
};
test/verify/main.cpp
View file @
70d9faf7
...
...
@@ -67,16 +67,27 @@ int main(int argc, const char* argv[])
{
run_verify
rv
;
rv
.
add_validation_for
(
"gpu"
,
&
validate_gpu
);
rv
.
disable_test_for
(
"cpu"
,
{
"test_if_lp"
,
"test_if_param"
,
"test_if_literal"
,
"test_select_module_add"
,
"test_select_module_reduce"
,
"test_select_module_conv"
,
"test_split_single_dyn_dim"
,
"test_instancenorm_large_3d<migraphx::shape::float_type>"
,
"test_instancenorm_large_3d<migraphx::shape::half_type>"
});
rv
.
disable_test_for
(
"gpu"
,
{
"test_conv_bn_add"
});
rv
.
disable_test_for
(
"cpu"
,
{
"test_if_lp"
,
"test_if_param"
,
"test_if_literal"
,
"test_select_module_add"
,
"test_select_module_reduce"
,
"test_select_module_conv"
,
"test_split_single_dyn_dim"
,
"test_instancenorm_large_3d<migraphx::shape::float_type>"
,
"test_instancenorm_large_3d<migraphx::shape::half_type>"
,
// these tests are disabled due issue of lossy downcast, see issue#2517
#if defined(__GNUC__) and !defined(__clang__)
"batch_quant_dot_1<migraphx::fp8::float8<migraphx::fp8::f8_type::fp8, true>, float>"
,
"quant_dot_3args_4<migraphx::fp8::float8<migraphx::fp8::f8_type::fp8, true>, float>"
,
"quant_dot_3args_5<migraphx::fp8::float8<migraphx::fp8::f8_type::fp8, true>, float>"
,
#else
"batch_quant_dot_1<migraphx::fp8::fp8e4m3fnuz, float>"
,
"quant_dot_3args_4<migraphx::fp8::fp8e4m3fnuz, float>"
,
"quant_dot_3args_5<migraphx::fp8::fp8e4m3fnuz, float>"
#endif
});
rv
.
disable_test_for
(
"gpu"
,
{
// These passes on MI300 but fails on others, same issue as CPU.
"batch_quant_dot_1<migraphx::fp8::fp8e4m3fnuz, float>"
,
"quant_dot_3args_4<migraphx::fp8::fp8e4m3fnuz, float>"
,
"quant_dot_3args_5<migraphx::fp8::fp8e4m3fnuz, float>"
});
rv
.
run
(
argc
,
argv
);
}
test/verify/quant_conv.cpp
View file @
70d9faf7
...
...
@@ -27,17 +27,21 @@
#include <migraphx/generate.hpp>
#include <migraphx/make_op.hpp>
struct
quant_conv
:
verify_program
<
quant_conv
>
template
<
migraphx
::
shape
::
type_t
DType
>
struct
quant_conv
:
verify_program
<
quant_conv
<
DType
>>
{
migraphx
::
program
create_program
()
const
{
migraphx
::
program
p
;
auto
*
mm
=
p
.
get_main_module
();
migraphx
::
shape
a_shape
{
migraphx
::
shape
::
int8_t
ype
,
{
2
,
3
,
4
,
4
}};
migraphx
::
shape
a_shape
{
DT
ype
,
{
2
,
3
,
4
,
4
}};
auto
pa
=
mm
->
add_parameter
(
"a"
,
a_shape
);
migraphx
::
shape
c_shape
{
migraphx
::
shape
::
int8_t
ype
,
{
2
,
3
,
3
,
3
}};
migraphx
::
shape
c_shape
{
DT
ype
,
{
2
,
3
,
3
,
3
}};
auto
pc
=
mm
->
add_parameter
(
"c"
,
c_shape
);
mm
->
add_instruction
(
migraphx
::
make_op
(
"quant_convolution"
),
pa
,
pc
);
return
p
;
}
};
template
struct
quant_conv
<
migraphx
::
shape
::
int8_type
>;
template
struct
quant_conv
<
migraphx
::
shape
::
fp8e4m3fnuz_type
>;
test/verify/quant_conv_
default_mode
.cpp
→
test/verify/quant_conv_
1
.cpp
View file @
70d9faf7
...
...
@@ -27,17 +27,21 @@
#include <migraphx/generate.hpp>
#include <migraphx/op/quant_convolution.hpp>
struct
quant_conv_default_mode
:
verify_program
<
quant_conv_default_mode
>
template
<
migraphx
::
shape
::
type_t
DType
>
struct
quant_conv_1
:
verify_program
<
quant_conv_1
<
DType
>>
{
migraphx
::
program
create_program
()
const
{
migraphx
::
program
p
;
auto
*
mm
=
p
.
get_main_module
();
migraphx
::
shape
a_shape
{
migraphx
::
shape
::
int8_t
ype
,
{
2
,
3
,
4
,
4
}};
migraphx
::
shape
a_shape
{
DT
ype
,
{
2
,
3
,
4
,
4
}};
auto
pa
=
mm
->
add_parameter
(
"a"
,
a_shape
);
migraphx
::
shape
c_shape
{
migraphx
::
shape
::
int8_t
ype
,
{
2
,
3
,
3
,
3
}};
migraphx
::
shape
c_shape
{
DT
ype
,
{
2
,
3
,
3
,
3
}};
auto
pc
=
mm
->
add_parameter
(
"c"
,
c_shape
);
mm
->
add_instruction
(
migraphx
::
op
::
quant_convolution
{{{
0
,
0
}},
{{
1
,
1
}},
{{
1
,
1
}}},
pa
,
pc
);
return
p
;
}
};
template
struct
quant_conv_1
<
migraphx
::
shape
::
int8_type
>;
template
struct
quant_conv_1
<
migraphx
::
shape
::
fp8e4m3fnuz_type
>;
test/verify/quant_conv_1d.cpp
View file @
70d9faf7
...
...
@@ -27,15 +27,16 @@
#include <migraphx/generate.hpp>
#include <migraphx/make_op.hpp>
struct
quant_conv_1d
:
verify_program
<
quant_conv_1d
>
template
<
migraphx
::
shape
::
type_t
DType
>
struct
quant_conv_1d
:
verify_program
<
quant_conv_1d
<
DType
>>
{
migraphx
::
program
create_program
()
const
{
migraphx
::
program
p
;
auto
*
mm
=
p
.
get_main_module
();
migraphx
::
shape
a_shape
{
migraphx
::
shape
::
int8_t
ype
,
{
2
,
3
,
4
}};
migraphx
::
shape
a_shape
{
DT
ype
,
{
2
,
3
,
4
}};
auto
pa
=
mm
->
add_parameter
(
"a"
,
a_shape
);
migraphx
::
shape
c_shape
{
migraphx
::
shape
::
int8_t
ype
,
{
2
,
3
,
3
}};
migraphx
::
shape
c_shape
{
DT
ype
,
{
2
,
3
,
3
}};
auto
pc
=
mm
->
add_parameter
(
"c"
,
c_shape
);
mm
->
add_instruction
(
migraphx
::
make_op
(
"quant_convolution"
,
...
...
@@ -45,3 +46,7 @@ struct quant_conv_1d : verify_program<quant_conv_1d>
return
p
;
}
};
template
struct
quant_conv_1d
<
migraphx
::
shape
::
int8_type
>;
// MLIR 1D convolution is not supported in MIGraphX yet. Enable this through MIOpen route later.
// template struct quant_conv_1d<migraphx::shape::fp8e4m3fnuz_type>;
test/verify/quant_conv_
int8x4_default
.cpp
→
test/verify/quant_conv_
2
.cpp
View file @
70d9faf7
...
...
@@ -27,17 +27,21 @@
#include <migraphx/generate.hpp>
#include <migraphx/op/quant_convolution.hpp>
struct
quant_conv_int8x4_default
:
verify_program
<
quant_conv_int8x4_default
>
template
<
migraphx
::
shape
::
type_t
DType
>
struct
quant_conv_2
:
verify_program
<
quant_conv_2
<
DType
>>
{
migraphx
::
program
create_program
()
const
{
migraphx
::
program
p
;
auto
*
mm
=
p
.
get_main_module
();
migraphx
::
shape
a_shape
{
migraphx
::
shape
::
int8_t
ype
,
{
16
,
16
,
4
,
4
}};
migraphx
::
shape
a_shape
{
DT
ype
,
{
16
,
16
,
4
,
4
}};
auto
pa
=
mm
->
add_parameter
(
"a"
,
a_shape
);
migraphx
::
shape
c_shape
{
migraphx
::
shape
::
int8_t
ype
,
{
16
,
16
,
3
,
3
}};
migraphx
::
shape
c_shape
{
DT
ype
,
{
16
,
16
,
3
,
3
}};
auto
pc
=
mm
->
add_parameter
(
"c"
,
c_shape
);
mm
->
add_instruction
(
migraphx
::
op
::
quant_convolution
{{{
0
,
0
}},
{{
1
,
1
}},
{{
1
,
1
}}},
pa
,
pc
);
return
p
;
}
};
template
struct
quant_conv_2
<
migraphx
::
shape
::
int8_type
>;
template
struct
quant_conv_2
<
migraphx
::
shape
::
fp8e4m3fnuz_type
>;
test/verify/quant_conv_padding.cpp
View file @
70d9faf7
...
...
@@ -27,15 +27,16 @@
#include <migraphx/generate.hpp>
#include <migraphx/make_op.hpp>
struct
quant_conv_padding
:
verify_program
<
quant_conv_padding
>
template
<
migraphx
::
shape
::
type_t
DType
>
struct
quant_conv_padding
:
verify_program
<
quant_conv_padding
<
DType
>>
{
migraphx
::
program
create_program
()
const
{
migraphx
::
program
p
;
auto
*
mm
=
p
.
get_main_module
();
migraphx
::
shape
a_shape
{
migraphx
::
shape
::
int8_t
ype
,
{
2
,
3
,
4
,
4
}};
migraphx
::
shape
a_shape
{
DT
ype
,
{
2
,
3
,
4
,
4
}};
auto
pa
=
mm
->
add_parameter
(
"a"
,
a_shape
);
migraphx
::
shape
c_shape
{
migraphx
::
shape
::
int8_t
ype
,
{
2
,
3
,
3
,
3
}};
migraphx
::
shape
c_shape
{
DT
ype
,
{
2
,
3
,
3
,
3
}};
auto
pc
=
mm
->
add_parameter
(
"c"
,
c_shape
);
mm
->
add_instruction
(
migraphx
::
make_op
(
"quant_convolution"
,
{{
"padding"
,
{
1
,
1
}},
{
"stride"
,
{
1
,
1
}}}),
...
...
@@ -44,3 +45,6 @@ struct quant_conv_padding : verify_program<quant_conv_padding>
return
p
;
}
};
template
struct
quant_conv_padding
<
migraphx
::
shape
::
int8_type
>;
template
struct
quant_conv_padding
<
migraphx
::
shape
::
fp8e4m3fnuz_type
>;
test/verify/quant_conv_padding_stride.cpp
View file @
70d9faf7
...
...
@@ -27,15 +27,16 @@
#include <migraphx/generate.hpp>
#include <migraphx/make_op.hpp>
struct
quant_conv_padding_stride
:
verify_program
<
quant_conv_padding_stride
>
template
<
migraphx
::
shape
::
type_t
DType
>
struct
quant_conv_padding_stride
:
verify_program
<
quant_conv_padding_stride
<
DType
>>
{
migraphx
::
program
create_program
()
const
{
migraphx
::
program
p
;
auto
*
mm
=
p
.
get_main_module
();
migraphx
::
shape
a_shape
{
migraphx
::
shape
::
int8_t
ype
,
{
2
,
3
,
4
,
4
}};
migraphx
::
shape
a_shape
{
DT
ype
,
{
2
,
3
,
4
,
4
}};
auto
pa
=
mm
->
add_parameter
(
"a"
,
a_shape
);
migraphx
::
shape
c_shape
{
migraphx
::
shape
::
int8_t
ype
,
{
2
,
3
,
3
,
3
}};
migraphx
::
shape
c_shape
{
DT
ype
,
{
2
,
3
,
3
,
3
}};
auto
pc
=
mm
->
add_parameter
(
"c"
,
c_shape
);
mm
->
add_instruction
(
migraphx
::
make_op
(
"quant_convolution"
,
{{
"padding"
,
{
1
,
1
}},
{
"stride"
,
{
2
,
2
}}}),
...
...
@@ -45,3 +46,5 @@ struct quant_conv_padding_stride : verify_program<quant_conv_padding_stride>
return
p
;
}
};
template
struct
quant_conv_padding_stride
<
migraphx
::
shape
::
int8_type
>;
template
struct
quant_conv_padding_stride
<
migraphx
::
shape
::
fp8e4m3fnuz_type
>;
test/verify/quant_dot_3args_1.cpp
View file @
70d9faf7
...
...
@@ -25,23 +25,31 @@
#include "verify_program.hpp"
#include <migraphx/program.hpp>
#include <migraphx/apply_alpha_beta.hpp>
#include <migraphx/float8.hpp>
#include <migraphx/generate.hpp>
#include <migraphx/make_op.hpp>
struct
quant_dot_3args_1
:
verify_program
<
quant_dot_3args_1
>
template
<
typename
DType
,
typename
CType
>
struct
quant_dot_3args_1
:
verify_program
<
quant_dot_3args_1
<
DType
,
CType
>>
{
migraphx
::
program
create_program
()
const
{
migraphx
::
program
p
;
auto
*
mm
=
p
.
get_main_module
();
migraphx
::
shape
m1_shape
{
migraphx
::
shape
::
int8_type
,
{
2
,
8
}};
migraphx
::
shape
m2_shape
{
migraphx
::
shape
::
int8_type
,
{
8
,
7
}};
migraphx
::
shape
m3_shape
{
migraphx
::
shape
::
int32_type
,
{
2
,
7
}};
auto
ctype
=
migraphx
::
shape
::
get_type
<
CType
>
();
auto
dtype
=
migraphx
::
shape
::
get_type
<
DType
>
();
migraphx
::
shape
m1_shape
{
dtype
,
{
2
,
8
}};
migraphx
::
shape
m2_shape
{
dtype
,
{
8
,
7
}};
migraphx
::
shape
m3_shape
{
ctype
,
{
2
,
7
}};
auto
l1
=
mm
->
add_parameter
(
"a"
,
m1_shape
);
auto
l2
=
mm
->
add_parameter
(
"b"
,
m2_shape
);
auto
l3
=
mm
->
add_parameter
(
"c"
,
m3_shape
);
migraphx
::
add_apply_alpha_beta
(
*
mm
,
{
l1
,
l2
,
l3
},
migraphx
::
make_op
(
"quant_dot"
),
1
,
1
);
migraphx
::
add_apply_alpha_beta
(
*
mm
,
{
l1
,
l2
,
l3
},
migraphx
::
make_op
(
"quant_dot"
),
CType
{
1
},
CType
{
1
});
return
p
;
}
};
template
struct
quant_dot_3args_1
<
int8_t
,
int32_t
>;
template
struct
quant_dot_3args_1
<
migraphx
::
fp8
::
fp8e4m3fnuz
,
float
>;
test/verify/quant_dot_3args_2.cpp
View file @
70d9faf7
...
...
@@ -28,22 +28,29 @@
#include <migraphx/generate.hpp>
#include <migraphx/make_op.hpp>
struct
quant_dot_3args_2
:
verify_program
<
quant_dot_3args_2
>
template
<
typename
DType
,
typename
CType
>
struct
quant_dot_3args_2
:
verify_program
<
quant_dot_3args_2
<
DType
,
CType
>>
{
migraphx
::
program
create_program
()
const
{
migraphx
::
program
p
;
auto
*
mm
=
p
.
get_main_module
();
migraphx
::
shape
m1_shape
{
migraphx
::
shape
::
int8_type
,
{
8
,
2
}};
migraphx
::
shape
m2_shape
{
migraphx
::
shape
::
int8_type
,
{
8
,
7
}};
migraphx
::
shape
m3_shape
{
migraphx
::
shape
::
int32_type
,
{
2
,
7
}};
auto
ctype
=
migraphx
::
shape
::
get_type
<
CType
>
();
auto
dtype
=
migraphx
::
shape
::
get_type
<
DType
>
();
migraphx
::
shape
m1_shape
{
dtype
,
{
8
,
2
}};
migraphx
::
shape
m2_shape
{
dtype
,
{
8
,
7
}};
migraphx
::
shape
m3_shape
{
ctype
,
{
2
,
7
}};
auto
l1
=
mm
->
add_parameter
(
"a"
,
m1_shape
);
auto
tl1
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"transpose"
,
{{
"permutation"
,
{
1
,
0
}}}),
l1
);
auto
l2
=
mm
->
add_parameter
(
"b"
,
m2_shape
);
auto
l3
=
mm
->
add_parameter
(
"c"
,
m3_shape
);
migraphx
::
add_apply_alpha_beta
(
*
mm
,
{
tl1
,
l2
,
l3
},
migraphx
::
make_op
(
"quant_dot"
),
1
,
3
);
migraphx
::
add_apply_alpha_beta
(
*
mm
,
{
tl1
,
l2
,
l3
},
migraphx
::
make_op
(
"quant_dot"
),
CType
{
1
},
CType
{
3
});
return
p
;
}
};
template
struct
quant_dot_3args_2
<
int8_t
,
int32_t
>;
template
struct
quant_dot_3args_2
<
migraphx
::
fp8
::
fp8e4m3fnuz
,
float
>;
test/verify/quant_dot_3args_3.cpp
View file @
70d9faf7
...
...
@@ -28,22 +28,28 @@
#include <migraphx/generate.hpp>
#include <migraphx/make_op.hpp>
struct
quant_dot_3args_3
:
verify_program
<
quant_dot_3args_3
>
template
<
typename
DType
,
typename
CType
>
struct
quant_dot_3args_3
:
verify_program
<
quant_dot_3args_3
<
DType
,
CType
>>
{
migraphx
::
program
create_program
()
const
{
migraphx
::
program
p
;
auto
*
mm
=
p
.
get_main_module
();
migraphx
::
shape
m1_shape
{
migraphx
::
shape
::
int8_type
,
{
2
,
8
}};
migraphx
::
shape
m2_shape
{
migraphx
::
shape
::
int8_type
,
{
7
,
8
}};
migraphx
::
shape
m3_shape
{
migraphx
::
shape
::
int32_type
,
{
2
,
7
}};
auto
ctype
=
migraphx
::
shape
::
get_type
<
CType
>
();
auto
dtype
=
migraphx
::
shape
::
get_type
<
DType
>
();
migraphx
::
shape
m1_shape
{
dtype
,
{
2
,
8
}};
migraphx
::
shape
m2_shape
{
dtype
,
{
7
,
8
}};
migraphx
::
shape
m3_shape
{
ctype
,
{
2
,
7
}};
auto
l1
=
mm
->
add_parameter
(
"a"
,
m1_shape
);
auto
l2
=
mm
->
add_parameter
(
"b"
,
m2_shape
);
auto
tl2
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"transpose"
,
{{
"permutation"
,
{
1
,
0
}}}),
l2
);
auto
l3
=
mm
->
add_parameter
(
"c"
,
m3_shape
);
migraphx
::
add_apply_alpha_beta
(
*
mm
,
{
l1
,
tl2
,
l3
},
migraphx
::
make_op
(
"quant_dot"
),
2
,
3
);
migraphx
::
add_apply_alpha_beta
(
*
mm
,
{
l1
,
tl2
,
l3
},
migraphx
::
make_op
(
"quant_dot"
),
CType
{
2
},
CType
{
3
});
return
p
;
}
};
template
struct
quant_dot_3args_3
<
int8_t
,
int32_t
>;
template
struct
quant_dot_3args_3
<
migraphx
::
fp8
::
fp8e4m3fnuz
,
float
>;
test/verify/quant_dot_3args_4.cpp
View file @
70d9faf7
...
...
@@ -28,15 +28,18 @@
#include <migraphx/generate.hpp>
#include <migraphx/make_op.hpp>
struct
quant_dot_3args_4
:
verify_program
<
quant_dot_3args_4
>
template
<
typename
DType
,
typename
CType
>
struct
quant_dot_3args_4
:
verify_program
<
quant_dot_3args_4
<
DType
,
CType
>>
{
migraphx
::
program
create_program
()
const
{
migraphx
::
program
p
;
auto
*
mm
=
p
.
get_main_module
();
migraphx
::
shape
m1_shape
{
migraphx
::
shape
::
int8_type
,
{
8
,
2
}};
migraphx
::
shape
m2_shape
{
migraphx
::
shape
::
int8_type
,
{
7
,
8
}};
migraphx
::
shape
m3_shape
{
migraphx
::
shape
::
int32_type
,
{
2
,
7
}};
auto
ctype
=
migraphx
::
shape
::
get_type
<
CType
>
();
auto
dtype
=
migraphx
::
shape
::
get_type
<
DType
>
();
migraphx
::
shape
m1_shape
{
dtype
,
{
8
,
2
}};
migraphx
::
shape
m2_shape
{
dtype
,
{
7
,
8
}};
migraphx
::
shape
m3_shape
{
ctype
,
{
2
,
7
}};
auto
l1
=
mm
->
add_parameter
(
"a"
,
m1_shape
);
auto
tl1
=
...
...
@@ -45,7 +48,11 @@ struct quant_dot_3args_4 : verify_program<quant_dot_3args_4>
auto
tl2
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"transpose"
,
{{
"permutation"
,
{
1
,
0
}}}),
l2
);
auto
l3
=
mm
->
add_parameter
(
"c"
,
m3_shape
);
migraphx
::
add_apply_alpha_beta
(
*
mm
,
{
tl1
,
tl2
,
l3
},
migraphx
::
make_op
(
"quant_dot"
),
3
,
2
);
migraphx
::
add_apply_alpha_beta
(
*
mm
,
{
tl1
,
tl2
,
l3
},
migraphx
::
make_op
(
"quant_dot"
),
CType
{
3
},
CType
{
2
});
return
p
;
}
};
template
struct
quant_dot_3args_4
<
int8_t
,
int32_t
>;
template
struct
quant_dot_3args_4
<
migraphx
::
fp8
::
fp8e4m3fnuz
,
float
>;
test/verify/quant_dot_3args_5.cpp
View file @
70d9faf7
...
...
@@ -28,14 +28,17 @@
#include <migraphx/generate.hpp>
#include <migraphx/make_op.hpp>
struct
quant_dot_3args_5
:
verify_program
<
quant_dot_3args_5
>
template
<
typename
DType
,
typename
CType
>
struct
quant_dot_3args_5
:
verify_program
<
quant_dot_3args_5
<
DType
,
CType
>>
{
migraphx
::
program
create_program
()
const
{
migraphx
::
program
p
;
auto
*
mm
=
p
.
get_main_module
();
migraphx
::
shape
m1_shape
{
migraphx
::
shape
::
int8_type
,
{
6
,
2
}};
migraphx
::
shape
m2_shape
{
migraphx
::
shape
::
int8_type
,
{
7
,
6
}};
auto
dtype
=
migraphx
::
shape
::
get_type
<
DType
>
();
migraphx
::
shape
m1_shape
{
dtype
,
{
6
,
2
}};
migraphx
::
shape
m2_shape
{
dtype
,
{
7
,
6
}};
auto
l1
=
mm
->
add_parameter
(
"a"
,
m1_shape
);
auto
tl1
=
...
...
@@ -43,7 +46,10 @@ struct quant_dot_3args_5 : verify_program<quant_dot_3args_5>
auto
l2
=
mm
->
add_parameter
(
"b"
,
m2_shape
);
auto
tl2
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"transpose"
,
{{
"permutation"
,
{
1
,
0
}}}),
l2
);
migraphx
::
add_apply_alpha_beta
(
*
mm
,
{
tl1
,
tl2
},
migraphx
::
make_op
(
"quant_dot"
),
3
);
migraphx
::
add_apply_alpha_beta
(
*
mm
,
{
tl1
,
tl2
},
migraphx
::
make_op
(
"quant_dot"
),
CType
{
3
}
);
return
p
;
}
};
template
struct
quant_dot_3args_5
<
int8_t
,
int32_t
>;
template
struct
quant_dot_3args_5
<
migraphx
::
fp8
::
fp8e4m3fnuz
,
float
>;
test/verify/run_verify.cpp
View file @
70d9faf7
...
...
@@ -136,15 +136,18 @@ void run_verify::validate(const migraphx::target& t,
ti
.
validate
(
p
,
m
);
}
std
::
vector
<
migraphx
::
argument
>
run_verify
::
run_ref
(
migraphx
::
program
p
,
migraphx
::
parameter_map
inputs
,
const
migraphx
::
compile_options
&
c_opts
)
const
std
::
pair
<
migraphx
::
program
,
std
::
vector
<
migraphx
::
argument
>>
run_verify
::
run_ref
(
migraphx
::
program
p
,
migraphx
::
parameter_map
inputs
,
const
migraphx
::
compile_options
&
c_opts
)
const
{
migraphx
::
target
t
=
migraphx
::
make_target
(
"ref"
);
auto_print
pp
{
p
,
t
.
name
()};
compile_check
(
p
,
t
,
c_opts
);
return
p
.
eval
(
std
::
move
(
inputs
));
auto
trace_target
=
migraphx
::
string_value_of
(
MIGRAPHX_TRACE_TEST_COMPILE
{});
compile_check
(
p
,
t
,
c_opts
,
(
trace_target
==
"ref"
));
return
std
::
make_pair
(
std
::
move
(
p
),
p
.
eval
(
std
::
move
(
inputs
)));
}
std
::
pair
<
migraphx
::
program
,
std
::
vector
<
migraphx
::
argument
>>
run_verify
::
run_target
(
const
migraphx
::
target
&
t
,
migraphx
::
program
p
,
...
...
@@ -225,7 +228,7 @@ void run_verify::verify(const std::string& name,
}
}
auto
gold
_f
=
detach_async
([
=
]
{
return
run_ref
(
p
,
m
,
c_opts
);
});
auto
ref
_f
=
detach_async
([
=
]
{
return
run_ref
(
p
,
m
,
c_opts
);
});
for
(
const
auto
&
tname
:
target_names
)
{
target_info
ti
=
get_target_info
(
tname
);
...
...
@@ -234,8 +237,8 @@ void run_verify::verify(const std::string& name,
tname
,
detach_async
([
=
]
{
return
run_target
(
t
,
p
,
m
,
c_opts
);
},
ti
.
parallel
));
}
assert
(
gold
_f
.
valid
());
auto
gold
=
gold
_f
.
get
();
assert
(
ref
_f
.
valid
());
auto
ref_results
=
ref
_f
.
get
();
for
(
auto
&&
pp
:
results
)
{
...
...
@@ -244,7 +247,7 @@ void run_verify::verify(const std::string& name,
auto
x
=
pp
.
second
.
get
();
auto
cp
=
x
.
first
;
auto
result
=
x
.
second
;
auto
gold
=
ref_results
.
second
;
bool
passed
=
true
;
passed
&=
(
gold
.
size
()
==
result
.
size
());
std
::
size_t
num
=
gold
.
size
();
...
...
@@ -257,7 +260,7 @@ void run_verify::verify(const std::string& name,
if
(
not
passed
or
migraphx
::
enabled
(
MIGRAPHX_TRACE_TEST
{}))
{
std
::
cout
<<
p
<<
std
::
endl
;
std
::
cout
<<
"ref:
\n
"
<<
p
<<
std
::
endl
;
std
::
cout
<<
"ref:
\n
"
<<
ref_results
.
first
<<
std
::
endl
;
std
::
cout
<<
tname
<<
":
\n
"
<<
cp
<<
std
::
endl
;
std
::
cout
<<
std
::
endl
;
}
...
...
test/verify/run_verify.hpp
View file @
70d9faf7
...
...
@@ -39,9 +39,11 @@ struct target_info
struct
run_verify
{
std
::
vector
<
migraphx
::
argument
>
run_ref
(
migraphx
::
program
p
,
migraphx
::
parameter_map
inputs
,
const
migraphx
::
compile_options
&
c_opts
)
const
;
std
::
pair
<
migraphx
::
program
,
std
::
vector
<
migraphx
::
argument
>>
run_ref
(
migraphx
::
program
p
,
migraphx
::
parameter_map
inputs
,
const
migraphx
::
compile_options
&
c_opts
)
const
;
std
::
pair
<
migraphx
::
program
,
std
::
vector
<
migraphx
::
argument
>>
run_target
(
const
migraphx
::
target
&
t
,
migraphx
::
program
p
,
...
...
test/verify/test_abs.cpp
View file @
70d9faf7
...
...
@@ -27,14 +27,19 @@
#include <migraphx/generate.hpp>
#include <migraphx/make_op.hpp>
struct
test_abs
:
verify_program
<
test_abs
>
template
<
migraphx
::
shape
::
type_t
DType
>
struct
test_abs
:
verify_program
<
test_abs
<
DType
>>
{
migraphx
::
program
create_program
()
const
{
migraphx
::
program
p
;
auto
*
mm
=
p
.
get_main_module
();
auto
x
=
mm
->
add_parameter
(
"x"
,
migraphx
::
shape
{
migraphx
::
shape
::
float_t
ype
,
{
4
,
3
,
3
,
3
}});
auto
x
=
mm
->
add_parameter
(
"x"
,
migraphx
::
shape
{
DT
ype
,
{
4
,
3
,
3
,
3
}});
mm
->
add_instruction
(
migraphx
::
make_op
(
"abs"
),
x
);
return
p
;
}
};
template
struct
test_abs
<
migraphx
::
shape
::
fp8e4m3fnuz_type
>;
template
struct
test_abs
<
migraphx
::
shape
::
half_type
>;
template
struct
test_abs
<
migraphx
::
shape
::
float_type
>;
Prev
1
…
13
14
15
16
17
18
19
20
21
…
23
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