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
dc8edad8
Unverified
Commit
dc8edad8
authored
Dec 03, 2023
by
Chris Austen
Committed by
GitHub
Dec 03, 2023
Browse files
Merge branch 'develop' into check-mlir-perf
parents
b9cbfd8e
32f0b028
Changes
88
Hide whitespace changes
Inline
Side-by-side
Showing
20 changed files
with
670 additions
and
105 deletions
+670
-105
test/onnx/unique_unsorted_test.onnx
test/onnx/unique_unsorted_test.onnx
+0
-0
test/onnx/verify_onnx.cpp
test/onnx/verify_onnx.cpp
+128
-62
test/op_shape_test.cpp
test/op_shape_test.cpp
+34
-0
test/ref/unique.cpp
test/ref/unique.cpp
+342
-0
test/simplify_algebra_test.cpp
test/simplify_algebra_test.cpp
+34
-0
test/verify/gemm_softmax_gemm_relu.cpp
test/verify/gemm_softmax_gemm_relu.cpp
+20
-7
test/verify/test_abs.cpp
test/verify/test_abs.cpp
+7
-2
test/verify/test_acos.cpp
test/verify/test_acos.cpp
+7
-2
test/verify/test_acosh.cpp
test/verify/test_acosh.cpp
+12
-5
test/verify/test_add.cpp
test/verify/test_add.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
+13
-5
test/verify/test_ceil.cpp
test/verify/test_ceil.cpp
+7
-2
test/verify/test_concat_axis_0.cpp
test/verify/test_concat_axis_0.cpp
+10
-4
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
No files found.
test/onnx/unique_unsorted_test.onnx
0 → 100644
View file @
dc8edad8
File added
test/onnx/verify_onnx.cpp
View file @
dc8edad8
/*
* The MIT License (MIT)
*
* Copyright (c) 2015-202
2
Advanced Micro Devices, Inc. All rights reserved.
* Copyright (c) 2015-202
3
Advanced Micro Devices, Inc. All rights reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
...
...
@@ -2735,67 +2735,6 @@ TEST_CASE(softsign_test)
EXPECT
(
migraphx
::
verify
::
verify_rms_range
(
result_vector
,
gold
));
}
TEST_CASE
(
upsample_test
)
{
migraphx
::
program
p
=
migraphx
::
parse_onnx
(
"upsample_test.onnx"
);
std
::
vector
<
float
>
x_data
=
{
1
,
2
,
3
,
4
};
migraphx
::
shape
sx
{
migraphx
::
shape
::
float_type
,
{
1
,
1
,
2
,
2
}};
migraphx
::
parameter_map
pp
;
pp
[
"X"
]
=
migraphx
::
argument
(
sx
,
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
());
});
std
::
vector
<
float
>
gold
=
{
1
,
1
,
1
,
2
,
2
,
2
,
1
,
1
,
1
,
2
,
2
,
2
,
3
,
3
,
3
,
4
,
4
,
4
,
3
,
3
,
3
,
4
,
4
,
4
};
EXPECT
(
migraphx
::
verify
::
verify_rms_range
(
result_vector
,
gold
));
}
TEST_CASE
(
where_test
)
{
migraphx
::
program
p
=
migraphx
::
parse_onnx
(
"where_test.onnx"
);
p
.
compile
(
migraphx
::
make_target
(
"ref"
));
migraphx
::
shape
c_shape
{
migraphx
::
shape
::
bool_type
,
{
2
}};
std
::
vector
<
int8_t
>
c_data
=
{
1
,
0
};
migraphx
::
shape
x_shape
{
migraphx
::
shape
::
float_type
,
{
2
,
2
,
2
}};
std
::
vector
<
float
>
x_data
(
8
,
1.0
f
);
migraphx
::
shape
y_shape
{
migraphx
::
shape
::
float_type
,
{
2
,
1
,
2
,
2
}};
std
::
vector
<
float
>
y_data
(
8
,
2.0
f
);
migraphx
::
parameter_map
pp
;
pp
[
"c"
]
=
migraphx
::
argument
(
c_shape
,
c_data
.
data
());
pp
[
"x"
]
=
migraphx
::
argument
(
x_shape
,
x_data
.
data
());
pp
[
"y"
]
=
migraphx
::
argument
(
y_shape
,
y_data
.
data
());
auto
result
=
p
.
eval
(
pp
).
back
();
std
::
vector
<
float
>
result_vector
;
result
.
visit
([
&
](
auto
output
)
{
result_vector
.
assign
(
output
.
begin
(),
output
.
end
());
});
std
::
vector
<
float
>
gold
=
{
1.0
f
,
2.0
f
,
1.0
f
,
2.0
f
,
1.0
f
,
2.0
f
,
1.0
f
,
2.0
f
,
1.0
f
,
2.0
f
,
1.0
f
,
2.0
f
,
1.0
f
,
2.0
f
,
1.0
f
,
2.0
f
};
EXPECT
(
migraphx
::
verify
::
verify_rms_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
...
...
@@ -2921,4 +2860,131 @@ TEST_CASE(tril_row_one_test)
EXPECT
(
migraphx
::
verify
::
verify_rms_range
(
result_vector
,
gold
));
}
TEST_CASE
(
upsample_test
)
{
migraphx
::
program
p
=
migraphx
::
parse_onnx
(
"upsample_test.onnx"
);
std
::
vector
<
float
>
x_data
=
{
1
,
2
,
3
,
4
};
migraphx
::
shape
sx
{
migraphx
::
shape
::
float_type
,
{
1
,
1
,
2
,
2
}};
migraphx
::
parameter_map
pp
;
pp
[
"X"
]
=
migraphx
::
argument
(
sx
,
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
());
});
std
::
vector
<
float
>
gold
=
{
1
,
1
,
1
,
2
,
2
,
2
,
1
,
1
,
1
,
2
,
2
,
2
,
3
,
3
,
3
,
4
,
4
,
4
,
3
,
3
,
3
,
4
,
4
,
4
};
EXPECT
(
migraphx
::
verify
::
verify_rms_range
(
result_vector
,
gold
));
}
TEST_CASE
(
unique_dynamic_sorted_test
)
{
migraphx
::
program
p
=
migraphx
::
parse_onnx
(
"unique_dynamic_sorted_test.onnx"
);
p
.
compile
(
migraphx
::
make_target
(
"ref"
));
std
::
vector
<
float
>
x
{
2
,
1
,
1
,
3
,
4
,
3
};
std
::
vector
<
float
>
y_gold
=
{
1
,
2
,
3
,
4
};
std
::
vector
<
size_t
>
y_idx_gold
=
{
1
,
0
,
3
,
4
};
std
::
vector
<
size_t
>
x_idx_gold
=
{
1
,
0
,
0
,
2
,
3
,
2
};
std
::
vector
<
size_t
>
y_ct_gold
=
{
2
,
1
,
2
,
1
};
migraphx
::
shape
s
{
migraphx
::
shape
::
float_type
,
{
x
.
size
()}};
migraphx
::
parameter_map
pm
;
pm
[
"X"
]
=
migraphx
::
argument
(
s
,
x
.
data
());
auto
result
=
p
.
eval
(
pm
);
std
::
vector
<
float
>
yvec
;
result
[
0
].
visit
([
&
](
auto
out
)
{
yvec
.
assign
(
out
.
begin
(),
out
.
end
());
});
EXPECT
(
yvec
==
y_gold
);
std
::
vector
<
size_t
>
y_idx_vec
;
result
[
1
].
visit
([
&
](
auto
out
)
{
y_idx_vec
.
assign
(
out
.
begin
(),
out
.
end
());
});
EXPECT
(
y_idx_vec
==
y_idx_gold
);
std
::
vector
<
size_t
>
x_idx_vec
;
result
[
2
].
visit
([
&
](
auto
out
)
{
x_idx_vec
.
assign
(
out
.
begin
(),
out
.
end
());
});
EXPECT
(
x_idx_vec
==
x_idx_gold
);
std
::
vector
<
size_t
>
y_ct_vec
;
result
[
3
].
visit
([
&
](
auto
out
)
{
y_ct_vec
.
assign
(
out
.
begin
(),
out
.
end
());
});
EXPECT
(
y_ct_vec
==
y_ct_gold
);
}
TEST_CASE
(
unique_dynamic_unsorted_test
)
{
migraphx
::
program
p
=
migraphx
::
parse_onnx
(
"unique_dynamic_unsorted_test.onnx"
);
p
.
compile
(
migraphx
::
make_target
(
"ref"
));
std
::
vector
<
float
>
x
{
2
,
1
,
1
,
3
,
4
,
3
};
std
::
vector
<
float
>
y_gold
=
{
2
,
1
,
3
,
4
};
std
::
vector
<
size_t
>
y_idx_gold
=
{
0
,
1
,
3
,
4
};
std
::
vector
<
size_t
>
x_idx_gold
=
{
0
,
1
,
1
,
2
,
3
,
2
};
std
::
vector
<
size_t
>
y_ct_gold
=
{
1
,
2
,
2
,
1
};
migraphx
::
shape
s
{
migraphx
::
shape
::
float_type
,
{
x
.
size
()}};
migraphx
::
parameter_map
pm
;
pm
[
"X"
]
=
migraphx
::
argument
(
s
,
x
.
data
());
auto
result
=
p
.
eval
(
pm
);
std
::
vector
<
float
>
yvec
;
result
[
0
].
visit
([
&
](
auto
out
)
{
yvec
.
assign
(
out
.
begin
(),
out
.
end
());
});
EXPECT
(
yvec
==
y_gold
);
std
::
vector
<
size_t
>
y_idx_vec
;
result
[
1
].
visit
([
&
](
auto
out
)
{
y_idx_vec
.
assign
(
out
.
begin
(),
out
.
end
());
});
EXPECT
(
y_idx_vec
==
y_idx_gold
);
std
::
vector
<
size_t
>
x_idx_vec
;
result
[
2
].
visit
([
&
](
auto
out
)
{
x_idx_vec
.
assign
(
out
.
begin
(),
out
.
end
());
});
EXPECT
(
x_idx_vec
==
x_idx_gold
);
std
::
vector
<
size_t
>
y_ct_vec
;
result
[
3
].
visit
([
&
](
auto
out
)
{
y_ct_vec
.
assign
(
out
.
begin
(),
out
.
end
());
});
EXPECT
(
y_ct_vec
==
y_ct_gold
);
}
TEST_CASE
(
where_test
)
{
migraphx
::
program
p
=
migraphx
::
parse_onnx
(
"where_test.onnx"
);
p
.
compile
(
migraphx
::
make_target
(
"ref"
));
migraphx
::
shape
c_shape
{
migraphx
::
shape
::
bool_type
,
{
2
}};
std
::
vector
<
int8_t
>
c_data
=
{
1
,
0
};
migraphx
::
shape
x_shape
{
migraphx
::
shape
::
float_type
,
{
2
,
2
,
2
}};
std
::
vector
<
float
>
x_data
(
8
,
1.0
f
);
migraphx
::
shape
y_shape
{
migraphx
::
shape
::
float_type
,
{
2
,
1
,
2
,
2
}};
std
::
vector
<
float
>
y_data
(
8
,
2.0
f
);
migraphx
::
parameter_map
pp
;
pp
[
"c"
]
=
migraphx
::
argument
(
c_shape
,
c_data
.
data
());
pp
[
"x"
]
=
migraphx
::
argument
(
x_shape
,
x_data
.
data
());
pp
[
"y"
]
=
migraphx
::
argument
(
y_shape
,
y_data
.
data
());
auto
result
=
p
.
eval
(
pp
).
back
();
std
::
vector
<
float
>
result_vector
;
result
.
visit
([
&
](
auto
output
)
{
result_vector
.
assign
(
output
.
begin
(),
output
.
end
());
});
std
::
vector
<
float
>
gold
=
{
1.0
f
,
2.0
f
,
1.0
f
,
2.0
f
,
1.0
f
,
2.0
f
,
1.0
f
,
2.0
f
,
1.0
f
,
2.0
f
,
1.0
f
,
2.0
f
,
1.0
f
,
2.0
f
,
1.0
f
,
2.0
f
};
EXPECT
(
migraphx
::
verify
::
verify_rms_range
(
result_vector
,
gold
));
}
int
main
(
int
argc
,
const
char
*
argv
[])
{
test
::
run
(
argc
,
argv
);
}
test/op_shape_test.cpp
View file @
dc8edad8
...
...
@@ -4166,6 +4166,40 @@ TEST_CASE(test_squeeze_wrong_axis)
throws_shape
(
migraphx
::
make_op
(
"squeeze"
,
{{
"axes"
,
{
0
}}}),
s1
);
}
TEST_CASE
(
test_unique_axis_invalid
)
{
migraphx
::
shape
x_shape
{
migraphx
::
shape
::
float_type
,
{
10
,
4
,
3
}};
throws_shape
(
migraphx
::
make_op
(
"unique"
,
{{
"axis"
,
-
1
}}),
x_shape
);
}
TEST_CASE
(
test_unique_axis_negative
)
{
migraphx
::
shape
x_shape
{
migraphx
::
shape
::
float_type
,
{
10
,
4
,
3
}};
std
::
vector
<
migraphx
::
shape
::
dynamic_dimension
>
y_dims
{{
1
,
10
},
{
4
,
4
},
{
3
,
3
}};
std
::
vector
<
migraphx
::
shape
::
dynamic_dimension
>
idx_dims
{{
1
,
10
}};
std
::
vector
<
migraphx
::
shape
>
y_dyn_shape
{{
migraphx
::
shape
::
float_type
,
y_dims
},
{
migraphx
::
shape
::
int64_type
,
idx_dims
},
{
migraphx
::
shape
::
int64_type
,
idx_dims
},
{
migraphx
::
shape
::
int64_type
,
idx_dims
}};
expect_shape
(
y_dyn_shape
,
migraphx
::
make_op
(
"unique"
,
{{
"axis"
,
-
3
}}),
x_shape
);
}
TEST_CASE
(
test_unique_axis_none
)
{
migraphx
::
shape
x_shape
{
migraphx
::
shape
::
half_type
,
{
10
,
4
,
3
}};
std
::
vector
<
migraphx
::
shape
::
dynamic_dimension
>
y_dims
{{
1
,
120
}};
std
::
vector
<
migraphx
::
shape
::
dynamic_dimension
>
idx_dims
{{
1
,
120
}};
std
::
vector
<
migraphx
::
shape
>
y_dyn_shape
{{
migraphx
::
shape
::
half_type
,
y_dims
},
{
migraphx
::
shape
::
int64_type
,
idx_dims
},
{
migraphx
::
shape
::
int64_type
,
idx_dims
},
{
migraphx
::
shape
::
int64_type
,
idx_dims
}};
expect_shape
(
y_dyn_shape
,
migraphx
::
make_op
(
"unique"
),
x_shape
);
}
TEST_CASE
(
test_unsqueeze
)
{
migraphx
::
shape
s1
{
migraphx
::
shape
::
float_type
,
{
4
,
5
,
3
}};
...
...
test/ref/unique.cpp
0 → 100644
View file @
dc8edad8
/*
* The MIT License (MIT)
*
* Copyright (c) 2015-2023 Advanced Micro Devices, Inc. All rights reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
#include <migraphx/instruction.hpp>
#include <migraphx/literal.hpp>
#include <migraphx/make_op.hpp>
#include <migraphx/onnx.hpp>
#include <migraphx/register_target.hpp>
#include <migraphx/verify.hpp>
#include <optional>
#include <test.hpp>
namespace
{
migraphx
::
program
create_program
(
const
migraphx
::
shape
&
data_shape
,
int64_t
sorted
,
std
::
optional
<
int64_t
>
axis
)
{
migraphx
::
program
p
;
auto
*
mm
=
p
.
get_main_module
();
auto
data
=
mm
->
add_parameter
(
"X"
,
data_shape
);
auto
op
=
axis
?
migraphx
::
make_op
(
"unique"
,
{{
"axis"
,
*
axis
},
{
"sorted"
,
sorted
}})
:
migraphx
::
make_op
(
"unique"
,
{{
"sorted"
,
sorted
}});
auto
r
=
mm
->
add_instruction
(
op
,
data
);
auto
r0
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"get_tuple_elem"
,
{{
"index"
,
0
}}),
r
);
auto
r1
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"get_tuple_elem"
,
{{
"index"
,
1
}}),
r
);
auto
r2
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"get_tuple_elem"
,
{{
"index"
,
2
}}),
r
);
auto
r3
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"get_tuple_elem"
,
{{
"index"
,
3
}}),
r
);
mm
->
add_return
({
r0
,
r1
,
r2
,
r3
});
return
p
;
};
template
<
typename
T
>
auto
run_program
(
T
&
data
,
const
migraphx
::
shape
&
data_shape
,
int
sorted
,
std
::
optional
<
int64_t
>
axis
=
std
::
nullopt
)
{
auto
p
=
create_program
(
data_shape
,
sorted
,
axis
);
p
.
compile
(
migraphx
::
make_target
(
"ref"
));
migraphx
::
parameter_map
pp
;
pp
[
"X"
]
=
migraphx
::
argument
(
data_shape
,
data
.
data
());
auto
rets
=
p
.
eval
(
pp
);
std
::
vector
<
typename
std
::
remove_reference_t
<
decltype
(
data
)
>::
value_type
>
y
;
rets
[
0
].
visit
([
&
](
auto
v
)
{
y
.
assign
(
v
.
begin
(),
v
.
end
());
});
std
::
vector
<
int64_t
>
y_idx
;
rets
[
1
].
visit
([
&
](
auto
v
)
{
y_idx
.
assign
(
v
.
begin
(),
v
.
end
());
});
std
::
vector
<
int64_t
>
x_rev_idx
;
rets
[
2
].
visit
([
&
](
auto
v
)
{
x_rev_idx
.
assign
(
v
.
begin
(),
v
.
end
());
});
std
::
vector
<
int64_t
>
y_ct
;
rets
[
3
].
visit
([
&
](
auto
v
)
{
y_ct
.
assign
(
v
.
begin
(),
v
.
end
());
});
return
std
::
make_tuple
(
y
,
y_idx
,
x_rev_idx
,
y_ct
);
}
}
// namespace
// sorted. single entry
TEST_CASE
(
unique_sorted_single_entry_test
)
{
std
::
vector
<
int
>
data
=
{
2
};
int64_t
axis
=
0
;
int64_t
sorted
=
1
;
std
::
vector
<
size_t
>
lens
=
{
1
};
migraphx
::
shape
data_shape
{
migraphx
::
shape
::
int32_type
,
lens
};
const
auto
&
[
y
,
idx
,
x_rev
,
ct
]
=
run_program
(
data
,
data_shape
,
sorted
,
axis
);
std
::
vector
<
int
>
gold_val
=
{
2
};
EXPECT
(
y
==
gold_val
);
std
::
vector
<
int64_t
>
gold_y_idx
=
{
0
};
EXPECT
(
idx
==
gold_y_idx
);
std
::
vector
<
int64_t
>
gold_x_rev
=
{
0
};
EXPECT
(
x_rev
==
gold_x_rev
);
std
::
vector
<
int64_t
>
gold_ct
=
{
1
};
EXPECT
(
ct
==
gold_ct
);
}
// unsorted. single entry
TEST_CASE
(
unique_unsorted_single_entry_test
)
{
std
::
vector
<
float
>
data
=
{
3.33
};
int64_t
axis
=
-
1
;
int64_t
sorted
=
0
;
std
::
vector
<
size_t
>
lens
=
{
1
};
migraphx
::
shape
data_shape
{
migraphx
::
shape
::
float_type
,
lens
};
const
auto
&
[
y
,
idx
,
x_rev
,
ct
]
=
run_program
(
data
,
data_shape
,
sorted
,
axis
);
std
::
vector
<
float
>
gold_val
=
{
3.33
};
EXPECT
(
y
==
gold_val
);
std
::
vector
<
int64_t
>
gold_y_idx
=
{
0
};
EXPECT
(
idx
==
gold_y_idx
);
std
::
vector
<
int64_t
>
gold_x_rev
=
{
0
};
EXPECT
(
x_rev
==
gold_x_rev
);
std
::
vector
<
int64_t
>
gold_ct
=
{
1
};
EXPECT
(
ct
==
gold_ct
);
}
// case 2 sorted. all unique input..
TEST_CASE
(
unique_sorted_all_unique_test
)
{
std
::
vector
<
float
>
data
=
{
2.1
,
2.3
,
2.4
,
2.5
,
1.9
};
int64_t
axis
=
0
;
int64_t
sorted
=
1
;
std
::
vector
<
size_t
>
lens
=
{
5
};
migraphx
::
shape
data_shape
{
migraphx
::
shape
::
float_type
,
lens
};
const
auto
&
[
y
,
idx
,
x_rev
,
ct
]
=
run_program
(
data
,
data_shape
,
sorted
,
axis
);
std
::
vector
<
float
>
gold_val
=
{
1.9
,
2.1
,
2.3
,
2.4
,
2.5
};
EXPECT
(
y
==
gold_val
);
std
::
vector
<
int64_t
>
gold_y_idx
=
{
4
,
0
,
1
,
2
,
3
};
EXPECT
(
idx
==
gold_y_idx
);
std
::
vector
<
int64_t
>
gold_x_rev
=
{
1
,
2
,
3
,
4
,
0
};
EXPECT
(
x_rev
==
gold_x_rev
);
std
::
vector
<
int64_t
>
gold_ct
=
{
1
,
1
,
1
,
1
,
1
};
EXPECT
(
ct
==
gold_ct
);
}
// case 3 unsorted. all unique input
TEST_CASE
(
unique_unsorted_all_unique_test
)
{
std
::
vector
<
float
>
data
=
{
2.1
,
2.3
,
2.4
,
2.5
,
1.9
};
int64_t
axis
=
0
;
int64_t
sorted
=
0
;
std
::
vector
<
size_t
>
lens
=
{
5
};
migraphx
::
shape
data_shape
{
migraphx
::
shape
::
float_type
,
lens
};
const
auto
&
[
y
,
idx
,
x_rev
,
ct
]
=
run_program
(
data
,
data_shape
,
sorted
,
axis
);
std
::
vector
<
float
>
gold_val
=
{
2.1
,
2.3
,
2.4
,
2.5
,
1.9
};
EXPECT
(
y
==
gold_val
);
std
::
vector
<
int64_t
>
gold_y_idx
=
{
0
,
1
,
2
,
3
,
4
};
EXPECT
(
idx
==
gold_y_idx
);
std
::
vector
<
int64_t
>
gold_x_rev
=
{
0
,
1
,
2
,
3
,
4
};
EXPECT
(
x_rev
==
gold_x_rev
);
std
::
vector
<
int64_t
>
gold_ct
=
{
1
,
1
,
1
,
1
,
1
};
EXPECT
(
ct
==
gold_ct
);
}
// case 4 sorted (with dup entries)
TEST_CASE
(
unique_sorted_dupes_test
)
{
std
::
vector
<
double
>
data
=
{
2.1
,
2.3
,
2.4
,
2.5
,
1.9
,
2.5
,
2.3
,
2.5
};
int64_t
axis
=
0
;
int64_t
sorted
=
1
;
std
::
vector
<
size_t
>
lens
=
{
8
};
migraphx
::
shape
data_shape
{
migraphx
::
shape
::
double_type
,
lens
};
const
auto
&
[
y
,
idx
,
x_rev
,
ct
]
=
run_program
(
data
,
data_shape
,
sorted
,
axis
);
std
::
vector
<
double
>
gold_val
=
{
1.9
,
2.1
,
2.3
,
2.4
,
2.5
};
EXPECT
(
y
==
gold_val
);
std
::
vector
<
int64_t
>
gold_ct
=
{
1
,
1
,
2
,
1
,
3
};
EXPECT
(
ct
==
gold_ct
);
}
// case 5 unsorted (with dup entries)
TEST_CASE
(
unique_unsorted_dupes_test
)
{
std
::
vector
<
float
>
data
=
{
2.1
,
2.3
,
2.4
,
2.5
,
1.9
,
2.5
,
2.3
,
2.1
};
int64_t
axis
=
-
1
;
int64_t
sorted
=
0
;
std
::
vector
<
size_t
>
lens
=
{
8
};
migraphx
::
shape
data_shape
{
migraphx
::
shape
::
float_type
,
lens
};
const
auto
&
[
y
,
idx
,
x_rev
,
ct
]
=
run_program
(
data
,
data_shape
,
sorted
,
axis
);
std
::
vector
<
float
>
gold_val
=
{
2.1
,
2.3
,
2.4
,
2.5
,
1.9
};
EXPECT
(
y
==
gold_val
);
std
::
vector
<
int64_t
>
gold_y_idx
=
{
0
,
1
,
2
,
3
,
4
};
EXPECT
(
idx
==
gold_y_idx
);
std
::
vector
<
int64_t
>
gold_x_rev
=
{
0
,
1
,
2
,
3
,
4
,
3
,
1
,
0
};
EXPECT
(
x_rev
==
gold_x_rev
);
std
::
vector
<
int64_t
>
gold_ct
=
{
2
,
2
,
1
,
2
,
1
};
EXPECT
(
ct
==
gold_ct
);
}
TEST_CASE
(
unique_3D_no_axis_test
)
{
// sorted 3D (with dup entries). no axis
int
sorted
=
1
;
std
::
vector
<
double
>
data_3d
=
{
2.1
,
2.3
,
2.4
,
2.5
,
1.9
,
2.5
,
2.3
,
2.5
};
std
::
vector
<
size_t
>
lens
=
{
2
,
2
,
2
};
// 3D data. type double
migraphx
::
shape
data_shape
{
migraphx
::
shape
::
double_type
,
lens
};
const
auto
&
[
y
,
idx
,
x_rev
,
ct
]
=
run_program
(
data_3d
,
data_shape
,
sorted
);
std
::
vector
<
double
>
gold_val
=
{
1.9
,
2.1
,
2.3
,
2.4
,
2.5
};
EXPECT
(
y
==
gold_val
);
std
::
vector
<
int64_t
>
gold_ct
=
{
1
,
1
,
2
,
1
,
3
};
EXPECT
(
ct
==
gold_ct
);
}
TEST_CASE
(
unique_3D_no_axis_unsorted_test
)
// unsorted 3D (with dup entries). no axis
{
int
sorted
=
0
;
std
::
vector
<
float
>
data
=
{
2.1
,
2.3
,
2.4
,
2.5
,
1.9
,
2.5
,
2.3
,
2.1
};
std
::
vector
<
size_t
>
lens
=
{
2
,
1
,
4
};
// 3D data. type float
migraphx
::
shape
data_shape
{
migraphx
::
shape
::
float_type
,
lens
};
const
auto
&
[
y
,
idx
,
x_rev
,
ct
]
=
run_program
(
data
,
data_shape
,
sorted
);
std
::
vector
<
float
>
gold_val
=
{
2.1
,
2.3
,
2.4
,
2.5
,
1.9
};
EXPECT
(
y
==
gold_val
);
std
::
vector
<
int64_t
>
gold_y_idx
=
{
0
,
1
,
2
,
3
,
4
};
EXPECT
(
idx
==
gold_y_idx
);
std
::
vector
<
int64_t
>
gold_x_rev
=
{
0
,
1
,
2
,
3
,
4
,
3
,
1
,
0
};
EXPECT
(
x_rev
==
gold_x_rev
);
std
::
vector
<
int64_t
>
gold_ct
=
{
2
,
2
,
1
,
2
,
1
};
EXPECT
(
ct
==
gold_ct
);
}
// unique integer sub-tensors: sorted (with dup entries)
TEST_CASE
(
unique_subtensors_sorted_test
)
{
/*
input_X = [[1, 0, 0], [1, 0, 0], [2, 3, 4]]
attribute_sorted = 1
attribute_axis = 0
output_Y = [[1, 0, 0], [2, 3, 4]]
output_indices = [0, 2]
output_inverse_indices = [0, 0, 1]
output_counts = [2, 1]
*/
int
axis
=
0
;
int
sorted
=
1
;
std
::
vector
<
int32_t
>
data
=
{
1
,
0
,
0
,
1
,
0
,
0
,
2
,
3
,
4
};
std
::
vector
<
size_t
>
lens
=
{
3
,
3
};
migraphx
::
shape
data_shape
{
migraphx
::
shape
::
int32_type
,
lens
};
const
auto
&
[
y
,
idx
,
x_rev
,
ct
]
=
run_program
(
data
,
data_shape
,
sorted
,
axis
);
std
::
vector
<
int32_t
>
gold_val
=
{
1
,
0
,
0
,
2
,
3
,
4
};
EXPECT
(
y
==
gold_val
);
std
::
vector
<
int64_t
>
gold_y_idx
=
{
0
,
2
};
EXPECT
(
idx
==
gold_y_idx
);
std
::
vector
<
int64_t
>
gold_x_rev
=
{
0
,
0
,
1
};
EXPECT
(
x_rev
==
gold_x_rev
);
std
::
vector
<
int64_t
>
gold_ct
=
{
2
,
1
};
EXPECT
(
ct
==
gold_ct
);
}
// unique integer sub-tensors: un-sorted (with dup entries)
TEST_CASE
(
unique_subtensors_neg_axis_test
)
{
/*
input_X = [[1, 0, 0], [1, 0, 0], [2, 3, 4]]
attribute_sorted = 0
attribute_axis = 0
output_Y = [[1, 0, 0], [2, 3, 4]]
output_indices = [0, 2]
output_inverse_indices = [0, 0, 1]
output_counts = [2, 1]
*/
int
axis
=
-
2
;
// == 0
int
sorted
=
0
;
std
::
vector
<
int32_t
>
data
=
{
1
,
0
,
0
,
1
,
0
,
0
,
2
,
3
,
4
};
std
::
vector
<
size_t
>
lens
=
{
3
,
3
};
migraphx
::
shape
data_shape
{
migraphx
::
shape
::
int32_type
,
lens
};
const
auto
&
[
y
,
idx
,
x_rev
,
ct
]
=
run_program
(
data
,
data_shape
,
sorted
,
axis
);
std
::
vector
<
int32_t
>
gold_val
=
{
1
,
0
,
0
,
2
,
3
,
4
};
EXPECT
(
y
==
gold_val
);
std
::
vector
<
int64_t
>
gold_y_idx
=
{
0
,
2
};
EXPECT
(
idx
==
gold_y_idx
);
std
::
vector
<
int64_t
>
gold_x_rev
=
{
0
,
0
,
1
};
EXPECT
(
x_rev
==
gold_x_rev
);
std
::
vector
<
int64_t
>
gold_ct
=
{
2
,
1
};
EXPECT
(
ct
==
gold_ct
);
}
// unique float sub-tensors: sorted (with dup entries) axis = 0
TEST_CASE
(
unique_subtensors_zero_axis_test
)
{
/*
input_x = [[[1., 1.], [0., 1.], [2., 1.], [0., 1.]],
[[1., 1.], [0., 1.], [2., 1.], [0., 1.]]]
attribute_sorted = 1
attribute_axis = 0
*/
int
axis
=
0
;
int
sorted
=
1
;
std
::
vector
<
float
>
data
=
{
1.
,
1.
,
0.
,
1.
,
2.
,
1.
,
0.
,
1.
,
1.
,
1.
,
0.
,
1.
,
2.
,
1.
,
0.
,
1.
};
std
::
vector
<
size_t
>
lens
=
{
2
,
4
,
2
};
migraphx
::
shape
data_shape
{
migraphx
::
shape
::
float_type
,
lens
};
const
auto
&
[
y
,
idx
,
x_rev
,
ct
]
=
run_program
(
data
,
data_shape
,
sorted
,
axis
);
std
::
vector
<
float
>
gold_val
=
{
1.
,
1.
,
0.
,
1.
,
2.
,
1.
,
0.
,
1.
};
EXPECT
(
y
==
gold_val
);
std
::
vector
<
int64_t
>
gold_y_idx
=
{
0
};
EXPECT
(
idx
==
gold_y_idx
);
std
::
vector
<
int64_t
>
gold_x_rev
=
{
0
,
0
};
EXPECT
(
x_rev
==
gold_x_rev
);
std
::
vector
<
int64_t
>
gold_ct
=
{
2
};
EXPECT
(
ct
==
gold_ct
);
}
test/simplify_algebra_test.cpp
View file @
dc8edad8
...
...
@@ -1017,6 +1017,40 @@ TEST_CASE(simplify_concat_add_relu_broadcast_same_axis)
EXPECT
(
m1
==
m2
);
}
TEST_CASE
(
concat_convert_fusion
)
{
auto
s
=
migraphx
::
shape
{
migraphx
::
shape
::
float_type
,
{
64
}};
migraphx
::
module
m1
;
{
auto
x
=
m1
.
add_parameter
(
"x"
,
s
);
auto
y
=
m1
.
add_parameter
(
"y"
,
s
);
auto
xh
=
m1
.
add_instruction
(
migraphx
::
make_op
(
"convert"
,
{{
"target_type"
,
migraphx
::
to_value
(
migraphx
::
shape
::
half_type
)}}),
x
);
auto
yh
=
m1
.
add_instruction
(
migraphx
::
make_op
(
"convert"
,
{{
"target_type"
,
migraphx
::
to_value
(
migraphx
::
shape
::
half_type
)}}),
y
);
auto
concat
=
m1
.
add_instruction
(
migraphx
::
make_op
(
"concat"
,
{{
"axis"
,
0
}}),
xh
,
yh
);
m1
.
add_instruction
(
pass_op
{},
concat
);
}
run_pass
(
m1
);
migraphx
::
module
m2
;
{
auto
x
=
m2
.
add_parameter
(
"x"
,
s
);
auto
y
=
m2
.
add_parameter
(
"y"
,
s
);
auto
concat
=
m2
.
add_instruction
(
migraphx
::
make_op
(
"concat"
,
{{
"axis"
,
0
}}),
x
,
y
);
auto
concath
=
m2
.
add_instruction
(
migraphx
::
make_op
(
"convert"
,
{{
"target_type"
,
migraphx
::
to_value
(
migraphx
::
shape
::
half_type
)}}),
concat
);
m2
.
add_instruction
(
pass_op
{},
concath
);
}
EXPECT
(
m1
==
m2
);
}
TEST_CASE
(
simplify_div_const
)
{
migraphx
::
module
m1
;
...
...
test/verify/
test_isnan_half
.cpp
→
test/verify/
gemm_softmax_gemm_relu
.cpp
View file @
dc8edad8
...
...
@@ -21,23 +21,36 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
#include <limits>
#include "verify_program.hpp"
#include <migraphx/program.hpp>
#include <migraphx/generate.hpp>
#include <migraphx/make_op.hpp>
#include <migraphx/half.hpp>
struct
test_isnan_half
:
verify_program
<
test_isnan_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
();
auto
x
=
mm
->
add_parameter
(
"x"
,
migraphx
::
shape
{
migraphx
::
shape
::
half_type
,
{
2
}});
auto
l0
=
mm
->
add_literal
(
std
::
numeric_limits
<
migraphx
::
half
>::
quiet_NaN
());
x
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"concat"
,
{{
"axis"
,
0
}}),
x
,
l0
);
mm
->
add_instruction
(
migraphx
::
make_op
(
"isnan"
),
x
);
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
});
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/test_abs.cpp
View file @
dc8edad8
...
...
@@ -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
>;
test/verify/test_acos.cpp
View file @
dc8edad8
...
...
@@ -27,15 +27,20 @@
#include <migraphx/generate.hpp>
#include <migraphx/make_op.hpp>
struct
test_acos
:
verify_program
<
test_acos
>
template
<
migraphx
::
shape
::
type_t
DType
>
struct
test_acos
:
verify_program
<
test_acos
<
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
(
"acos"
),
x
);
return
p
;
}
};
template
struct
test_acos
<
migraphx
::
shape
::
fp8e4m3fnuz_type
>;
template
struct
test_acos
<
migraphx
::
shape
::
half_type
>;
template
struct
test_acos
<
migraphx
::
shape
::
float_type
>;
test/verify/test_acosh.cpp
View file @
dc8edad8
...
...
@@ -23,20 +23,23 @@
*/
#include "verify_program.hpp"
#include <migraphx/literal.hpp>
#include <migraphx/program.hpp>
#include <migraphx/generate.hpp>
#include <migraphx/make_op.hpp>
struct
test_acosh
:
verify_program
<
test_acosh
>
template
<
typename
CType
>
struct
test_acosh
:
verify_program
<
test_acosh
<
CType
>>
{
migraphx
::
program
create_program
()
const
{
migraphx
::
program
p
;
auto
*
mm
=
p
.
get_main_module
();
migraphx
::
shape
s
{
migraphx
::
shape
::
float_type
,
{
16
}};
auto
*
mm
=
p
.
get_main_module
();
migraphx
::
shape
::
type_t
dtype
=
migraphx
::
shape
::
get_type
<
CType
>
();
migraphx
::
shape
s
{
dtype
,
{
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
);
auto
min_val
=
mm
->
add_literal
(
migraphx
::
literal
{
migraphx
::
shape
{
dtype
},
{
1.1
f
}}
);
auto
max_val
=
mm
->
add_literal
(
migraphx
::
literal
{
migraphx
::
shape
{
dtype
},
{
100.0
f
}}
);
min_val
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"multibroadcast"
,
{{
"out_lens"
,
{
16
}}}),
min_val
);
max_val
=
...
...
@@ -46,3 +49,7 @@ struct test_acosh : verify_program<test_acosh>
return
p
;
}
};
template
struct
test_acosh
<
float
>;
template
struct
test_acosh
<
migraphx
::
half
>;
template
struct
test_acosh
<
migraphx
::
fp8
::
fp8e4m3fnuz
>;
test/verify/test_add.cpp
View file @
dc8edad8
...
...
@@ -27,16 +27,21 @@
#include <migraphx/generate.hpp>
#include <migraphx/make_op.hpp>
struct
test_add
:
verify_program
<
test_add
>
template
<
migraphx
::
shape
::
type_t
DType
>
struct
test_add
:
verify_program
<
test_add
<
DType
>>
{
migraphx
::
program
create_program
()
const
{
migraphx
::
program
p
;
auto
*
mm
=
p
.
get_main_module
();
migraphx
::
shape
s
{
migraphx
::
shape
::
float_t
ype
,
{
3
}};
migraphx
::
shape
s
{
DT
ype
,
{
8
}};
auto
x
=
mm
->
add_parameter
(
"x"
,
s
);
auto
y
=
mm
->
add_parameter
(
"y"
,
s
);
mm
->
add_instruction
(
migraphx
::
make_op
(
"add"
),
x
,
y
);
return
p
;
}
};
template
struct
test_add
<
migraphx
::
shape
::
fp8e4m3fnuz_type
>;
template
struct
test_add
<
migraphx
::
shape
::
half_type
>;
template
struct
test_add
<
migraphx
::
shape
::
float_type
>;
test/verify/test_asin.cpp
View file @
dc8edad8
...
...
@@ -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 @
dc8edad8
...
...
@@ -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 @
dc8edad8
...
...
@@ -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 @
dc8edad8
...
...
@@ -23,20 +23,24 @@
*/
#include "verify_program.hpp"
#include <migraphx/float8.hpp>
#include <migraphx/half.hpp>
#include <migraphx/program.hpp>
#include <migraphx/generate.hpp>
#include <migraphx/make_op.hpp>
struct
test_atanh
:
verify_program
<
test_atanh
>
template
<
typename
CType
>
struct
test_atanh
:
verify_program
<
test_atanh
<
CType
>>
{
migraphx
::
program
create_program
()
const
{
migraphx
::
program
p
;
auto
*
mm
=
p
.
get_main_module
();
migraphx
::
shape
s
{
migraphx
::
shape
::
float_type
,
{
16
}};
auto
*
mm
=
p
.
get_main_module
();
migraphx
::
shape
::
type_t
dtype
=
migraphx
::
shape
::
get_type
<
CType
>
();
migraphx
::
shape
s
{
dtype
,
{
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
);
auto
min_val
=
mm
->
add_literal
(
migraphx
::
literal
{
migraphx
::
shape
{
dtype
},
{
-
0.95
f
}}
);
auto
max_val
=
mm
->
add_literal
(
migraphx
::
literal
{
migraphx
::
shape
{
dtype
},
{
0.95
f
}}
);
min_val
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"multibroadcast"
,
{{
"out_lens"
,
{
16
}}}),
min_val
);
max_val
=
...
...
@@ -46,3 +50,7 @@ struct test_atanh : verify_program<test_atanh>
return
p
;
}
};
template
struct
test_atanh
<
float
>;
template
struct
test_atanh
<
migraphx
::
half
>;
template
struct
test_atanh
<
migraphx
::
fp8
::
fp8e4m3fnuz
>;
test/verify/test_ceil.cpp
View file @
dc8edad8
...
...
@@ -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_concat_axis_0.cpp
View file @
dc8edad8
...
...
@@ -27,16 +27,17 @@
#include <migraphx/generate.hpp>
#include <migraphx/make_op.hpp>
struct
test_concat_axis_0
:
verify_program
<
test_concat_axis_0
>
template
<
migraphx
::
shape
::
type_t
DType
>
struct
test_concat_axis_0
:
verify_program
<
test_concat_axis_0
<
DType
>>
{
migraphx
::
program
create_program
()
const
{
migraphx
::
program
p
;
auto
*
mm
=
p
.
get_main_module
();
int
axis
=
0
;
migraphx
::
shape
s0
{
migraphx
::
shape
::
int32_t
ype
,
{
2
,
2
}};
migraphx
::
shape
s1
{
migraphx
::
shape
::
int32_t
ype
,
{
3
,
2
}};
migraphx
::
shape
s2
{
migraphx
::
shape
::
int32_t
ype
,
{
1
,
2
}};
migraphx
::
shape
s0
{
DT
ype
,
{
2
,
2
}};
migraphx
::
shape
s1
{
DT
ype
,
{
3
,
2
}};
migraphx
::
shape
s2
{
DT
ype
,
{
1
,
2
}};
auto
l0
=
mm
->
add_parameter
(
"x"
,
s0
);
auto
l1
=
mm
->
add_parameter
(
"y"
,
s1
);
auto
l2
=
mm
->
add_parameter
(
"z"
,
s2
);
...
...
@@ -44,3 +45,8 @@ struct test_concat_axis_0 : verify_program<test_concat_axis_0>
return
p
;
}
};
template
struct
test_concat_axis_0
<
migraphx
::
shape
::
fp8e4m3fnuz_type
>;
template
struct
test_concat_axis_0
<
migraphx
::
shape
::
half_type
>;
template
struct
test_concat_axis_0
<
migraphx
::
shape
::
float_type
>;
template
struct
test_concat_axis_0
<
migraphx
::
shape
::
int32_type
>;
test/verify/test_cos.cpp
View file @
dc8edad8
...
...
@@ -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 @
dc8edad8
...
...
@@ -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 @
dc8edad8
...
...
@@ -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 @
dc8edad8
...
...
@@ -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
>;
Prev
1
2
3
4
5
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