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
22aadbd6
Commit
22aadbd6
authored
Nov 27, 2023
by
Umang Yadav
Browse files
add some MLIR fp8 tests for convolutions
parent
afe12765
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
41 additions
and
27 deletions
+41
-27
test/verify/test_conv_add_1x1_diff_strides.cpp
test/verify/test_conv_add_1x1_diff_strides.cpp
+9
-7
test/verify/test_conv_bn.cpp
test/verify/test_conv_bn.cpp
+10
-6
test/verify/test_conv_bn_relu_pooling.cpp
test/verify/test_conv_bn_relu_pooling.cpp
+10
-6
test/verify/test_conv_bn_relu_pooling2.cpp
test/verify/test_conv_bn_relu_pooling2.cpp
+12
-8
No files found.
test/verify/test_conv_add_1x1_diff_strides.cpp
View file @
22aadbd6
...
...
@@ -27,18 +27,17 @@
#include <migraphx/generate.hpp>
#include <migraphx/make_op.hpp>
struct
test_conv_add_1x1_diff_strides
:
verify_program
<
test_conv_add_1x1_diff_strides
>
template
<
migraphx
::
shape
::
type_t
DType
>
struct
test_conv_add_1x1_diff_strides
:
verify_program
<
test_conv_add_1x1_diff_strides
<
DType
>>
{
migraphx
::
program
create_program
()
const
{
migraphx
::
program
p
;
auto
*
mm
=
p
.
get_main_module
();
auto
x
=
mm
->
add_parameter
(
"x"
,
{
migraphx
::
shape
::
float_type
,
{
1
,
8
,
2
,
2
}});
auto
w
=
mm
->
add_literal
(
migraphx
::
generate_literal
({
migraphx
::
shape
::
float_type
,
{
2
,
8
,
1
,
1
}},
1
));
auto
y
=
mm
->
add_parameter
(
"y"
,
{
migraphx
::
shape
::
float_type
,
{
1
,
8
,
4
,
4
}});
auto
v
=
mm
->
add_literal
(
migraphx
::
generate_literal
({
migraphx
::
shape
::
float_type
,
{
2
,
8
,
1
,
1
}},
2
));
auto
x
=
mm
->
add_parameter
(
"x"
,
{
DType
,
{
1
,
8
,
2
,
2
}});
auto
w
=
mm
->
add_literal
(
migraphx
::
generate_literal
({
DType
,
{
2
,
8
,
1
,
1
}},
1
));
auto
y
=
mm
->
add_parameter
(
"y"
,
{
DType
,
{
1
,
8
,
4
,
4
}});
auto
v
=
mm
->
add_literal
(
migraphx
::
generate_literal
({
DType
,
{
2
,
8
,
1
,
1
}},
2
));
auto
conv1
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"convolution"
),
x
,
w
);
auto
conv2
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"convolution"
,
{{
"padding"
,
{
0
,
0
}},
{
"stride"
,
{
2
,
2
}}}),
y
,
v
);
...
...
@@ -47,3 +46,6 @@ struct test_conv_add_1x1_diff_strides : verify_program<test_conv_add_1x1_diff_st
return
p
;
}
};
template
struct
test_conv_add_1x1_diff_strides
<
migraphx
::
shape
::
float_type
>;
template
struct
test_conv_add_1x1_diff_strides
<
migraphx
::
shape
::
fp8e4m3fnuz_type
>;
test/verify/test_conv_bn.cpp
View file @
22aadbd6
...
...
@@ -29,16 +29,17 @@
#include <migraphx/instruction.hpp>
#include <migraphx/common.hpp>
struct
test_conv_bn
:
verify_program
<
test_conv_bn
>
template
<
migraphx
::
shape
::
type_t
DType
>
struct
test_conv_bn
:
verify_program
<
test_conv_bn
<
DType
>>
{
migraphx
::
program
create_program
()
const
{
migraphx
::
program
p
;
auto
*
mm
=
p
.
get_main_module
();
migraphx
::
shape
xs
{
migraphx
::
shape
::
float_t
ype
,
{
1
,
3
,
224
,
224
}};
migraphx
::
shape
ws
{
migraphx
::
shape
::
float_t
ype
,
{
64
,
3
,
7
,
7
}};
migraphx
::
shape
vars
{
migraphx
::
shape
::
float_t
ype
,
{
64
}};
migraphx
::
shape
xs
{
DT
ype
,
{
1
,
3
,
224
,
224
}};
migraphx
::
shape
ws
{
DT
ype
,
{
64
,
3
,
7
,
7
}};
migraphx
::
shape
vars
{
DT
ype
,
{
64
}};
auto
x
=
mm
->
add_parameter
(
"x"
,
xs
);
auto
w
=
mm
->
add_parameter
(
"w"
,
ws
);
// non-symmetrical tiling
...
...
@@ -53,8 +54,8 @@ struct test_conv_bn : verify_program<test_conv_bn>
auto
mean
=
mm
->
add_literal
(
migraphx
::
abs
(
migraphx
::
generate_literal
(
vars
,
3
)));
auto
variance
=
mm
->
add_literal
(
migraphx
::
abs
(
migraphx
::
generate_literal
(
vars
,
4
)));
auto
rt
=
mm
->
add_literal
(
migraphx
::
literal
{
migraphx
::
shape
::
float_t
ype
,
{
0.5
}});
auto
eps
=
mm
->
add_literal
(
migraphx
::
literal
{
migraphx
::
shape
::
float_t
ype
,
{
1e-5
f
}});
auto
rt
=
mm
->
add_literal
(
migraphx
::
literal
{
DT
ype
,
{
0.5
}});
auto
eps
=
mm
->
add_literal
(
migraphx
::
literal
{
DT
ype
,
{
1e-5
f
}});
auto
usq_scale
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"unsqueeze"
,
{{
"axes"
,
{
1
,
2
}}}),
scale
);
...
...
@@ -74,3 +75,6 @@ struct test_conv_bn : verify_program<test_conv_bn>
return
p
;
}
};
template
struct
test_conv_bn
<
migraphx
::
shape
::
float_type
>;
template
struct
test_conv_bn
<
migraphx
::
shape
::
fp8e4m3fnuz_type
>;
test/verify/test_conv_bn_relu_pooling.cpp
View file @
22aadbd6
...
...
@@ -30,16 +30,17 @@
#include <migraphx/instruction.hpp>
#include <migraphx/common.hpp>
struct
test_conv_bn_relu_pooling
:
verify_program
<
test_conv_bn_relu_pooling
>
template
<
migraphx
::
shape
::
type_t
DType
>
struct
test_conv_bn_relu_pooling
:
verify_program
<
test_conv_bn_relu_pooling
<
DType
>>
{
migraphx
::
program
create_program
()
const
{
migraphx
::
program
p
;
auto
*
mm
=
p
.
get_main_module
();
migraphx
::
shape
xs
{
migraphx
::
shape
::
float_t
ype
,
{
1
,
3
,
224
,
224
}};
migraphx
::
shape
ws
{
migraphx
::
shape
::
float_t
ype
,
{
64
,
3
,
7
,
7
}};
migraphx
::
shape
vars
{
migraphx
::
shape
::
float_t
ype
,
{
64
}};
migraphx
::
shape
xs
{
DT
ype
,
{
1
,
3
,
224
,
224
}};
migraphx
::
shape
ws
{
DT
ype
,
{
64
,
3
,
7
,
7
}};
migraphx
::
shape
vars
{
DT
ype
,
{
64
}};
auto
x
=
mm
->
add_parameter
(
"x"
,
xs
);
auto
w
=
mm
->
add_parameter
(
"w"
,
ws
);
auto
conv
=
mm
->
add_instruction
(
...
...
@@ -52,8 +53,8 @@ struct test_conv_bn_relu_pooling : verify_program<test_conv_bn_relu_pooling>
auto
mean
=
mm
->
add_literal
(
migraphx
::
abs
(
migraphx
::
generate_literal
(
vars
,
3
)));
auto
variance
=
mm
->
add_literal
(
migraphx
::
abs
(
migraphx
::
generate_literal
(
vars
,
4
)));
auto
rt
=
mm
->
add_literal
(
migraphx
::
literal
{
migraphx
::
shape
::
float_t
ype
,
{
0.5
}});
auto
eps
=
mm
->
add_literal
(
migraphx
::
literal
{
migraphx
::
shape
::
float_t
ype
,
{
1e-5
f
}});
auto
rt
=
mm
->
add_literal
(
migraphx
::
literal
{
DT
ype
,
{
0.5
}});
auto
eps
=
mm
->
add_literal
(
migraphx
::
literal
{
DT
ype
,
{
1e-5
f
}});
auto
usq_scale
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"unsqueeze"
,
{{
"axes"
,
{
1
,
2
}}}),
scale
);
...
...
@@ -81,3 +82,6 @@ struct test_conv_bn_relu_pooling : verify_program<test_conv_bn_relu_pooling>
return
p
;
}
};
template
struct
test_conv_bn_relu_pooling
<
migraphx
::
shape
::
float_type
>;
template
struct
test_conv_bn_relu_pooling
<
migraphx
::
shape
::
fp8e4m3fnuz_type
>;
test/verify/test_conv_bn_relu_pooling2.cpp
View file @
22aadbd6
...
...
@@ -30,21 +30,22 @@
#include <migraphx/instruction.hpp>
#include <migraphx/common.hpp>
struct
test_conv_bn_relu_pooling2
:
verify_program
<
test_conv_bn_relu_pooling2
>
template
<
migraphx
::
shape
::
type_t
DType
>
struct
test_conv_bn_relu_pooling2
:
verify_program
<
test_conv_bn_relu_pooling2
<
DType
>>
{
static
migraphx
::
instruction_ref
add_bn
(
migraphx
::
module
&
m
,
migraphx
::
instruction_ref
x
)
{
auto
bn_lens
=
x
->
get_shape
().
lens
();
auto
c_len
=
bn_lens
.
at
(
1
);
migraphx
::
shape
vars
{
migraphx
::
shape
::
float_t
ype
,
{
c_len
}};
migraphx
::
shape
vars
{
DT
ype
,
{
c_len
}};
auto
scale
=
m
.
add_literal
(
migraphx
::
abs
(
migraphx
::
generate_literal
(
vars
,
1
+
c_len
)));
auto
bias
=
m
.
add_literal
(
migraphx
::
abs
(
migraphx
::
generate_literal
(
vars
,
2
+
c_len
)));
auto
mean
=
m
.
add_literal
(
migraphx
::
abs
(
migraphx
::
generate_literal
(
vars
,
3
+
c_len
)));
auto
variance
=
m
.
add_literal
(
migraphx
::
abs
(
migraphx
::
generate_literal
(
vars
,
4
+
c_len
)));
auto
rt
=
m
.
add_literal
(
migraphx
::
literal
{
migraphx
::
shape
::
float_t
ype
,
{
0.5
}});
auto
eps
=
m
.
add_literal
(
migraphx
::
literal
{
migraphx
::
shape
::
float_t
ype
,
{
1e-5
f
}});
auto
rt
=
m
.
add_literal
(
migraphx
::
literal
{
DT
ype
,
{
0.5
}});
auto
eps
=
m
.
add_literal
(
migraphx
::
literal
{
DT
ype
,
{
1e-5
f
}});
auto
usq_scale
=
m
.
add_instruction
(
migraphx
::
make_op
(
"unsqueeze"
,
{{
"axes"
,
{
1
,
2
}}}),
scale
);
...
...
@@ -66,10 +67,10 @@ struct test_conv_bn_relu_pooling2 : verify_program<test_conv_bn_relu_pooling2>
migraphx
::
program
p
;
auto
*
mm
=
p
.
get_main_module
();
migraphx
::
shape
xs1
{
migraphx
::
shape
::
float_t
ype
,
{
1
,
512
,
7
,
7
}};
migraphx
::
shape
xs2
{
migraphx
::
shape
::
float_t
ype
,
{
1
,
1024
,
14
,
14
}};
migraphx
::
shape
ws1
{
migraphx
::
shape
::
float_t
ype
,
{
2048
,
512
,
1
,
1
}};
migraphx
::
shape
ws2
{
migraphx
::
shape
::
float_t
ype
,
{
2048
,
1024
,
1
,
1
}};
migraphx
::
shape
xs1
{
DT
ype
,
{
1
,
512
,
7
,
7
}};
migraphx
::
shape
xs2
{
DT
ype
,
{
1
,
1024
,
14
,
14
}};
migraphx
::
shape
ws1
{
DT
ype
,
{
2048
,
512
,
1
,
1
}};
migraphx
::
shape
ws2
{
DT
ype
,
{
2048
,
1024
,
1
,
1
}};
auto
x1
=
mm
->
add_parameter
(
"x1"
,
xs1
);
auto
w1
=
mm
->
add_parameter
(
"w1"
,
ws1
);
auto
conv1
=
mm
->
add_instruction
(
...
...
@@ -97,3 +98,6 @@ struct test_conv_bn_relu_pooling2 : verify_program<test_conv_bn_relu_pooling2>
return
p
;
}
};
template
struct
test_conv_bn_relu_pooling2
<
migraphx
::
shape
::
float_type
>;
template
struct
test_conv_bn_relu_pooling2
<
migraphx
::
shape
::
fp8e4m3fnuz_type
>;
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