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
eafd55de
Unverified
Commit
eafd55de
authored
Dec 01, 2023
by
Umang Yadav
Committed by
GitHub
Dec 01, 2023
Browse files
FP8 GPU implementation (#2455)
parent
785ff7d7
Changes
60
Hide whitespace changes
Inline
Side-by-side
Showing
20 changed files
with
163 additions
and
44 deletions
+163
-44
test/verify/test_literal_limits.cpp
test/verify/test_literal_limits.cpp
+9
-3
test/verify/test_log.cpp
test/verify/test_log.cpp
+7
-2
test/verify/test_min_max.cpp
test/verify/test_min_max.cpp
+2
-0
test/verify/test_nearbyint.cpp
test/verify/test_nearbyint.cpp
+2
-0
test/verify/test_pad.cpp
test/verify/test_pad.cpp
+8
-2
test/verify/test_pow.cpp
test/verify/test_pow.cpp
+8
-3
test/verify/test_reduce_add.cpp
test/verify/test_reduce_add.cpp
+7
-2
test/verify/test_reduce_mean_nhwc.cpp
test/verify/test_reduce_mean_nhwc.cpp
+8
-4
test/verify/test_reduce_op_large.cpp
test/verify/test_reduce_op_large.cpp
+16
-0
test/verify/test_reduce_op_small.cpp
test/verify/test_reduce_op_small.cpp
+16
-0
test/verify/test_roialign.cpp
test/verify/test_roialign.cpp
+12
-7
test/verify/test_rsqrt.cpp
test/verify/test_rsqrt.cpp
+14
-6
test/verify/test_scatternd.cpp
test/verify/test_scatternd.cpp
+9
-4
test/verify/test_sin.cpp
test/verify/test_sin.cpp
+7
-2
test/verify/test_sinh.cpp
test/verify/test_sinh.cpp
+7
-2
test/verify/test_softmax.cpp
test/verify/test_softmax.cpp
+4
-0
test/verify/test_sqrt.cpp
test/verify/test_sqrt.cpp
+7
-2
test/verify/test_tan.cpp
test/verify/test_tan.cpp
+7
-2
test/verify/test_tanh.cpp
test/verify/test_tanh.cpp
+7
-2
test/verify/test_where.cpp
test/verify/test_where.cpp
+6
-1
No files found.
test/verify/test_literal_limits.cpp
View file @
eafd55de
...
@@ -26,6 +26,7 @@
...
@@ -26,6 +26,7 @@
#include <migraphx/program.hpp>
#include <migraphx/program.hpp>
#include <migraphx/make_op.hpp>
#include <migraphx/make_op.hpp>
#include <limits>
#include <limits>
#include <type_traits>
template
<
migraphx
::
shape
::
type_t
Q
,
typename
T
>
template
<
migraphx
::
shape
::
type_t
Q
,
typename
T
>
struct
test_literal_limits
:
verify_program
<
test_literal_limits
<
Q
,
T
>>
struct
test_literal_limits
:
verify_program
<
test_literal_limits
<
Q
,
T
>>
...
@@ -33,9 +34,13 @@ struct test_literal_limits : verify_program<test_literal_limits<Q, T>>
...
@@ -33,9 +34,13 @@ struct test_literal_limits : verify_program<test_literal_limits<Q, T>>
migraphx
::
program
create_program
()
const
migraphx
::
program
create_program
()
const
{
{
migraphx
::
program
p
;
migraphx
::
program
p
;
auto
*
mm
=
p
.
get_main_module
();
auto
*
mm
=
p
.
get_main_module
();
auto
input_s
=
migraphx
::
shape
(
Q
,
{
3
,
1
});
auto
input_s
=
migraphx
::
shape
(
Q
,
{
3
,
1
});
auto
infinity_val
=
std
::
numeric_limits
<
T
>::
infinity
();
T
infinity_val
{
0
};
if
constexpr
(
std
::
numeric_limits
<
T
>::
has_infinity
and
std
::
is_floating_point
<
T
>
{})
{
infinity_val
=
std
::
numeric_limits
<
T
>::
infinity
();
}
std
::
vector
<
T
>
s_data
{
std
::
vector
<
T
>
s_data
{
infinity_val
,
static_cast
<
T
>
(
-
infinity_val
),
std
::
numeric_limits
<
T
>::
quiet_NaN
()};
infinity_val
,
static_cast
<
T
>
(
-
infinity_val
),
std
::
numeric_limits
<
T
>::
quiet_NaN
()};
...
@@ -52,3 +57,4 @@ template struct test_literal_limits<migraphx::shape::double_type, double>;
...
@@ -52,3 +57,4 @@ template struct test_literal_limits<migraphx::shape::double_type, double>;
template
struct
test_literal_limits
<
migraphx
::
shape
::
half_type
,
migraphx
::
half
>;
template
struct
test_literal_limits
<
migraphx
::
shape
::
half_type
,
migraphx
::
half
>;
template
struct
test_literal_limits
<
migraphx
::
shape
::
int32_type
,
int32_t
>;
template
struct
test_literal_limits
<
migraphx
::
shape
::
int32_type
,
int32_t
>;
template
struct
test_literal_limits
<
migraphx
::
shape
::
int8_type
,
int8_t
>;
template
struct
test_literal_limits
<
migraphx
::
shape
::
int8_type
,
int8_t
>;
template
struct
test_literal_limits
<
migraphx
::
shape
::
fp8e4m3fnuz_type
,
migraphx
::
fp8
::
fp8e4m3fnuz
>;
test/verify/test_log.cpp
View file @
eafd55de
...
@@ -27,15 +27,20 @@
...
@@ -27,15 +27,20 @@
#include <migraphx/generate.hpp>
#include <migraphx/generate.hpp>
#include <migraphx/make_op.hpp>
#include <migraphx/make_op.hpp>
struct
test_log
:
verify_program
<
test_log
>
template
<
migraphx
::
shape
::
type_t
DType
>
struct
test_log
:
verify_program
<
test_log
<
DType
>>
{
{
migraphx
::
program
create_program
()
const
migraphx
::
program
create_program
()
const
{
{
migraphx
::
program
p
;
migraphx
::
program
p
;
auto
*
mm
=
p
.
get_main_module
();
auto
*
mm
=
p
.
get_main_module
();
migraphx
::
shape
s
{
migraphx
::
shape
::
float_t
ype
,
{
6
}};
migraphx
::
shape
s
{
DT
ype
,
{
6
}};
auto
x
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"abs"
),
mm
->
add_parameter
(
"x"
,
s
));
auto
x
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"abs"
),
mm
->
add_parameter
(
"x"
,
s
));
mm
->
add_instruction
(
migraphx
::
make_op
(
"log"
),
x
);
mm
->
add_instruction
(
migraphx
::
make_op
(
"log"
),
x
);
return
p
;
return
p
;
}
}
};
};
template
struct
test_log
<
migraphx
::
shape
::
float_type
>;
template
struct
test_log
<
migraphx
::
shape
::
half_type
>;
template
struct
test_log
<
migraphx
::
shape
::
fp8e4m3fnuz_type
>;
test/verify/test_min_max.cpp
View file @
eafd55de
...
@@ -46,7 +46,9 @@ struct test_min_max : verify_program<test_min_max<Op, T>>
...
@@ -46,7 +46,9 @@ struct test_min_max : verify_program<test_min_max<Op, T>>
template
struct
test_min_max
<
migraphx
::
op
::
max
,
migraphx
::
shape
::
float_type
>;
template
struct
test_min_max
<
migraphx
::
op
::
max
,
migraphx
::
shape
::
float_type
>;
template
struct
test_min_max
<
migraphx
::
op
::
max
,
migraphx
::
shape
::
half_type
>;
template
struct
test_min_max
<
migraphx
::
op
::
max
,
migraphx
::
shape
::
half_type
>;
template
struct
test_min_max
<
migraphx
::
op
::
max
,
migraphx
::
shape
::
double_type
>;
template
struct
test_min_max
<
migraphx
::
op
::
max
,
migraphx
::
shape
::
double_type
>;
template
struct
test_min_max
<
migraphx
::
op
::
max
,
migraphx
::
shape
::
fp8e4m3fnuz_type
>;
template
struct
test_min_max
<
migraphx
::
op
::
min
,
migraphx
::
shape
::
float_type
>;
template
struct
test_min_max
<
migraphx
::
op
::
min
,
migraphx
::
shape
::
float_type
>;
template
struct
test_min_max
<
migraphx
::
op
::
min
,
migraphx
::
shape
::
half_type
>;
template
struct
test_min_max
<
migraphx
::
op
::
min
,
migraphx
::
shape
::
half_type
>;
template
struct
test_min_max
<
migraphx
::
op
::
min
,
migraphx
::
shape
::
double_type
>;
template
struct
test_min_max
<
migraphx
::
op
::
min
,
migraphx
::
shape
::
double_type
>;
template
struct
test_min_max
<
migraphx
::
op
::
min
,
migraphx
::
shape
::
fp8e4m3fnuz_type
>;
test/verify/test_nearbyint.cpp
View file @
eafd55de
...
@@ -26,6 +26,7 @@
...
@@ -26,6 +26,7 @@
#include <migraphx/program.hpp>
#include <migraphx/program.hpp>
#include <migraphx/generate.hpp>
#include <migraphx/generate.hpp>
#include <migraphx/make_op.hpp>
#include <migraphx/make_op.hpp>
#include <migraphx/float8.hpp>
template
<
class
T
>
template
<
class
T
>
struct
test_nearbyint
:
verify_program
<
test_nearbyint
<
T
>>
struct
test_nearbyint
:
verify_program
<
test_nearbyint
<
T
>>
...
@@ -45,3 +46,4 @@ struct test_nearbyint : verify_program<test_nearbyint<T>>
...
@@ -45,3 +46,4 @@ struct test_nearbyint : verify_program<test_nearbyint<T>>
template
struct
test_nearbyint
<
migraphx
::
half
>;
template
struct
test_nearbyint
<
migraphx
::
half
>;
template
struct
test_nearbyint
<
float
>;
template
struct
test_nearbyint
<
float
>;
template
struct
test_nearbyint
<
migraphx
::
fp8
::
fp8e4m3fnuz
>;
test/verify/test_pad.cpp
View file @
eafd55de
...
@@ -27,13 +27,14 @@
...
@@ -27,13 +27,14 @@
#include <migraphx/generate.hpp>
#include <migraphx/generate.hpp>
#include <migraphx/make_op.hpp>
#include <migraphx/make_op.hpp>
struct
test_pad
:
verify_program
<
test_pad
>
template
<
migraphx
::
shape
::
type_t
DType
>
struct
test_pad
:
verify_program
<
test_pad
<
DType
>>
{
{
migraphx
::
program
create_program
()
const
migraphx
::
program
create_program
()
const
{
{
migraphx
::
program
p
;
migraphx
::
program
p
;
auto
*
mm
=
p
.
get_main_module
();
auto
*
mm
=
p
.
get_main_module
();
migraphx
::
shape
s0
{
migraphx
::
shape
::
int32_t
ype
,
{
1
,
96
,
165
,
165
}};
migraphx
::
shape
s0
{
DT
ype
,
{
1
,
96
,
165
,
165
}};
std
::
vector
<
int64_t
>
pads0
=
{
0
,
0
,
0
,
0
,
0
,
0
,
1
,
1
};
std
::
vector
<
int64_t
>
pads0
=
{
0
,
0
,
0
,
0
,
0
,
0
,
1
,
1
};
std
::
vector
<
int64_t
>
pads1
=
{
0
,
0
,
0
,
0
,
1
,
1
,
1
,
1
};
std
::
vector
<
int64_t
>
pads1
=
{
0
,
0
,
0
,
0
,
1
,
1
,
1
,
1
};
std
::
vector
<
int64_t
>
pads2
=
{
1
,
1
,
1
,
1
,
0
,
0
,
0
,
0
};
std
::
vector
<
int64_t
>
pads2
=
{
1
,
1
,
1
,
1
,
0
,
0
,
0
,
0
};
...
@@ -46,3 +47,8 @@ struct test_pad : verify_program<test_pad>
...
@@ -46,3 +47,8 @@ struct test_pad : verify_program<test_pad>
return
p
;
return
p
;
}
}
};
};
template
struct
test_pad
<
migraphx
::
shape
::
int32_type
>;
template
struct
test_pad
<
migraphx
::
shape
::
float_type
>;
template
struct
test_pad
<
migraphx
::
shape
::
half_type
>;
template
struct
test_pad
<
migraphx
::
shape
::
fp8e4m3fnuz_type
>;
test/verify/test_pow.cpp
View file @
eafd55de
...
@@ -27,13 +27,15 @@
...
@@ -27,13 +27,15 @@
#include <migraphx/generate.hpp>
#include <migraphx/generate.hpp>
#include <migraphx/make_op.hpp>
#include <migraphx/make_op.hpp>
struct
test_pow
:
verify_program
<
test_pow
>
template
<
typename
CType
>
struct
test_pow
:
verify_program
<
test_pow
<
CType
>>
{
{
migraphx
::
program
create_program
()
const
migraphx
::
program
create_program
()
const
{
{
migraphx
::
program
p
;
migraphx
::
program
p
;
auto
*
mm
=
p
.
get_main_module
();
migraphx
::
shape
::
type_t
dtype
=
migraphx
::
shape
::
get_type
<
CType
>
();
migraphx
::
shape
s
{
migraphx
::
shape
::
float_type
,
{
6
}};
auto
*
mm
=
p
.
get_main_module
();
migraphx
::
shape
s
{
dtype
,
{
6
}};
std
::
vector
<
float
>
vec_e
(
s
.
elements
(),
2.0
f
);
std
::
vector
<
float
>
vec_e
(
s
.
elements
(),
2.0
f
);
auto
b
=
mm
->
add_parameter
(
"x"
,
s
);
auto
b
=
mm
->
add_parameter
(
"x"
,
s
);
auto
e
=
mm
->
add_literal
(
migraphx
::
literal
(
s
,
vec_e
));
auto
e
=
mm
->
add_literal
(
migraphx
::
literal
(
s
,
vec_e
));
...
@@ -41,3 +43,6 @@ struct test_pow : verify_program<test_pow>
...
@@ -41,3 +43,6 @@ struct test_pow : verify_program<test_pow>
return
p
;
return
p
;
}
}
};
};
template
struct
test_pow
<
float
>;
template
struct
test_pow
<
migraphx
::
half
>;
template
struct
test_pow
<
migraphx
::
fp8
::
fp8e4m3fnuz
>;
test/verify/test_reduce_add.cpp
View file @
eafd55de
...
@@ -27,14 +27,16 @@
...
@@ -27,14 +27,16 @@
#include <migraphx/generate.hpp>
#include <migraphx/generate.hpp>
#include <migraphx/make_op.hpp>
#include <migraphx/make_op.hpp>
#include <migraphx/instruction.hpp>
#include <migraphx/instruction.hpp>
#include <migraphx/shape.hpp>
struct
test_reduce_add
:
verify_program
<
test_reduce_add
>
template
<
migraphx
::
shape
::
type_t
DType
>
struct
test_reduce_add
:
verify_program
<
test_reduce_add
<
DType
>>
{
{
migraphx
::
program
create_program
()
const
migraphx
::
program
create_program
()
const
{
{
migraphx
::
program
p
;
migraphx
::
program
p
;
auto
*
mm
=
p
.
get_main_module
();
auto
*
mm
=
p
.
get_main_module
();
migraphx
::
shape
s
{
migraphx
::
shape
::
float_t
ype
,
{
4
,
1000
,
2
,
2
}};
migraphx
::
shape
s
{
DT
ype
,
{
4
,
1000
,
2
,
2
}};
migraphx
::
shape
bs
{
migraphx
::
shape
::
half_type
,
{
1
,
32
,
128
}};
migraphx
::
shape
bs
{
migraphx
::
shape
::
half_type
,
{
1
,
32
,
128
}};
auto
x
=
mm
->
add_parameter
(
"x"
,
s
);
auto
x
=
mm
->
add_parameter
(
"x"
,
s
);
auto
reduce_mean
=
auto
reduce_mean
=
...
@@ -46,3 +48,6 @@ struct test_reduce_add : verify_program<test_reduce_add>
...
@@ -46,3 +48,6 @@ struct test_reduce_add : verify_program<test_reduce_add>
return
p
;
return
p
;
};
};
};
};
template
struct
test_reduce_add
<
migraphx
::
shape
::
float_type
>;
template
struct
test_reduce_add
<
migraphx
::
shape
::
fp8e4m3fnuz_type
>;
test/verify/test_reduce_mean_nhwc.cpp
View file @
eafd55de
...
@@ -28,14 +28,14 @@
...
@@ -28,14 +28,14 @@
#include <migraphx/make_op.hpp>
#include <migraphx/make_op.hpp>
#include <migraphx/instruction.hpp>
#include <migraphx/instruction.hpp>
struct
test_reduce_mean_nhwc
:
verify_program
<
test_reduce_mean_nhwc
>
template
<
migraphx
::
shape
::
type_t
DType
>
struct
test_reduce_mean_nhwc
:
verify_program
<
test_reduce_mean_nhwc
<
DType
>>
{
{
migraphx
::
program
create_program
()
const
migraphx
::
program
create_program
()
const
{
{
migraphx
::
program
p
;
migraphx
::
program
p
;
auto
*
mm
=
p
.
get_main_module
();
auto
*
mm
=
p
.
get_main_module
();
auto
s
=
migraphx
::
shape
::
from_permutation
(
auto
s
=
migraphx
::
shape
::
from_permutation
(
DType
,
{
4
,
256
,
2
,
2
},
{
0
,
2
,
3
,
1
});
migraphx
::
shape
::
float_type
,
{
4
,
256
,
2
,
2
},
{
0
,
2
,
3
,
1
});
auto
x
=
mm
->
add_parameter
(
"x"
,
s
);
auto
x
=
mm
->
add_parameter
(
"x"
,
s
);
auto
reduce
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"reduce_mean"
,
{{
"axes"
,
{
1
}}}),
x
);
auto
reduce
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"reduce_mean"
,
{{
"axes"
,
{
1
}}}),
x
);
auto
abs
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"abs"
),
reduce
);
auto
abs
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"abs"
),
reduce
);
...
@@ -44,3 +44,7 @@ struct test_reduce_mean_nhwc : verify_program<test_reduce_mean_nhwc>
...
@@ -44,3 +44,7 @@ struct test_reduce_mean_nhwc : verify_program<test_reduce_mean_nhwc>
return
p
;
return
p
;
};
};
};
};
template
struct
test_reduce_mean_nhwc
<
migraphx
::
shape
::
float_type
>;
template
struct
test_reduce_mean_nhwc
<
migraphx
::
shape
::
half_type
>;
template
struct
test_reduce_mean_nhwc
<
migraphx
::
shape
::
fp8e4m3fnuz_type
>;
test/verify/test_reduce_op_large.cpp
View file @
eafd55de
...
@@ -51,6 +51,22 @@ template struct test_reduce_op_large<migraphx::op::reduce_min, 1, migraphx::shap
...
@@ -51,6 +51,22 @@ template struct test_reduce_op_large<migraphx::op::reduce_min, 1, migraphx::shap
template
struct
test_reduce_op_large
<
migraphx
::
op
::
reduce_prod
,
2
,
migraphx
::
shape
::
float_type
>;
template
struct
test_reduce_op_large
<
migraphx
::
op
::
reduce_prod
,
2
,
migraphx
::
shape
::
float_type
>;
template
struct
test_reduce_op_large
<
migraphx
::
op
::
reduce_sum
,
1
,
migraphx
::
shape
::
float_type
>;
template
struct
test_reduce_op_large
<
migraphx
::
op
::
reduce_sum
,
1
,
migraphx
::
shape
::
float_type
>;
template
struct
test_reduce_op_large
<
migraphx
::
op
::
reduce_max
,
1
,
migraphx
::
shape
::
fp8e4m3fnuz_type
>;
template
struct
test_reduce_op_large
<
migraphx
::
op
::
reduce_mean
,
1
,
migraphx
::
shape
::
fp8e4m3fnuz_type
>;
template
struct
test_reduce_op_large
<
migraphx
::
op
::
reduce_min
,
1
,
migraphx
::
shape
::
fp8e4m3fnuz_type
>;
template
struct
test_reduce_op_large
<
migraphx
::
op
::
reduce_prod
,
2
,
migraphx
::
shape
::
fp8e4m3fnuz_type
>;
template
struct
test_reduce_op_large
<
migraphx
::
op
::
reduce_sum
,
1
,
migraphx
::
shape
::
fp8e4m3fnuz_type
>;
struct
test_reduce_mean_1
:
verify_program
<
test_reduce_mean_1
>
struct
test_reduce_mean_1
:
verify_program
<
test_reduce_mean_1
>
{
{
migraphx
::
program
create_program
()
const
migraphx
::
program
create_program
()
const
...
...
test/verify/test_reduce_op_small.cpp
View file @
eafd55de
...
@@ -56,3 +56,19 @@ template struct test_reduce_op_small<migraphx::op::reduce_mean, 2, migraphx::sha
...
@@ -56,3 +56,19 @@ template struct test_reduce_op_small<migraphx::op::reduce_mean, 2, migraphx::sha
template
struct
test_reduce_op_small
<
migraphx
::
op
::
reduce_max
,
2
,
migraphx
::
shape
::
half_type
>;
template
struct
test_reduce_op_small
<
migraphx
::
op
::
reduce_max
,
2
,
migraphx
::
shape
::
half_type
>;
template
struct
test_reduce_op_small
<
migraphx
::
op
::
reduce_min
,
2
,
migraphx
::
shape
::
half_type
>;
template
struct
test_reduce_op_small
<
migraphx
::
op
::
reduce_min
,
2
,
migraphx
::
shape
::
half_type
>;
template
struct
test_reduce_op_small
<
migraphx
::
op
::
reduce_prod
,
-
2
,
migraphx
::
shape
::
half_type
>;
template
struct
test_reduce_op_small
<
migraphx
::
op
::
reduce_prod
,
-
2
,
migraphx
::
shape
::
half_type
>;
template
struct
test_reduce_op_small
<
migraphx
::
op
::
reduce_sum
,
2
,
migraphx
::
shape
::
fp8e4m3fnuz_type
>;
template
struct
test_reduce_op_small
<
migraphx
::
op
::
reduce_mean
,
2
,
migraphx
::
shape
::
fp8e4m3fnuz_type
>;
template
struct
test_reduce_op_small
<
migraphx
::
op
::
reduce_max
,
2
,
migraphx
::
shape
::
fp8e4m3fnuz_type
>;
template
struct
test_reduce_op_small
<
migraphx
::
op
::
reduce_min
,
2
,
migraphx
::
shape
::
fp8e4m3fnuz_type
>;
template
struct
test_reduce_op_small
<
migraphx
::
op
::
reduce_prod
,
-
2
,
migraphx
::
shape
::
fp8e4m3fnuz_type
>;
test/verify/test_roialign.cpp
View file @
eafd55de
...
@@ -27,15 +27,16 @@
...
@@ -27,15 +27,16 @@
#include <migraphx/generate.hpp>
#include <migraphx/generate.hpp>
#include <migraphx/make_op.hpp>
#include <migraphx/make_op.hpp>
struct
test_roialign
:
verify_program
<
test_roialign
>
template
<
migraphx
::
shape
::
type_t
DType
>
struct
test_roialign
:
verify_program
<
test_roialign
<
DType
>>
{
{
migraphx
::
program
create_program
()
const
migraphx
::
program
create_program
()
const
{
{
migraphx
::
program
p
;
migraphx
::
program
p
;
auto
*
mm
=
p
.
get_main_module
();
auto
*
mm
=
p
.
get_main_module
();
migraphx
::
shape
x_s
{
migraphx
::
shape
::
float_t
ype
,
{
5
,
4
,
10
,
10
}};
migraphx
::
shape
x_s
{
DT
ype
,
{
5
,
4
,
10
,
10
}};
migraphx
::
shape
roi_s
{
migraphx
::
shape
::
float_t
ype
,
{
5
,
4
}};
migraphx
::
shape
roi_s
{
DT
ype
,
{
5
,
4
}};
migraphx
::
shape
ind_s
{
migraphx
::
shape
::
int64_type
,
{
5
}};
migraphx
::
shape
ind_s
{
migraphx
::
shape
::
int64_type
,
{
5
}};
std
::
vector
<
int64_t
>
ind_vec
=
{
0
,
2
,
3
,
4
,
1
};
std
::
vector
<
int64_t
>
ind_vec
=
{
0
,
2
,
3
,
4
,
1
};
...
@@ -44,10 +45,10 @@ struct test_roialign : verify_program<test_roialign>
...
@@ -44,10 +45,10 @@ struct test_roialign : verify_program<test_roialign>
auto
roi
=
mm
->
add_parameter
(
"roi"
,
roi_s
);
auto
roi
=
mm
->
add_parameter
(
"roi"
,
roi_s
);
auto
ind
=
mm
->
add_literal
(
migraphx
::
literal
(
ind_s
,
ind_vec
));
auto
ind
=
mm
->
add_literal
(
migraphx
::
literal
(
ind_s
,
ind_vec
));
auto
r
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"roialign"
,
auto
r
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"roialign"
,
{{
"spatial_scale"
,
1.0
},
{{
"spatial_scale"
,
1.0
},
{
"output_height"
,
5
},
{
"output_height"
,
5
},
{
"output_width"
,
5
},
{
"output_width"
,
5
},
{
"sampling_ratio"
,
2
}}),
{
"sampling_ratio"
,
2
}}),
x
,
x
,
roi
,
roi
,
ind
);
ind
);
...
@@ -56,3 +57,7 @@ struct test_roialign : verify_program<test_roialign>
...
@@ -56,3 +57,7 @@ struct test_roialign : verify_program<test_roialign>
return
p
;
return
p
;
}
}
};
};
template
struct
test_roialign
<
migraphx
::
shape
::
float_type
>;
template
struct
test_roialign
<
migraphx
::
shape
::
half_type
>;
template
struct
test_roialign
<
migraphx
::
shape
::
fp8e4m3fnuz_type
>;
test/verify/test_rsqrt.cpp
View file @
eafd55de
...
@@ -23,22 +23,26 @@
...
@@ -23,22 +23,26 @@
*/
*/
#include "verify_program.hpp"
#include "verify_program.hpp"
#include <migraphx/float8.hpp>
#include <migraphx/program.hpp>
#include <migraphx/program.hpp>
#include <migraphx/generate.hpp>
#include <migraphx/generate.hpp>
#include <migraphx/make_op.hpp>
#include <migraphx/make_op.hpp>
struct
test_rsqrt
:
verify_program
<
test_rsqrt
>
template
<
typename
CType
>
struct
test_rsqrt
:
verify_program
<
test_rsqrt
<
CType
>>
{
{
migraphx
::
program
create_program
()
const
migraphx
::
program
create_program
()
const
{
{
migraphx
::
program
p
;
migraphx
::
program
p
;
auto
*
mm
=
p
.
get_main_module
();
auto
*
mm
=
p
.
get_main_module
();
migraphx
::
shape
::
type_t
dtype
=
migraphx
::
shape
::
get_type
<
CType
>
();
std
::
vector
<
size_t
>
input_lens
{
1
,
3
,
16
,
16
};
std
::
vector
<
size_t
>
input_lens
{
1
,
3
,
16
,
16
};
migraphx
::
shape
s
{
migraphx
::
shape
::
float_
type
,
input_lens
};
migraphx
::
shape
s
{
d
type
,
input_lens
};
auto
x
=
mm
->
add_parameter
(
"x"
,
s
);
auto
x
=
mm
->
add_parameter
(
"x"
,
s
);
auto
min_val
=
mm
->
add_literal
(
1.0
f
);
auto
min_val
=
mm
->
add_literal
(
migraphx
::
literal
{
migraphx
::
shape
{
dtype
},
{
1.0
}});
auto
max_val
=
mm
->
add_literal
(
std
::
numeric_limits
<
float
>::
max
());
auto
max_val
=
mm
->
add_literal
(
min_val
=
mm
->
add_instruction
(
migraphx
::
literal
{
migraphx
::
shape
{
dtype
},
{
std
::
numeric_limits
<
CType
>::
max
()}});
min_val
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"multibroadcast"
,
{{
"out_lens"
,
input_lens
}}),
min_val
);
migraphx
::
make_op
(
"multibroadcast"
,
{{
"out_lens"
,
input_lens
}}),
min_val
);
max_val
=
mm
->
add_instruction
(
max_val
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"multibroadcast"
,
{{
"out_lens"
,
input_lens
}}),
max_val
);
migraphx
::
make_op
(
"multibroadcast"
,
{{
"out_lens"
,
input_lens
}}),
max_val
);
...
@@ -47,3 +51,7 @@ struct test_rsqrt : verify_program<test_rsqrt>
...
@@ -47,3 +51,7 @@ struct test_rsqrt : verify_program<test_rsqrt>
return
p
;
return
p
;
};
};
};
};
template
struct
test_rsqrt
<
float
>;
template
struct
test_rsqrt
<
migraphx
::
half
>;
template
struct
test_rsqrt
<
migraphx
::
fp8
::
fp8e4m3fnuz
>;
test/verify/test_scatternd.cpp
View file @
eafd55de
...
@@ -25,18 +25,19 @@
...
@@ -25,18 +25,19 @@
#include <migraphx/program.hpp>
#include <migraphx/program.hpp>
#include <migraphx/generate.hpp>
#include <migraphx/generate.hpp>
#include <migraphx/make_op.hpp>
#include <migraphx/make_op.hpp>
#include <migraphx/shape.hpp>
struct
test_scatternd
:
verify_program
<
test_scatternd
>
template
<
migraphx
::
shape
::
type_t
DType
>
struct
test_scatternd
:
verify_program
<
test_scatternd
<
DType
>>
{
{
migraphx
::
program
create_program
()
const
migraphx
::
program
create_program
()
const
{
{
migraphx
::
program
p
;
migraphx
::
program
p
;
auto
*
mm
=
p
.
get_main_module
();
auto
*
mm
=
p
.
get_main_module
();
auto
dtype
=
migraphx
::
shape
::
float_type
;
auto
itype
=
migraphx
::
shape
::
int64_type
;
auto
itype
=
migraphx
::
shape
::
int64_type
;
migraphx
::
shape
ds
{
dt
ype
,
{
1
}};
migraphx
::
shape
ds
{
DT
ype
,
{
1
}};
migraphx
::
shape
is
{
itype
,
{
4
,
1
}};
migraphx
::
shape
is
{
itype
,
{
4
,
1
}};
migraphx
::
shape
us
{
dt
ype
,
{
4
}};
migraphx
::
shape
us
{
DT
ype
,
{
4
}};
std
::
vector
<
int64_t
>
ind_vec
{
4
,
3
,
1
,
7
};
std
::
vector
<
int64_t
>
ind_vec
{
4
,
3
,
1
,
7
};
auto
ld
=
mm
->
add_literal
(
migraphx
::
literal
{
ds
,
{
1
}});
auto
ld
=
mm
->
add_literal
(
migraphx
::
literal
{
ds
,
{
1
}});
...
@@ -51,3 +52,7 @@ struct test_scatternd : verify_program<test_scatternd>
...
@@ -51,3 +52,7 @@ struct test_scatternd : verify_program<test_scatternd>
return
p
;
return
p
;
}
}
};
};
template
struct
test_scatternd
<
migraphx
::
shape
::
float_type
>;
template
struct
test_scatternd
<
migraphx
::
shape
::
half_type
>;
template
struct
test_scatternd
<
migraphx
::
shape
::
fp8e4m3fnuz_type
>;
test/verify/test_sin.cpp
View file @
eafd55de
...
@@ -27,15 +27,20 @@
...
@@ -27,15 +27,20 @@
#include <migraphx/generate.hpp>
#include <migraphx/generate.hpp>
#include <migraphx/make_op.hpp>
#include <migraphx/make_op.hpp>
struct
test_sin
:
verify_program
<
test_sin
>
template
<
migraphx
::
shape
::
type_t
DType
>
struct
test_sin
:
verify_program
<
test_sin
<
DType
>>
{
{
migraphx
::
program
create_program
()
const
migraphx
::
program
create_program
()
const
{
{
migraphx
::
program
p
;
migraphx
::
program
p
;
auto
*
mm
=
p
.
get_main_module
();
auto
*
mm
=
p
.
get_main_module
();
migraphx
::
shape
s
{
migraphx
::
shape
::
float_t
ype
,
{
10
}};
migraphx
::
shape
s
{
DT
ype
,
{
10
}};
auto
x
=
mm
->
add_parameter
(
"x"
,
s
);
auto
x
=
mm
->
add_parameter
(
"x"
,
s
);
mm
->
add_instruction
(
migraphx
::
make_op
(
"sin"
),
x
);
mm
->
add_instruction
(
migraphx
::
make_op
(
"sin"
),
x
);
return
p
;
return
p
;
}
}
};
};
template
struct
test_sin
<
migraphx
::
shape
::
float_type
>;
template
struct
test_sin
<
migraphx
::
shape
::
half_type
>;
template
struct
test_sin
<
migraphx
::
shape
::
fp8e4m3fnuz_type
>;
test/verify/test_sinh.cpp
View file @
eafd55de
...
@@ -27,15 +27,20 @@
...
@@ -27,15 +27,20 @@
#include <migraphx/generate.hpp>
#include <migraphx/generate.hpp>
#include <migraphx/make_op.hpp>
#include <migraphx/make_op.hpp>
struct
test_sinh
:
verify_program
<
test_sinh
>
template
<
migraphx
::
shape
::
type_t
DType
>
struct
test_sinh
:
verify_program
<
test_sinh
<
DType
>>
{
{
migraphx
::
program
create_program
()
const
migraphx
::
program
create_program
()
const
{
{
migraphx
::
program
p
;
migraphx
::
program
p
;
auto
*
mm
=
p
.
get_main_module
();
auto
*
mm
=
p
.
get_main_module
();
migraphx
::
shape
s
{
migraphx
::
shape
::
float_t
ype
,
{
16
}};
migraphx
::
shape
s
{
DT
ype
,
{
16
}};
auto
x
=
mm
->
add_parameter
(
"x"
,
s
);
auto
x
=
mm
->
add_parameter
(
"x"
,
s
);
mm
->
add_instruction
(
migraphx
::
make_op
(
"sinh"
),
x
);
mm
->
add_instruction
(
migraphx
::
make_op
(
"sinh"
),
x
);
return
p
;
return
p
;
}
}
};
};
template
struct
test_sinh
<
migraphx
::
shape
::
float_type
>;
template
struct
test_sinh
<
migraphx
::
shape
::
half_type
>;
template
struct
test_sinh
<
migraphx
::
shape
::
fp8e4m3fnuz_type
>;
test/verify/test_softmax.cpp
View file @
eafd55de
...
@@ -48,3 +48,7 @@ template struct test_softmax<0, migraphx::shape::half_type>;
...
@@ -48,3 +48,7 @@ template struct test_softmax<0, migraphx::shape::half_type>;
template
struct
test_softmax
<
1
,
migraphx
::
shape
::
half_type
>;
template
struct
test_softmax
<
1
,
migraphx
::
shape
::
half_type
>;
template
struct
test_softmax
<
2
,
migraphx
::
shape
::
half_type
>;
template
struct
test_softmax
<
2
,
migraphx
::
shape
::
half_type
>;
template
struct
test_softmax
<
3
,
migraphx
::
shape
::
half_type
>;
template
struct
test_softmax
<
3
,
migraphx
::
shape
::
half_type
>;
template
struct
test_softmax
<
0
,
migraphx
::
shape
::
fp8e4m3fnuz_type
>;
template
struct
test_softmax
<
1
,
migraphx
::
shape
::
fp8e4m3fnuz_type
>;
template
struct
test_softmax
<
2
,
migraphx
::
shape
::
fp8e4m3fnuz_type
>;
template
struct
test_softmax
<
3
,
migraphx
::
shape
::
fp8e4m3fnuz_type
>;
test/verify/test_sqrt.cpp
View file @
eafd55de
...
@@ -27,16 +27,21 @@
...
@@ -27,16 +27,21 @@
#include <migraphx/generate.hpp>
#include <migraphx/generate.hpp>
#include <migraphx/make_op.hpp>
#include <migraphx/make_op.hpp>
struct
test_sqrt
:
verify_program
<
test_sqrt
>
template
<
migraphx
::
shape
::
type_t
DType
>
struct
test_sqrt
:
verify_program
<
test_sqrt
<
DType
>>
{
{
migraphx
::
program
create_program
()
const
migraphx
::
program
create_program
()
const
{
{
migraphx
::
program
p
;
migraphx
::
program
p
;
auto
*
mm
=
p
.
get_main_module
();
auto
*
mm
=
p
.
get_main_module
();
migraphx
::
shape
s
{
migraphx
::
shape
::
float_t
ype
,
{
2
,
3
,
4
,
6
}};
migraphx
::
shape
s
{
DT
ype
,
{
2
,
3
,
4
,
6
}};
auto
param
=
mm
->
add_parameter
(
"x"
,
s
);
auto
param
=
mm
->
add_parameter
(
"x"
,
s
);
auto
param_abs
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"abs"
),
param
);
auto
param_abs
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"abs"
),
param
);
mm
->
add_instruction
(
migraphx
::
make_op
(
"sqrt"
),
param_abs
);
mm
->
add_instruction
(
migraphx
::
make_op
(
"sqrt"
),
param_abs
);
return
p
;
return
p
;
}
}
};
};
template
struct
test_sqrt
<
migraphx
::
shape
::
float_type
>;
template
struct
test_sqrt
<
migraphx
::
shape
::
half_type
>;
template
struct
test_sqrt
<
migraphx
::
shape
::
fp8e4m3fnuz_type
>;
test/verify/test_tan.cpp
View file @
eafd55de
...
@@ -27,15 +27,20 @@
...
@@ -27,15 +27,20 @@
#include <migraphx/generate.hpp>
#include <migraphx/generate.hpp>
#include <migraphx/make_op.hpp>
#include <migraphx/make_op.hpp>
struct
test_tan
:
verify_program
<
test_tan
>
template
<
migraphx
::
shape
::
type_t
DType
>
struct
test_tan
:
verify_program
<
test_tan
<
DType
>>
{
{
migraphx
::
program
create_program
()
const
migraphx
::
program
create_program
()
const
{
{
migraphx
::
program
p
;
migraphx
::
program
p
;
auto
*
mm
=
p
.
get_main_module
();
auto
*
mm
=
p
.
get_main_module
();
migraphx
::
shape
s
{
migraphx
::
shape
::
float_t
ype
,
{
16
}};
migraphx
::
shape
s
{
DT
ype
,
{
16
}};
auto
x
=
mm
->
add_parameter
(
"x"
,
s
);
auto
x
=
mm
->
add_parameter
(
"x"
,
s
);
mm
->
add_instruction
(
migraphx
::
make_op
(
"tan"
),
x
);
mm
->
add_instruction
(
migraphx
::
make_op
(
"tan"
),
x
);
return
p
;
return
p
;
}
}
};
};
template
struct
test_tan
<
migraphx
::
shape
::
float_type
>;
template
struct
test_tan
<
migraphx
::
shape
::
half_type
>;
template
struct
test_tan
<
migraphx
::
shape
::
fp8e4m3fnuz_type
>;
test/verify/test_tanh.cpp
View file @
eafd55de
...
@@ -27,14 +27,19 @@
...
@@ -27,14 +27,19 @@
#include <migraphx/generate.hpp>
#include <migraphx/generate.hpp>
#include <migraphx/make_op.hpp>
#include <migraphx/make_op.hpp>
struct
test_tanh
:
verify_program
<
test_tanh
>
template
<
migraphx
::
shape
::
type_t
DType
>
struct
test_tanh
:
verify_program
<
test_tanh
<
DType
>>
{
{
migraphx
::
program
create_program
()
const
migraphx
::
program
create_program
()
const
{
{
migraphx
::
program
p
;
migraphx
::
program
p
;
auto
*
mm
=
p
.
get_main_module
();
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
(
"tanh"
),
x
);
mm
->
add_instruction
(
migraphx
::
make_op
(
"tanh"
),
x
);
return
p
;
return
p
;
}
}
};
};
template
struct
test_tanh
<
migraphx
::
shape
::
float_type
>;
template
struct
test_tanh
<
migraphx
::
shape
::
half_type
>;
template
struct
test_tanh
<
migraphx
::
shape
::
fp8e4m3fnuz_type
>;
test/verify/test_where.cpp
View file @
eafd55de
...
@@ -27,7 +27,8 @@
...
@@ -27,7 +27,8 @@
#include <migraphx/generate.hpp>
#include <migraphx/generate.hpp>
#include <migraphx/make_op.hpp>
#include <migraphx/make_op.hpp>
struct
test_where
:
verify_program
<
test_where
>
template
<
migraphx
::
shape
::
type_t
DType
>
struct
test_where
:
verify_program
<
test_where
<
DType
>>
{
{
migraphx
::
program
create_program
()
const
migraphx
::
program
create_program
()
const
{
{
...
@@ -44,3 +45,7 @@ struct test_where : verify_program<test_where>
...
@@ -44,3 +45,7 @@ struct test_where : verify_program<test_where>
return
p
;
return
p
;
};
};
};
};
template
struct
test_where
<
migraphx
::
shape
::
float_type
>;
template
struct
test_where
<
migraphx
::
shape
::
half_type
>;
template
struct
test_where
<
migraphx
::
shape
::
fp8e4m3fnuz_type
>;
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