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
93c89587
Commit
93c89587
authored
Dec 13, 2023
by
Paul
Browse files
Split onnx tests
parent
d2532d0e
Changes
490
Hide whitespace changes
Inline
Side-by-side
Showing
20 changed files
with
491 additions
and
0 deletions
+491
-0
test/onnx/parse/flatten_nonstd_test.cpp
test/onnx/parse/flatten_nonstd_test.cpp
+21
-0
test/onnx/parse/flatten_test.cpp
test/onnx/parse/flatten_test.cpp
+17
-0
test/onnx/parse/floor_test.cpp
test/onnx/parse/floor_test.cpp
+17
-0
test/onnx/parse/gather_dyn_test.cpp
test/onnx/parse/gather_dyn_test.cpp
+28
-0
test/onnx/parse/gather_elements_axis0_test.cpp
test/onnx/parse/gather_elements_axis0_test.cpp
+34
-0
test/onnx/parse/gather_elements_axis1_test.cpp
test/onnx/parse/gather_elements_axis1_test.cpp
+34
-0
test/onnx/parse/gather_scalar_test.cpp
test/onnx/parse/gather_scalar_test.cpp
+20
-0
test/onnx/parse/gather_test.cpp
test/onnx/parse/gather_test.cpp
+18
-0
test/onnx/parse/gathernd_batch_dims_test.cpp
test/onnx/parse/gathernd_batch_dims_test.cpp
+18
-0
test/onnx/parse/gathernd_dyn_test.cpp
test/onnx/parse/gathernd_dyn_test.cpp
+23
-0
test/onnx/parse/gathernd_test.cpp
test/onnx/parse/gathernd_test.cpp
+17
-0
test/onnx/parse/gemm_brcst_C_test.cpp
test/onnx/parse/gemm_brcst_C_test.cpp
+32
-0
test/onnx/parse/gemm_dyn_bias_test.cpp
test/onnx/parse/gemm_dyn_bias_test.cpp
+25
-0
test/onnx/parse/gemm_dyn_inner_test.cpp
test/onnx/parse/gemm_dyn_inner_test.cpp
+27
-0
test/onnx/parse/gemm_dyn_outer_test.cpp
test/onnx/parse/gemm_dyn_outer_test.cpp
+27
-0
test/onnx/parse/gemm_half_test.cpp
test/onnx/parse/gemm_half_test.cpp
+36
-0
test/onnx/parse/gemm_no_C_test.cpp
test/onnx/parse/gemm_no_C_test.cpp
+32
-0
test/onnx/parse/gemm_rank_error.cpp
test/onnx/parse/gemm_rank_error.cpp
+10
-0
test/onnx/parse/gemm_test.cpp
test/onnx/parse/gemm_test.cpp
+29
-0
test/onnx/parse/globalavgpool_dyn_test.cpp
test/onnx/parse/globalavgpool_dyn_test.cpp
+26
-0
No files found.
test/onnx/parse/flatten_nonstd_test.cpp
0 → 100644
View file @
93c89587
#include <onnx_test.hpp>
TEST_CASE
(
flatten_nonstd_test
)
{
migraphx
::
program
p
;
auto
*
mm
=
p
.
get_main_module
();
auto
l0
=
mm
->
add_parameter
(
"0"
,
migraphx
::
shape
{
migraphx
::
shape
::
float_type
,
{
2
,
3
,
5
,
4
}});
auto
l1
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"transpose"
,
{{
"permutation"
,
{
0
,
1
,
3
,
2
}}}),
l0
);
auto
l2
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"contiguous"
),
l1
);
mm
->
add_instruction
(
migraphx
::
make_op
(
"flatten"
,
{{
"axis"
,
2
}}),
l2
);
auto
l3
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"contiguous"
),
l1
);
mm
->
add_instruction
(
migraphx
::
make_op
(
"flatten"
,
{{
"axis"
,
1
}}),
l3
);
auto
prog
=
optimize_onnx
(
"flatten_nonstd_test.onnx"
);
EXPECT
(
p
==
prog
);
}
test/onnx/parse/flatten_test.cpp
0 → 100644
View file @
93c89587
#include <onnx_test.hpp>
TEST_CASE
(
flatten_test
)
{
migraphx
::
program
p
;
auto
*
mm
=
p
.
get_main_module
();
auto
l0
=
mm
->
add_parameter
(
"0"
,
migraphx
::
shape
{
migraphx
::
shape
::
float_type
,
{
2
,
3
,
4
,
5
}});
mm
->
add_instruction
(
migraphx
::
make_op
(
"flatten"
,
{{
"axis"
,
2
}}),
l0
);
mm
->
add_instruction
(
migraphx
::
make_op
(
"flatten"
,
{{
"axis"
,
1
}}),
l0
);
auto
prog
=
optimize_onnx
(
"flatten_test.onnx"
);
EXPECT
(
p
==
prog
);
}
test/onnx/parse/floor_test.cpp
0 → 100644
View file @
93c89587
#include <onnx_test.hpp>
TEST_CASE
(
floor_test
)
{
migraphx
::
program
p
;
auto
*
mm
=
p
.
get_main_module
();
auto
input
=
mm
->
add_parameter
(
"x"
,
migraphx
::
shape
{
migraphx
::
shape
::
float_type
,
{
10
}});
mm
->
add_instruction
(
migraphx
::
make_op
(
"floor"
),
input
);
auto
prog
=
optimize_onnx
(
"floor_test.onnx"
);
EXPECT
(
p
==
prog
);
}
test/onnx/parse/gather_dyn_test.cpp
0 → 100644
View file @
93c89587
#include <onnx_test.hpp>
TEST_CASE
(
gather_dyn_test
)
{
migraphx
::
program
p
;
auto
*
mm
=
p
.
get_main_module
();
auto
l0
=
mm
->
add_parameter
(
"data"
,
migraphx
::
shape
{
migraphx
::
shape
::
float_type
,
{{
1
,
4
},
{
4
,
4
},
{
5
,
5
},
{
6
,
6
}}});
auto
l1
=
mm
->
add_parameter
(
"indices"
,
migraphx
::
shape
{
migraphx
::
shape
::
int32_type
,
{{
1
,
4
},
{
3
,
3
},
{
4
,
4
},
{
5
,
5
}}});
auto
cont_l0
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"contiguous"
),
l0
);
auto
cont_l1
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"contiguous"
),
l1
);
int
axis
=
1
;
auto
gather_op
=
migraphx
::
make_op
(
"gather"
,
{{
"axis"
,
axis
}});
auto
ret
=
mm
->
add_instruction
(
gather_op
,
cont_l0
,
cont_l1
);
mm
->
add_return
({
ret
});
migraphx
::
onnx_options
options
;
options
.
default_dyn_dim_value
=
{
1
,
4
};
auto
prog
=
parse_onnx
(
"gather_dyn_test.onnx"
,
options
);
EXPECT
(
p
==
prog
);
}
test/onnx/parse/gather_elements_axis0_test.cpp
0 → 100644
View file @
93c89587
#include <onnx_test.hpp>
TEST_CASE
(
gather_elements_axis0_test
)
{
migraphx
::
program
p
;
auto
*
mm
=
p
.
get_main_module
();
auto
data
=
mm
->
add_parameter
(
"data"
,
{
migraphx
::
shape
::
float_type
,
{
3
,
4
}});
auto
indices
=
mm
->
add_parameter
(
"indices"
,
{
migraphx
::
shape
::
int32_type
,
{
2
,
3
}});
std
::
vector
<
int
>
ind_indices
{
0
,
1
,
2
,
4
,
5
,
6
};
std
::
vector
<
int
>
ind_axis_indices
{
0
,
0
,
0
,
1
,
1
,
1
};
migraphx
::
shape
ind_s
{
migraphx
::
shape
::
int32_type
,
{
2
,
3
}};
auto
l_data_indices
=
mm
->
add_literal
(
migraphx
::
literal
{
ind_s
,
ind_indices
.
begin
(),
ind_indices
.
end
()});
auto
l_ind_axis_indices
=
mm
->
add_literal
(
migraphx
::
literal
{
ind_s
,
ind_axis_indices
.
begin
(),
ind_axis_indices
.
end
()});
auto
l_stride
=
mm
->
add_literal
(
migraphx
::
literal
{{
migraphx
::
shape
::
int32_type
,
{
1
}},
{
4
}});
auto
rsp_data
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"reshape"
,
{{
"dims"
,
{
12
}}}),
data
);
auto
lbst_stride
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"multibroadcast"
,
{{
"out_lens"
,
ind_s
.
lens
()}}),
l_stride
);
auto
axis_delta
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"sub"
),
indices
,
l_ind_axis_indices
);
auto
mul_delta
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"mul"
),
axis_delta
,
lbst_stride
);
auto
ind
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"add"
),
l_data_indices
,
mul_delta
);
auto
ret
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"gather"
,
{{
"axis"
,
0
}}),
rsp_data
,
ind
);
mm
->
add_return
({
ret
});
auto
prog
=
migraphx
::
parse_onnx
(
"gather_elements_axis0_test.onnx"
);
EXPECT
(
p
==
prog
);
}
test/onnx/parse/gather_elements_axis1_test.cpp
0 → 100644
View file @
93c89587
#include <onnx_test.hpp>
TEST_CASE
(
gather_elements_axis1_test
)
{
migraphx
::
program
p
;
auto
*
mm
=
p
.
get_main_module
();
auto
data
=
mm
->
add_parameter
(
"data"
,
{
migraphx
::
shape
::
float_type
,
{
3
,
4
}});
auto
indices
=
mm
->
add_parameter
(
"indices"
,
{
migraphx
::
shape
::
int32_type
,
{
2
,
3
}});
std
::
vector
<
int
>
ind_indices
{
0
,
1
,
2
,
4
,
5
,
6
};
std
::
vector
<
int
>
ind_axis_indices
{
0
,
1
,
2
,
0
,
1
,
2
};
migraphx
::
shape
ind_s
{
migraphx
::
shape
::
int32_type
,
{
2
,
3
}};
auto
l_data_indices
=
mm
->
add_literal
(
migraphx
::
literal
{
ind_s
,
ind_indices
.
begin
(),
ind_indices
.
end
()});
auto
l_ind_axis_indices
=
mm
->
add_literal
(
migraphx
::
literal
{
ind_s
,
ind_axis_indices
.
begin
(),
ind_axis_indices
.
end
()});
auto
l_stride
=
mm
->
add_literal
(
migraphx
::
literal
{{
migraphx
::
shape
::
int32_type
,
{
1
}},
{
1
}});
auto
rsp_data
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"reshape"
,
{{
"dims"
,
{
12
}}}),
data
);
auto
lbst_stride
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"multibroadcast"
,
{{
"out_lens"
,
ind_s
.
lens
()}}),
l_stride
);
auto
axis_delta
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"sub"
),
indices
,
l_ind_axis_indices
);
auto
mul_delta
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"mul"
),
axis_delta
,
lbst_stride
);
auto
ind
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"add"
),
l_data_indices
,
mul_delta
);
auto
ret
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"gather"
,
{{
"axis"
,
0
}}),
rsp_data
,
ind
);
mm
->
add_return
({
ret
});
auto
prog
=
migraphx
::
parse_onnx
(
"gather_elements_axis1_test.onnx"
);
EXPECT
(
p
==
prog
);
}
test/onnx/parse/gather_scalar_test.cpp
0 → 100644
View file @
93c89587
#include <onnx_test.hpp>
TEST_CASE
(
gather_scalar_test
)
{
migraphx
::
program
p
;
auto
*
mm
=
p
.
get_main_module
();
auto
l0
=
mm
->
add_parameter
(
"data"
,
migraphx
::
shape
{
migraphx
::
shape
::
float_type
,
{
3
,
4
,
5
,
6
}});
std
::
vector
<
size_t
>
idims
{
1
};
auto
l1
=
mm
->
add_parameter
(
"indices"
,
migraphx
::
shape
{
migraphx
::
shape
::
int32_type
,
idims
,
{
0
}});
int
axis
=
1
;
mm
->
add_instruction
(
migraphx
::
make_op
(
"gather"
,
{{
"axis"
,
axis
}}),
l0
,
l1
);
auto
prog
=
optimize_onnx
(
"gather_scalar_test.onnx"
);
EXPECT
(
p
==
prog
);
}
test/onnx/parse/gather_test.cpp
0 → 100644
View file @
93c89587
#include <onnx_test.hpp>
TEST_CASE
(
gather_test
)
{
migraphx
::
program
p
;
auto
*
mm
=
p
.
get_main_module
();
auto
l0
=
mm
->
add_parameter
(
"data"
,
migraphx
::
shape
{
migraphx
::
shape
::
float_type
,
{
3
,
4
,
5
,
6
}});
auto
l1
=
mm
->
add_parameter
(
"indices"
,
migraphx
::
shape
{
migraphx
::
shape
::
int32_type
,
{
2
,
3
}});
int
axis
=
1
;
mm
->
add_instruction
(
migraphx
::
make_op
(
"gather"
,
{{
"axis"
,
axis
}}),
l0
,
l1
);
auto
prog
=
optimize_onnx
(
"gather_test.onnx"
);
EXPECT
(
p
==
prog
);
}
test/onnx/parse/gathernd_batch_dims_test.cpp
0 → 100644
View file @
93c89587
#include <onnx_test.hpp>
TEST_CASE
(
gathernd_batch_dims_test
)
{
migraphx
::
program
p
;
auto
*
mm
=
p
.
get_main_module
();
auto
l0
=
mm
->
add_parameter
(
"data"
,
migraphx
::
shape
{
migraphx
::
shape
::
float_type
,
{
2
,
2
,
2
}});
auto
l1
=
mm
->
add_parameter
(
"indices"
,
migraphx
::
shape
{
migraphx
::
shape
::
int64_type
,
{
2
,
1
}});
int
batch_dims
=
1
;
mm
->
add_instruction
(
migraphx
::
make_op
(
"gathernd"
,
{{
"batch_dims"
,
batch_dims
}}),
l0
,
l1
);
auto
prog
=
optimize_onnx
(
"gathernd_batch_dims_test.onnx"
);
EXPECT
(
p
==
prog
);
}
test/onnx/parse/gathernd_dyn_test.cpp
0 → 100644
View file @
93c89587
#include <onnx_test.hpp>
TEST_CASE
(
gathernd_dyn_test
)
{
migraphx
::
program
p
;
auto
*
mm
=
p
.
get_main_module
();
auto
l0
=
mm
->
add_parameter
(
"data"
,
migraphx
::
shape
{
migraphx
::
shape
::
float_type
,
{{
2
,
4
,
{
2
}},
{
2
,
4
}}});
auto
l1
=
mm
->
add_parameter
(
"indices"
,
migraphx
::
shape
{
migraphx
::
shape
::
int64_type
,
{{
1
,
3
},
{
2
,
2
}}});
auto
r
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"gathernd"
),
l0
,
l1
);
mm
->
add_return
({
r
});
migraphx
::
onnx_options
options
;
options
.
map_dyn_input_dims
[
"data"
]
=
{{
2
,
4
,
{
2
}},
{
2
,
4
}};
options
.
map_dyn_input_dims
[
"indices"
]
=
{{
1
,
3
},
{
2
,
2
}};
auto
prog
=
migraphx
::
parse_onnx
(
"gathernd_dyn_test.onnx"
,
options
);
EXPECT
(
p
==
prog
);
}
test/onnx/parse/gathernd_test.cpp
0 → 100644
View file @
93c89587
#include <onnx_test.hpp>
TEST_CASE
(
gathernd_test
)
{
migraphx
::
program
p
;
auto
*
mm
=
p
.
get_main_module
();
auto
l0
=
mm
->
add_parameter
(
"data"
,
migraphx
::
shape
{
migraphx
::
shape
::
float_type
,
{
2
,
2
}});
auto
l1
=
mm
->
add_parameter
(
"indices"
,
migraphx
::
shape
{
migraphx
::
shape
::
int64_type
,
{
2
,
2
}});
mm
->
add_instruction
(
migraphx
::
make_op
(
"gathernd"
),
l0
,
l1
);
auto
prog
=
optimize_onnx
(
"gathernd_test.onnx"
);
EXPECT
(
p
==
prog
);
}
test/onnx/parse/gemm_brcst_C_test.cpp
0 → 100644
View file @
93c89587
#include <onnx_test.hpp>
#include <migraphx/apply_alpha_beta.hpp>
TEST_CASE
(
gemm_brcst_C_test
)
{
migraphx
::
program
p
;
auto
*
mm
=
p
.
get_main_module
();
auto
l0
=
mm
->
add_parameter
(
"A"
,
migraphx
::
shape
{
migraphx
::
shape
::
float_type
,
{
5
,
6
}});
auto
l1
=
mm
->
add_parameter
(
"B"
,
migraphx
::
shape
{
migraphx
::
shape
::
float_type
,
{
5
,
7
}});
auto
l2
=
mm
->
add_parameter
(
"C"
,
migraphx
::
shape
{
migraphx
::
shape
::
float_type
,
{
6
,
1
}});
std
::
vector
<
std
::
size_t
>
out_lens
{
6
,
7
};
auto
alpha
=
0.5
f
;
auto
beta
=
0.8
f
;
auto
a_l
=
mm
->
add_literal
(
alpha
);
auto
t_a
=
add_common_op
(
*
mm
,
migraphx
::
make_op
(
"mul"
),
{
a_l
,
l0
});
t_a
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"transpose"
,
{{
"permutation"
,
{
1
,
0
}}}),
t_a
);
auto
dot
=
migraphx
::
add_apply_alpha_beta
(
*
mm
,
{
t_a
,
l1
},
migraphx
::
make_op
(
"dot"
),
1.0
f
,
0.0
f
);
auto
b_l
=
mm
->
add_literal
(
beta
);
auto
l2_b
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"multibroadcast"
,
{{
"out_lens"
,
out_lens
}}),
l2
);
auto
b_b
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"multibroadcast"
,
{{
"out_lens"
,
l2_b
->
get_shape
().
lens
()}}),
b_l
);
auto
l2_bb
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"mul"
),
l2_b
,
b_b
);
mm
->
add_instruction
(
migraphx
::
make_op
(
"add"
),
dot
,
l2_bb
);
auto
prog
=
optimize_onnx
(
"gemm_brcst_C_test.onnx"
);
EXPECT
(
p
==
prog
);
}
test/onnx/parse/gemm_dyn_bias_test.cpp
0 → 100644
View file @
93c89587
#include <onnx_test.hpp>
TEST_CASE
(
gemm_dyn_bias_test
)
{
migraphx
::
program
p
;
auto
*
mm
=
p
.
get_main_module
();
auto
x0
=
mm
->
add_parameter
(
"A"
,
migraphx
::
shape
{
migraphx
::
shape
::
float_type
,
{{
8
,
8
},
{
1
,
10
}}});
auto
x1
=
mm
->
add_parameter
(
"B"
,
migraphx
::
shape
{
migraphx
::
shape
::
float_type
,
{
8
,
7
}});
auto
x2
=
mm
->
add_parameter
(
"C"
,
migraphx
::
shape
{
migraphx
::
shape
::
float_type
,
{
1
,
7
}});
auto
x0_t
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"transpose"
,
{{
"permutation"
,
{
1
,
0
}}}),
x0
);
auto
dot
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"dot"
),
x0_t
,
x1
);
auto
x2_b
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"multibroadcast"
),
x2
,
dot
);
auto
ret
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"add"
),
dot
,
x2_b
);
mm
->
add_return
({
ret
});
migraphx
::
onnx_options
options
;
options
.
default_dyn_dim_value
=
{
1
,
10
};
auto
prog
=
parse_onnx
(
"gemm_dyn_bias_test.onnx"
,
options
);
EXPECT
(
p
==
prog
);
}
test/onnx/parse/gemm_dyn_inner_test.cpp
0 → 100644
View file @
93c89587
#include <onnx_test.hpp>
#include <migraphx/apply_alpha_beta.hpp>
TEST_CASE
(
gemm_dyn_inner_test
)
{
migraphx
::
program
p
;
auto
*
mm
=
p
.
get_main_module
();
auto
l0
=
mm
->
add_parameter
(
"A"
,
migraphx
::
shape
{
migraphx
::
shape
::
float_type
,
{{
1
,
10
,
{
8
}},
{
6
,
6
}}});
auto
l1
=
mm
->
add_parameter
(
"B"
,
migraphx
::
shape
{
migraphx
::
shape
::
float_type
,
{{
1
,
10
,
{
8
}},
{
7
,
7
}}});
auto
alpha
=
0.5
f
;
auto
a_l
=
mm
->
add_literal
(
alpha
);
auto
t_a
=
add_common_op
(
*
mm
,
migraphx
::
make_op
(
"mul"
),
{
a_l
,
l0
});
t_a
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"transpose"
,
{{
"permutation"
,
{
1
,
0
}}}),
t_a
);
auto
dot
=
migraphx
::
add_apply_alpha_beta
(
*
mm
,
{
t_a
,
l1
},
migraphx
::
make_op
(
"dot"
),
1.0
f
,
0.0
f
);
mm
->
add_return
({
dot
});
migraphx
::
onnx_options
options
;
options
.
default_dyn_dim_value
=
{
1
,
10
,
{
8
}};
auto
prog
=
migraphx
::
parse_onnx
(
"gemm_dyn_inner_test.onnx"
,
options
);
EXPECT
(
p
==
prog
);
}
test/onnx/parse/gemm_dyn_outer_test.cpp
0 → 100644
View file @
93c89587
#include <onnx_test.hpp>
#include <migraphx/apply_alpha_beta.hpp>
TEST_CASE
(
gemm_dyn_outer_test
)
{
migraphx
::
program
p
;
auto
*
mm
=
p
.
get_main_module
();
auto
l0
=
mm
->
add_parameter
(
"A"
,
migraphx
::
shape
{
migraphx
::
shape
::
float_type
,
{{
5
,
5
},
{
5
,
10
,
{
7
}}}});
auto
l1
=
mm
->
add_parameter
(
"B"
,
migraphx
::
shape
{
migraphx
::
shape
::
float_type
,
{
11
,
5
}});
auto
alpha
=
2.
f
;
auto
a_l
=
mm
->
add_literal
(
alpha
);
auto
t_a
=
add_common_op
(
*
mm
,
migraphx
::
make_op
(
"mul"
),
{
a_l
,
l0
});
t_a
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"transpose"
,
{{
"permutation"
,
{
1
,
0
}}}),
t_a
);
auto
t1
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"transpose"
,
{{
"permutation"
,
{
1
,
0
}}}),
l1
);
auto
dot
=
migraphx
::
add_apply_alpha_beta
(
*
mm
,
{
t_a
,
t1
},
migraphx
::
make_op
(
"dot"
),
1.0
f
,
0.0
f
);
mm
->
add_return
({
dot
});
migraphx
::
onnx_options
options
;
options
.
default_dyn_dim_value
=
{
5
,
10
,
{
7
}};
auto
prog
=
migraphx
::
parse_onnx
(
"gemm_dyn_outer_test.onnx"
,
options
);
EXPECT
(
p
==
prog
);
}
test/onnx/parse/gemm_half_test.cpp
0 → 100644
View file @
93c89587
#include <onnx_test.hpp>
#include <migraphx/apply_alpha_beta.hpp>
TEST_CASE
(
gemm_half_test
)
{
migraphx
::
program
p
;
auto
*
mm
=
p
.
get_main_module
();
auto
l0
=
mm
->
add_parameter
(
"A"
,
migraphx
::
shape
{
migraphx
::
shape
::
half_type
,
{
8
,
6
}});
auto
l1
=
mm
->
add_parameter
(
"B"
,
migraphx
::
shape
{
migraphx
::
shape
::
half_type
,
{
8
,
7
}});
auto
l2
=
mm
->
add_parameter
(
"C"
,
migraphx
::
shape
{
migraphx
::
shape
::
half_type
,
{
6
,
1
}});
auto
alpha
=
0.5
f
;
auto
beta
=
0.8
f
;
auto
a_l
=
mm
->
add_literal
(
alpha
);
auto
t_a
=
add_common_op
(
*
mm
,
migraphx
::
make_op
(
"mul"
),
{
a_l
,
l0
});
t_a
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"convert"
,
{{
"target_type"
,
migraphx
::
shape
::
half_type
}}),
t_a
);
t_a
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"transpose"
,
{{
"permutation"
,
{
1
,
0
}}}),
t_a
);
std
::
vector
<
std
::
size_t
>
lens
=
{
6
,
7
};
auto
dot
=
migraphx
::
add_apply_alpha_beta
(
*
mm
,
{
t_a
,
l1
},
migraphx
::
make_op
(
"dot"
),
1.0
f
,
0.0
f
);
l2
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"multibroadcast"
,
{{
"out_lens"
,
lens
}}),
l2
);
l2
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"convert"
,
{{
"target_type"
,
migraphx
::
shape
::
float_type
}}),
l2
);
auto
b_l
=
mm
->
add_literal
(
beta
);
auto
b_b
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"multibroadcast"
,
{{
"out_lens"
,
lens
}}),
b_l
);
auto
l2_b
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"mul"
),
l2
,
b_b
);
l2_b
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"convert"
,
{{
"target_type"
,
migraphx
::
shape
::
half_type
}}),
l2_b
);
mm
->
add_instruction
(
migraphx
::
make_op
(
"add"
),
dot
,
l2_b
);
auto
prog
=
optimize_onnx
(
"gemm_half_test.onnx"
);
EXPECT
(
p
==
prog
);
}
test/onnx/parse/gemm_no_C_test.cpp
0 → 100644
View file @
93c89587
#include <onnx_test.hpp>
#include <migraphx/apply_alpha_beta.hpp>
TEST_CASE
(
gemm_no_C_test
)
{
migraphx
::
program
p
;
auto
*
mm
=
p
.
get_main_module
();
auto
l0
=
mm
->
add_parameter
(
"A"
,
migraphx
::
shape
{
migraphx
::
shape
::
float_type
,
{
5
,
7
}});
auto
l1
=
mm
->
add_parameter
(
"B"
,
migraphx
::
shape
{
migraphx
::
shape
::
float_type
,
{
11
,
5
}});
auto
l2
=
mm
->
add_parameter
(
"C"
,
migraphx
::
shape
{
migraphx
::
shape
::
float_type
});
auto
alpha
=
2.
f
;
auto
beta
=
2.0
f
;
auto
a_l
=
mm
->
add_literal
(
alpha
);
auto
t_a
=
add_common_op
(
*
mm
,
migraphx
::
make_op
(
"mul"
),
{
a_l
,
l0
});
t_a
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"transpose"
,
{{
"permutation"
,
{
1
,
0
}}}),
t_a
);
auto
t1
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"transpose"
,
{{
"permutation"
,
{
1
,
0
}}}),
l1
);
auto
dot
=
migraphx
::
add_apply_alpha_beta
(
*
mm
,
{
t_a
,
t1
},
migraphx
::
make_op
(
"dot"
),
1.0
f
,
0.0
f
);
auto
b_l
=
mm
->
add_literal
(
beta
);
auto
l2_b
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"multibroadcast"
,
{{
"out_lens"
,
{
7
,
11
}}}),
l2
);
auto
b_b
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"multibroadcast"
,
{{
"out_lens"
,
l2_b
->
get_shape
().
lens
()}}),
b_l
);
auto
l2_bb
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"mul"
),
l2_b
,
b_b
);
mm
->
add_instruction
(
migraphx
::
make_op
(
"add"
),
dot
,
l2_bb
);
auto
prog
=
optimize_onnx
(
"gemm_no_C_test.onnx"
);
EXPECT
(
p
==
prog
);
}
test/onnx/parse/gemm_rank_error.cpp
0 → 100644
View file @
93c89587
#include <onnx_test.hpp>
TEST_CASE
(
gemm_rank_error
)
{
EXPECT
(
test
::
throws
([
&
]
{
migraphx
::
parse_onnx
(
"gemm_rank_error.onnx"
);
}));
}
test/onnx/parse/gemm_test.cpp
0 → 100644
View file @
93c89587
#include <onnx_test.hpp>
#include <migraphx/apply_alpha_beta.hpp>
TEST_CASE
(
gemm_test
)
{
migraphx
::
program
p
;
auto
*
mm
=
p
.
get_main_module
();
auto
l0
=
mm
->
add_parameter
(
"A"
,
migraphx
::
shape
{
migraphx
::
shape
::
float_type
,
{
8
,
6
}});
auto
l1
=
mm
->
add_parameter
(
"B"
,
migraphx
::
shape
{
migraphx
::
shape
::
float_type
,
{
8
,
7
}});
auto
l2
=
mm
->
add_parameter
(
"C"
,
migraphx
::
shape
{
migraphx
::
shape
::
float_type
,
{
6
,
7
}});
auto
alpha
=
0.5
f
;
auto
beta
=
0.8
f
;
auto
a_l
=
mm
->
add_literal
(
alpha
);
auto
t_a
=
add_common_op
(
*
mm
,
migraphx
::
make_op
(
"mul"
),
{
a_l
,
l0
});
t_a
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"transpose"
,
{{
"permutation"
,
{
1
,
0
}}}),
t_a
);
auto
dot
=
migraphx
::
add_apply_alpha_beta
(
*
mm
,
{
t_a
,
l1
},
migraphx
::
make_op
(
"dot"
),
1.0
f
,
0.0
f
);
auto
b_l
=
mm
->
add_literal
(
beta
);
auto
b_b
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"multibroadcast"
,
{{
"out_lens"
,
l2
->
get_shape
().
lens
()}}),
b_l
);
auto
l2_b
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"mul"
),
l2
,
b_b
);
mm
->
add_instruction
(
migraphx
::
make_op
(
"add"
),
dot
,
l2_b
);
auto
prog
=
optimize_onnx
(
"gemm_test.onnx"
);
EXPECT
(
p
==
prog
);
}
test/onnx/parse/globalavgpool_dyn_test.cpp
0 → 100644
View file @
93c89587
#include <onnx_test.hpp>
#include <migraphx/op/pooling.hpp>
TEST_CASE
(
globalavgpool_dyn_test
)
{
migraphx
::
program
p
;
auto
*
mm
=
p
.
get_main_module
();
auto
input
=
mm
->
add_parameter
(
"0"
,
migraphx
::
shape
{
migraphx
::
shape
::
float_type
,
{{
1
,
4
},
{
3
,
3
},
{
16
,
16
},
{
16
,
16
}}});
auto
ret
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"pooling"
,
{{
"mode"
,
migraphx
::
op
::
pooling_mode
::
average
},
{
"lengths"
,
{
16
,
16
}},
{
"padding"
,
{
0
,
0
,
0
,
0
}}}),
input
);
mm
->
add_return
({
ret
});
migraphx
::
onnx_options
options
;
options
.
default_dyn_dim_value
=
{
1
,
4
};
auto
prog
=
parse_onnx
(
"globalavgpool_dyn_test.onnx"
,
options
);
EXPECT
(
p
==
prog
);
}
Prev
1
…
4
5
6
7
8
9
10
11
12
…
25
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