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
91cc9c7c
"src/targets/vscode:/vscode.git/clone" did not exist on "27c33f30cdd1f8d1c77b07f94eee9f483003fb78"
Commit
91cc9c7c
authored
Nov 18, 2023
by
Umang Yadav
Browse files
Add math and reduce tests
parent
bd0ae5fa
Changes
35
Show whitespace changes
Inline
Side-by-side
Showing
20 changed files
with
115 additions
and
33 deletions
+115
-33
src/targets/gpu/kernels/include/migraphx/kernels/reduce.hpp
src/targets/gpu/kernels/include/migraphx/kernels/reduce.hpp
+5
-6
test/verify/test_acosh.cpp
test/verify/test_acosh.cpp
+7
-2
test/verify/test_asin.cpp
test/verify/test_asin.cpp
+7
-2
test/verify/test_asinh.cpp
test/verify/test_asinh.cpp
+7
-2
test/verify/test_atan.cpp
test/verify/test_atan.cpp
+7
-2
test/verify/test_atanh.cpp
test/verify/test_atanh.cpp
+7
-2
test/verify/test_ceil.cpp
test/verify/test_ceil.cpp
+7
-2
test/verify/test_cos.cpp
test/verify/test_cos.cpp
+7
-2
test/verify/test_cosh.cpp
test/verify/test_cosh.cpp
+7
-2
test/verify/test_erf.cpp
test/verify/test_erf.cpp
+7
-2
test/verify/test_exp.cpp
test/verify/test_exp.cpp
+7
-2
test/verify/test_floor.cpp
test/verify/test_floor.cpp
+7
-2
test/verify/test_fmod_mod.cpp
test/verify/test_fmod_mod.cpp
+1
-0
test/verify/test_gathernd_default.cpp
test/verify/test_gathernd_default.cpp
+1
-1
test/verify/test_isnan.cpp
test/verify/test_isnan.cpp
+0
-0
test/verify/test_layernorm.cpp
test/verify/test_layernorm.cpp
+12
-0
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
No files found.
src/targets/gpu/kernels/include/migraphx/kernels/reduce.hpp
View file @
91cc9c7c
...
...
@@ -106,7 +106,7 @@ __device__ auto block_reduce(index idx, Op op, T init, Index n, F f)
#endif
using
type
=
decltype
(
index
::
invoke_loop
(
f
,
0
,
_c
<
0
>
));
__shared__
type
buffer
[
idx
.
max_nlocal
()
/
lanes_per_thread
];
type
x
=
init
;
type
x
=
type
(
init
)
;
idx
.
local_stride
(
n
,
[
&
](
auto
i
,
auto
d
)
{
x
=
op
(
x
,
index
::
invoke_loop
(
f
,
i
,
d
));
});
dpp_reduce
(
x
,
op
);
...
...
@@ -117,7 +117,7 @@ __device__ auto block_reduce(index idx, Op op, T init, Index n, F f)
}
__syncthreads
();
type
y
=
init
;
type
y
=
type
(
init
)
;
for
(
index_int
i
=
0
;
i
<
idx
.
nlocal
()
/
lanes_per_thread
;
i
++
)
{
y
=
op
(
y
,
buffer
[
i
]);
...
...
@@ -244,9 +244,8 @@ struct reducer_base
{
auto
&&
derived
=
static_cast
<
const
Derived
&>
(
*
this
);
auto
t
=
derived
.
slice
(
x
);
return
make_storage_access
<
typename
decltype
(
t
)
::
type
>
([
=
](
auto
i
,
auto
...)
->
auto
&
{
return
t
[
i
];
});
return
make_storage_access
<
typename
decltype
(
t
)
::
type
>
(
[
=
](
auto
i
,
auto
...)
->
auto
&
{
return
t
[
i
];
});
}
}
...
...
@@ -482,7 +481,7 @@ struct lane
__device__
auto
reduce_impl
(
Op
op
,
T
init
,
Read
read
,
N
n
,
U
&&
x
,
Us
&&
...
xs
)
const
{
using
type
=
remove_reference_t
<
decltype
(
x
(
0
,
_c
<
0
>
))
>
;
type
r
=
init
;
type
r
=
type
(
init
)
;
for
(
index_int
j
=
0
;
j
<
n
;
j
++
)
{
r
=
op
(
r
,
read
(
x
(
j
,
_c
<
0
>
),
xs
(
j
,
_c
<
0
>
)...));
...
...
test/verify/test_acosh.cpp
View file @
91cc9c7c
...
...
@@ -27,13 +27,14 @@
#include <migraphx/generate.hpp>
#include <migraphx/make_op.hpp>
struct
test_acosh
:
verify_program
<
test_acosh
>
template
<
migraphx
::
shape
::
type_t
DType
>
struct
test_acosh
:
verify_program
<
test_acosh
<
DType
>>
{
migraphx
::
program
create_program
()
const
{
migraphx
::
program
p
;
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
min_val
=
mm
->
add_literal
(
1.1
f
);
auto
max_val
=
mm
->
add_literal
(
100.0
f
);
...
...
@@ -46,3 +47,7 @@ struct test_acosh : verify_program<test_acosh>
return
p
;
}
};
template
struct
test_acosh
<
migraphx
::
shape
::
float_type
>;
// template struct test_acosh<migraphx::shape::half_type>;
// template struct test_acosh<migraphx::shape::fp8e4m3fnuz_type>;
test/verify/test_asin.cpp
View file @
91cc9c7c
...
...
@@ -27,15 +27,20 @@
#include <migraphx/generate.hpp>
#include <migraphx/make_op.hpp>
struct
test_asin
:
verify_program
<
test_asin
>
template
<
migraphx
::
shape
::
type_t
DType
>
struct
test_asin
:
verify_program
<
test_asin
<
DType
>>
{
migraphx
::
program
create_program
()
const
{
migraphx
::
program
p
;
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
);
mm
->
add_instruction
(
migraphx
::
make_op
(
"asin"
),
x
);
return
p
;
}
};
template
struct
test_asin
<
migraphx
::
shape
::
float_type
>;
template
struct
test_asin
<
migraphx
::
shape
::
half_type
>;
template
struct
test_asin
<
migraphx
::
shape
::
fp8e4m3fnuz_type
>;
test/verify/test_asinh.cpp
View file @
91cc9c7c
...
...
@@ -27,15 +27,20 @@
#include <migraphx/generate.hpp>
#include <migraphx/make_op.hpp>
struct
test_asinh
:
verify_program
<
test_asinh
>
template
<
migraphx
::
shape
::
type_t
DType
>
struct
test_asinh
:
verify_program
<
test_asinh
<
DType
>>
{
migraphx
::
program
create_program
()
const
{
migraphx
::
program
p
;
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
);
mm
->
add_instruction
(
migraphx
::
make_op
(
"asinh"
),
x
);
return
p
;
}
};
template
struct
test_asinh
<
migraphx
::
shape
::
float_type
>;
template
struct
test_asinh
<
migraphx
::
shape
::
half_type
>;
template
struct
test_asinh
<
migraphx
::
shape
::
fp8e4m3fnuz_type
>;
test/verify/test_atan.cpp
View file @
91cc9c7c
...
...
@@ -27,15 +27,20 @@
#include <migraphx/generate.hpp>
#include <migraphx/make_op.hpp>
struct
test_atan
:
verify_program
<
test_atan
>
template
<
migraphx
::
shape
::
type_t
DType
>
struct
test_atan
:
verify_program
<
test_atan
<
DType
>>
{
migraphx
::
program
create_program
()
const
{
migraphx
::
program
p
;
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
);
mm
->
add_instruction
(
migraphx
::
make_op
(
"atan"
),
x
);
return
p
;
}
};
template
struct
test_atan
<
migraphx
::
shape
::
float_type
>;
template
struct
test_atan
<
migraphx
::
shape
::
half_type
>;
template
struct
test_atan
<
migraphx
::
shape
::
fp8e4m3fnuz_type
>;
test/verify/test_atanh.cpp
View file @
91cc9c7c
...
...
@@ -27,13 +27,14 @@
#include <migraphx/generate.hpp>
#include <migraphx/make_op.hpp>
struct
test_atanh
:
verify_program
<
test_atanh
>
template
<
migraphx
::
shape
::
type_t
DType
>
struct
test_atanh
:
verify_program
<
test_atanh
<
DType
>>
{
migraphx
::
program
create_program
()
const
{
migraphx
::
program
p
;
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
min_val
=
mm
->
add_literal
(
-
0.95
f
);
auto
max_val
=
mm
->
add_literal
(
0.95
f
);
...
...
@@ -46,3 +47,7 @@ struct test_atanh : verify_program<test_atanh>
return
p
;
}
};
template
struct
test_atanh
<
migraphx
::
shape
::
float_type
>;
// template struct test_atanh<migraphx::shape::half_type>;
// template struct test_atanh<migraphx::shape::fp8e4m3fnuz_type>;
test/verify/test_ceil.cpp
View file @
91cc9c7c
...
...
@@ -27,16 +27,21 @@
#include <migraphx/generate.hpp>
#include <migraphx/make_op.hpp>
struct
test_ceil
:
verify_program
<
test_ceil
>
template
<
migraphx
::
shape
::
type_t
DType
>
struct
test_ceil
:
verify_program
<
test_ceil
<
DType
>>
{
migraphx
::
program
create_program
()
const
{
migraphx
::
program
p
;
auto
*
mm
=
p
.
get_main_module
();
migraphx
::
shape
s
{
migraphx
::
shape
::
double_t
ype
,
{
2
,
3
,
4
,
6
}};
migraphx
::
shape
s
{
DT
ype
,
{
2
,
3
,
4
,
6
}};
auto
param
=
mm
->
add_parameter
(
"x"
,
s
);
mm
->
add_instruction
(
migraphx
::
make_op
(
"ceil"
),
param
);
return
p
;
};
};
template
struct
test_ceil
<
migraphx
::
shape
::
float_type
>;
template
struct
test_ceil
<
migraphx
::
shape
::
half_type
>;
template
struct
test_ceil
<
migraphx
::
shape
::
fp8e4m3fnuz_type
>;
test/verify/test_cos.cpp
View file @
91cc9c7c
...
...
@@ -27,15 +27,20 @@
#include <migraphx/generate.hpp>
#include <migraphx/make_op.hpp>
struct
test_cos
:
verify_program
<
test_cos
>
template
<
migraphx
::
shape
::
type_t
DType
>
struct
test_cos
:
verify_program
<
test_cos
<
DType
>>
{
migraphx
::
program
create_program
()
const
{
migraphx
::
program
p
;
auto
*
mm
=
p
.
get_main_module
();
migraphx
::
shape
s
{
migraphx
::
shape
::
float_t
ype
,
{
8
}};
migraphx
::
shape
s
{
DT
ype
,
{
8
}};
auto
x
=
mm
->
add_parameter
(
"x"
,
s
);
mm
->
add_instruction
(
migraphx
::
make_op
(
"cos"
),
x
);
return
p
;
}
};
template
struct
test_cos
<
migraphx
::
shape
::
float_type
>;
template
struct
test_cos
<
migraphx
::
shape
::
half_type
>;
template
struct
test_cos
<
migraphx
::
shape
::
fp8e4m3fnuz_type
>;
test/verify/test_cosh.cpp
View file @
91cc9c7c
...
...
@@ -27,15 +27,20 @@
#include <migraphx/generate.hpp>
#include <migraphx/make_op.hpp>
struct
test_cosh
:
verify_program
<
test_cosh
>
template
<
migraphx
::
shape
::
type_t
DType
>
struct
test_cosh
:
verify_program
<
test_cosh
<
DType
>>
{
migraphx
::
program
create_program
()
const
{
migraphx
::
program
p
;
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
);
mm
->
add_instruction
(
migraphx
::
make_op
(
"cosh"
),
x
);
return
p
;
}
};
template
struct
test_cosh
<
migraphx
::
shape
::
float_type
>;
template
struct
test_cosh
<
migraphx
::
shape
::
half_type
>;
template
struct
test_cosh
<
migraphx
::
shape
::
fp8e4m3fnuz_type
>;
test/verify/test_erf.cpp
View file @
91cc9c7c
...
...
@@ -27,15 +27,20 @@
#include <migraphx/generate.hpp>
#include <migraphx/make_op.hpp>
struct
test_erf
:
verify_program
<
test_erf
>
template
<
migraphx
::
shape
::
type_t
DType
>
struct
test_erf
:
verify_program
<
test_erf
<
DType
>>
{
migraphx
::
program
create_program
()
const
{
migraphx
::
program
p
;
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
);
mm
->
add_instruction
(
migraphx
::
make_op
(
"erf"
),
param
);
return
p
;
}
};
template
struct
test_erf
<
migraphx
::
shape
::
float_type
>;
template
struct
test_erf
<
migraphx
::
shape
::
half_type
>;
template
struct
test_erf
<
migraphx
::
shape
::
fp8e4m3fnuz_type
>;
test/verify/test_exp.cpp
View file @
91cc9c7c
...
...
@@ -27,15 +27,20 @@
#include <migraphx/generate.hpp>
#include <migraphx/make_op.hpp>
struct
test_exp
:
verify_program
<
test_exp
>
template
<
migraphx
::
shape
::
type_t
DType
>
struct
test_exp
:
verify_program
<
test_exp
<
DType
>>
{
migraphx
::
program
create_program
()
const
{
migraphx
::
program
p
;
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
));
mm
->
add_instruction
(
migraphx
::
make_op
(
"exp"
),
x
);
return
p
;
}
};
template
struct
test_exp
<
migraphx
::
shape
::
float_type
>;
template
struct
test_exp
<
migraphx
::
shape
::
half_type
>;
template
struct
test_exp
<
migraphx
::
shape
::
fp8e4m3fnuz_type
>;
test/verify/test_floor.cpp
View file @
91cc9c7c
...
...
@@ -27,16 +27,21 @@
#include <migraphx/generate.hpp>
#include <migraphx/make_op.hpp>
struct
test_floor
:
verify_program
<
test_floor
>
template
<
migraphx
::
shape
::
type_t
DType
>
struct
test_floor
:
verify_program
<
test_floor
<
DType
>>
{
migraphx
::
program
create_program
()
const
{
migraphx
::
program
p
;
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
);
mm
->
add_instruction
(
migraphx
::
make_op
(
"floor"
),
param
);
return
p
;
};
};
template
struct
test_floor
<
migraphx
::
shape
::
float_type
>;
template
struct
test_floor
<
migraphx
::
shape
::
half_type
>;
template
struct
test_floor
<
migraphx
::
shape
::
fp8e4m3fnuz_type
>;
test/verify/test_fmod_mod.cpp
View file @
91cc9c7c
...
...
@@ -71,3 +71,4 @@ struct test_mod : verify_program<test_mod>
return
p
;
}
};
// TODO: check if requires FP8 test
\ No newline at end of file
test/verify/test_gathernd_default.cpp
View file @
91cc9c7c
...
...
@@ -27,7 +27,7 @@
#include <migraphx/make_op.hpp>
template
<
migraphx
::
shape
::
type_t
DType
>
struct
test_gathernd_default
:
verify_program
<
test_gathernd_default
,
DType
>
struct
test_gathernd_default
:
verify_program
<
test_gathernd_default
<
DType
>
>
{
migraphx
::
program
create_program
()
const
{
...
...
test/verify/test_isnan
_float
.cpp
→
test/verify/test_isnan.cpp
View file @
91cc9c7c
File moved
test/verify/test_layernorm.cpp
View file @
91cc9c7c
...
...
@@ -117,6 +117,18 @@ struct test_layernorm_fp16 : verify_program<test_layernorm_fp16>
}
};
// struct test_layernorm_fp8 : verify_program<test_layernorm_fp8>
// {
// migraphx::program create_program() const
// {
// migraphx::program p;
// auto* mm = p.get_main_module();
// std::vector<size_t> dims = {1, 24, 64};
// auto x = mm->add_parameter("x", migraphx::shape{migraphx::shape::fp8e4m3fnuz_type,
// dims}); add_layernorm(*mm, x, dims); return p;
// }
// };
struct
test_layernorm_eps
:
verify_program
<
test_layernorm_eps
>
{
migraphx
::
program
create_program
()
const
...
...
test/verify/test_log.cpp
View file @
91cc9c7c
...
...
@@ -27,15 +27,20 @@
#include <migraphx/generate.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
p
;
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
));
mm
->
add_instruction
(
migraphx
::
make_op
(
"log"
),
x
);
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 @
91cc9c7c
...
...
@@ -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
::
half_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
::
half_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 @
91cc9c7c
...
...
@@ -22,6 +22,7 @@
* THE SOFTWARE.
*/
#include "migraphx/float8.hpp"
#include "verify_program.hpp"
#include <migraphx/program.hpp>
#include <migraphx/generate.hpp>
...
...
@@ -45,3 +46,4 @@ struct test_nearbyint : verify_program<test_nearbyint<T>>
template
struct
test_nearbyint
<
migraphx
::
half
>;
template
struct
test_nearbyint
<
float
>;
template
struct
test_nearbyint
<
migraphx
::
fp8
::
fp8e4m3fnuz
>;
test/verify/test_pad.cpp
View file @
91cc9c7c
...
...
@@ -27,13 +27,14 @@
#include <migraphx/generate.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
p
;
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
>
pads1
=
{
0
,
0
,
0
,
0
,
1
,
1
,
1
,
1
};
std
::
vector
<
int64_t
>
pads2
=
{
1
,
1
,
1
,
1
,
0
,
0
,
0
,
0
};
...
...
@@ -46,3 +47,8 @@ struct test_pad : verify_program<test_pad>
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>;
Prev
1
2
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