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
617 additions
and
0 deletions
+617
-0
test/onnx/parse/group_norm_missing_attribute_error_test.cpp
test/onnx/parse/group_norm_missing_attribute_error_test.cpp
+11
-0
test/onnx/parse/group_norm_small_eps_half_test.cpp
test/onnx/parse/group_norm_small_eps_half_test.cpp
+14
-0
test/onnx/parse/hardsigmoid_default_test.cpp
test/onnx/parse/hardsigmoid_default_test.cpp
+38
-0
test/onnx/parse/hardsigmoid_double_test.cpp
test/onnx/parse/hardsigmoid_double_test.cpp
+38
-0
test/onnx/parse/hardsigmoid_half_test.cpp
test/onnx/parse/hardsigmoid_half_test.cpp
+38
-0
test/onnx/parse/hardswish_test.cpp
test/onnx/parse/hardswish_test.cpp
+40
-0
test/onnx/parse/if_else_test.cpp
test/onnx/parse/if_else_test.cpp
+37
-0
test/onnx/parse/if_else_test_inlined.cpp
test/onnx/parse/if_else_test_inlined.cpp
+30
-0
test/onnx/parse/if_literal_test.cpp
test/onnx/parse/if_literal_test.cpp
+34
-0
test/onnx/parse/if_param_excp1_test.cpp
test/onnx/parse/if_param_excp1_test.cpp
+10
-0
test/onnx/parse/if_param_excp_test.cpp
test/onnx/parse/if_param_excp_test.cpp
+10
-0
test/onnx/parse/if_param_test.cpp
test/onnx/parse/if_param_test.cpp
+35
-0
test/onnx/parse/if_pl_test.cpp
test/onnx/parse/if_pl_test.cpp
+40
-0
test/onnx/parse/if_then_else_multi_output_shapes_inlined_test.cpp
...x/parse/if_then_else_multi_output_shapes_inlined_test.cpp
+33
-0
test/onnx/parse/if_then_else_multi_output_shapes_test.cpp
test/onnx/parse/if_then_else_multi_output_shapes_test.cpp
+41
-0
test/onnx/parse/if_then_test.cpp
test/onnx/parse/if_then_test.cpp
+37
-0
test/onnx/parse/if_then_test_inlined.cpp
test/onnx/parse/if_then_test_inlined.cpp
+31
-0
test/onnx/parse/if_tuple_test.cpp
test/onnx/parse/if_tuple_test.cpp
+47
-0
test/onnx/parse/imagescaler_half_test.cpp
test/onnx/parse/imagescaler_half_test.cpp
+27
-0
test/onnx/parse/imagescaler_test.cpp
test/onnx/parse/imagescaler_test.cpp
+26
-0
No files found.
test/onnx/parse/group_norm_missing_attribute_error_test.cpp
0 → 100644
View file @
93c89587
#include <onnx_test.hpp>
TEST_CASE
(
group_norm_missing_attribute_error_test
)
{
EXPECT
(
test
::
throws
(
[
&
]
{
migraphx
::
parse_onnx
(
"group_norm_missing_attribute_error_test.onnx"
);
}));
}
test/onnx/parse/group_norm_small_eps_half_test.cpp
0 → 100644
View file @
93c89587
#include <onnx_test.hpp>
#include <onnx_test_utils.hpp>
TEST_CASE
(
group_norm_small_eps_half_test
)
{
migraphx
::
program
p
=
make_group_norm
(
{
1
,
4
,
2
},
{
2
},
{
2
},
{
1
,
2
,
2
,
2
},
{
2
,
3
},
1e-7
f
,
migraphx
::
shape
::
half_type
);
auto
prog
=
optimize_onnx
(
"group_norm_small_eps_half_test.onnx"
);
EXPECT
(
p
==
prog
);
}
test/onnx/parse/hardsigmoid_default_test.cpp
0 → 100644
View file @
93c89587
#include <onnx_test.hpp>
TEST_CASE
(
hardsigmoid_default_test
)
{
migraphx
::
program
p
;
auto
*
mm
=
p
.
get_main_module
();
std
::
vector
<
std
::
size_t
>
input_lens
{
1
,
3
,
4
,
5
};
auto
input_type
=
migraphx
::
shape
::
float_type
;
migraphx
::
shape
s
{
input_type
,
input_lens
};
auto
x
=
mm
->
add_parameter
(
"x"
,
s
);
float
alpha
=
0.2
;
float
beta
=
0.5
;
auto
mb_alpha
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"multibroadcast"
,
{{
"out_lens"
,
input_lens
}}),
mm
->
add_literal
(
migraphx
::
literal
{
migraphx
::
shape
{
input_type
},
{
alpha
}}));
auto
mb_beta
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"multibroadcast"
,
{{
"out_lens"
,
input_lens
}}),
mm
->
add_literal
(
migraphx
::
literal
{
migraphx
::
shape
{
input_type
},
{
beta
}}));
auto
mb_zero
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"multibroadcast"
,
{{
"out_lens"
,
input_lens
}}),
mm
->
add_literal
(
migraphx
::
literal
{
migraphx
::
shape
{
input_type
},
{
0
}}));
auto
mb_one
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"multibroadcast"
,
{{
"out_lens"
,
input_lens
}}),
mm
->
add_literal
(
migraphx
::
literal
{
migraphx
::
shape
{
input_type
},
{
1
}}));
auto
mul
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"mul"
),
mb_alpha
,
x
);
auto
add
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"add"
),
mb_beta
,
mul
);
mm
->
add_instruction
(
migraphx
::
make_op
(
"clip"
),
add
,
mb_zero
,
mb_one
);
auto
prog
=
optimize_onnx
(
"hardsigmoid_default_test.onnx"
);
EXPECT
(
p
==
prog
);
}
test/onnx/parse/hardsigmoid_double_test.cpp
0 → 100644
View file @
93c89587
#include <onnx_test.hpp>
TEST_CASE
(
hardsigmoid_double_test
)
{
migraphx
::
program
p
;
auto
*
mm
=
p
.
get_main_module
();
std
::
vector
<
std
::
size_t
>
input_lens
{
1
,
3
,
4
,
5
};
auto
input_type
=
migraphx
::
shape
::
double_type
;
migraphx
::
shape
s
{
input_type
,
input_lens
};
auto
x
=
mm
->
add_parameter
(
"x"
,
s
);
float
alpha
=
0.3
;
float
beta
=
0.7
;
auto
mb_alpha
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"multibroadcast"
,
{{
"out_lens"
,
input_lens
}}),
mm
->
add_literal
(
migraphx
::
literal
{
migraphx
::
shape
{
input_type
},
{
alpha
}}));
auto
mb_beta
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"multibroadcast"
,
{{
"out_lens"
,
input_lens
}}),
mm
->
add_literal
(
migraphx
::
literal
{
migraphx
::
shape
{
input_type
},
{
beta
}}));
auto
mb_zero
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"multibroadcast"
,
{{
"out_lens"
,
input_lens
}}),
mm
->
add_literal
(
migraphx
::
literal
{
migraphx
::
shape
{
input_type
},
{
0
}}));
auto
mb_one
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"multibroadcast"
,
{{
"out_lens"
,
input_lens
}}),
mm
->
add_literal
(
migraphx
::
literal
{
migraphx
::
shape
{
input_type
},
{
1
}}));
auto
mul
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"mul"
),
mb_alpha
,
x
);
auto
add
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"add"
),
mb_beta
,
mul
);
mm
->
add_instruction
(
migraphx
::
make_op
(
"clip"
),
add
,
mb_zero
,
mb_one
);
auto
prog
=
optimize_onnx
(
"hardsigmoid_double_test.onnx"
);
EXPECT
(
p
==
prog
);
}
test/onnx/parse/hardsigmoid_half_test.cpp
0 → 100644
View file @
93c89587
#include <onnx_test.hpp>
TEST_CASE
(
hardsigmoid_half_test
)
{
migraphx
::
program
p
;
auto
*
mm
=
p
.
get_main_module
();
std
::
vector
<
std
::
size_t
>
input_lens
{
1
,
3
,
4
,
5
};
auto
input_type
=
migraphx
::
shape
::
half_type
;
migraphx
::
shape
s
{
input_type
,
input_lens
};
auto
x
=
mm
->
add_parameter
(
"x"
,
s
);
float
alpha
=
0.2
;
float
beta
=
0.5
;
auto
mb_alpha
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"multibroadcast"
,
{{
"out_lens"
,
input_lens
}}),
mm
->
add_literal
(
migraphx
::
literal
{
migraphx
::
shape
{
input_type
},
{
alpha
}}));
auto
mb_beta
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"multibroadcast"
,
{{
"out_lens"
,
input_lens
}}),
mm
->
add_literal
(
migraphx
::
literal
{
migraphx
::
shape
{
input_type
},
{
beta
}}));
auto
mb_zero
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"multibroadcast"
,
{{
"out_lens"
,
input_lens
}}),
mm
->
add_literal
(
migraphx
::
literal
{
migraphx
::
shape
{
input_type
},
{
0
}}));
auto
mb_one
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"multibroadcast"
,
{{
"out_lens"
,
input_lens
}}),
mm
->
add_literal
(
migraphx
::
literal
{
migraphx
::
shape
{
input_type
},
{
1
}}));
auto
mul
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"mul"
),
mb_alpha
,
x
);
auto
add
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"add"
),
mb_beta
,
mul
);
mm
->
add_instruction
(
migraphx
::
make_op
(
"clip"
),
add
,
mb_zero
,
mb_one
);
auto
prog
=
optimize_onnx
(
"hardsigmoid_half_test.onnx"
);
EXPECT
(
p
==
prog
);
}
test/onnx/parse/hardswish_test.cpp
0 → 100644
View file @
93c89587
#include <onnx_test.hpp>
TEST_CASE
(
hardswish_test
)
{
migraphx
::
program
p
;
auto
*
mm
=
p
.
get_main_module
();
std
::
vector
<
std
::
size_t
>
input_lens
{
2
,
5
};
auto
input_type
=
migraphx
::
shape
::
float_type
;
migraphx
::
shape
s
{
input_type
,
input_lens
};
auto
x
=
mm
->
add_parameter
(
"x"
,
s
);
float
alpha
=
1.0
/
6.0
;
float
beta
=
0.5
;
auto
mb_alpha
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"multibroadcast"
,
{{
"out_lens"
,
input_lens
}}),
mm
->
add_literal
(
migraphx
::
literal
{
migraphx
::
shape
{
input_type
},
{
alpha
}}));
auto
mb_beta
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"multibroadcast"
,
{{
"out_lens"
,
input_lens
}}),
mm
->
add_literal
(
migraphx
::
literal
{
migraphx
::
shape
{
input_type
},
{
beta
}}));
auto
mb_zero
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"multibroadcast"
,
{{
"out_lens"
,
input_lens
}}),
mm
->
add_literal
(
migraphx
::
literal
{
migraphx
::
shape
{
input_type
},
{
0
}}));
auto
mb_one
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"multibroadcast"
,
{{
"out_lens"
,
input_lens
}}),
mm
->
add_literal
(
migraphx
::
literal
{
migraphx
::
shape
{
input_type
},
{
1
}}));
auto
mul
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"mul"
),
mb_alpha
,
x
);
auto
add
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"add"
),
mb_beta
,
mul
);
auto
hardsigmoid
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"clip"
),
add
,
mb_zero
,
mb_one
);
mm
->
add_instruction
(
migraphx
::
make_op
(
"mul"
),
x
,
hardsigmoid
);
auto
prog
=
optimize_onnx
(
"hardswish_test.onnx"
);
EXPECT
(
p
==
prog
);
}
test/onnx/parse/if_else_test.cpp
0 → 100644
View file @
93c89587
#include <onnx_test.hpp>
TEST_CASE
(
if_else_test
)
{
migraphx
::
program
p
;
auto
*
mm
=
p
.
get_main_module
();
migraphx
::
shape
sc
{
migraphx
::
shape
::
bool_type
,
{
1
}};
migraphx
::
shape
s
{
migraphx
::
shape
::
float_type
,
{
2
,
3
}};
std
::
vector
<
float
>
ones
(
s
.
elements
(),
1.0
f
);
std
::
vector
<
float
>
rand
=
{
1.3865
,
-
0.494756
,
-
0.283504
,
0.200491
,
-
0.490031
,
1.32388
};
auto
l1
=
mm
->
add_literal
(
s
,
ones
);
auto
l2
=
mm
->
add_literal
(
s
,
rand
);
auto
x
=
mm
->
add_parameter
(
"x"
,
s
);
auto
y
=
mm
->
add_parameter
(
"y"
,
s
);
auto
cond
=
mm
->
add_parameter
(
"cond"
,
sc
);
auto
*
then_mod
=
p
.
create_module
(
"If_5_if"
);
auto
rt
=
then_mod
->
add_instruction
(
migraphx
::
make_op
(
"add"
),
x
,
l1
);
then_mod
->
add_return
({
rt
});
auto
*
else_mod
=
p
.
create_module
(
"If_5_else"
);
auto
re
=
else_mod
->
add_instruction
(
migraphx
::
make_op
(
"mul"
),
y
,
l2
);
else_mod
->
add_return
({
re
});
auto
ret
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"if"
),
{
cond
},
{
then_mod
,
else_mod
});
auto
r
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"get_tuple_elem"
,
{{
"index"
,
0
}}),
ret
);
mm
->
add_return
({
r
});
auto
prog
=
migraphx
::
parse_onnx
(
"if_else_test.onnx"
);
EXPECT
(
p
==
prog
);
}
test/onnx/parse/if_else_test_inlined.cpp
0 → 100644
View file @
93c89587
#include <onnx_test.hpp>
TEST_CASE
(
if_else_test_inlined
)
{
migraphx
::
program
p
;
auto
*
mm
=
p
.
get_main_module
();
migraphx
::
shape
sc
{
migraphx
::
shape
::
bool_type
,
{
1
}};
mm
->
add_literal
(
migraphx
::
literal
(
sc
,
{
0
}));
migraphx
::
shape
s
{
migraphx
::
shape
::
float_type
,
{
2
,
3
}};
std
::
vector
<
float
>
ones
(
s
.
elements
(),
1.0
f
);
mm
->
add_literal
(
s
,
ones
);
std
::
vector
<
float
>
rand
=
{
0.811412
,
-
0.949771
,
-
0.169276
,
0.36552
,
-
0.14801
,
2.07061
};
auto
l2
=
mm
->
add_literal
(
s
,
rand
);
mm
->
add_parameter
(
"x"
,
s
);
auto
y
=
mm
->
add_parameter
(
"y"
,
s
);
auto
re
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"mul"
),
y
,
l2
);
mm
->
add_return
({
re
});
auto
prog
=
migraphx
::
parse_onnx
(
"if_else_test_inlined.onnx"
);
EXPECT
(
p
==
prog
);
}
test/onnx/parse/if_literal_test.cpp
0 → 100644
View file @
93c89587
#include <onnx_test.hpp>
TEST_CASE
(
if_literal_test
)
{
migraphx
::
program
p
;
auto
*
mm
=
p
.
get_main_module
();
migraphx
::
shape
cond_s
{
migraphx
::
shape
::
bool_type
};
auto
cond
=
mm
->
add_parameter
(
"cond"
,
cond_s
);
migraphx
::
shape
s
{
migraphx
::
shape
::
float_type
,
{
5
}};
auto
*
then_mod
=
p
.
create_module
(
"If_1_if"
);
std
::
vector
<
float
>
data1
=
{
1
,
2
,
3
,
4
,
5
};
auto
l1
=
then_mod
->
add_literal
(
migraphx
::
literal
(
s
,
data1
));
then_mod
->
add_literal
({});
then_mod
->
add_return
({
l1
});
auto
*
else_mod
=
p
.
create_module
(
"If_1_else"
);
std
::
vector
<
float
>
data2
=
{
5
,
4
,
3
,
2
,
1
};
auto
l2
=
else_mod
->
add_literal
(
migraphx
::
literal
(
s
,
data2
));
else_mod
->
add_literal
({});
else_mod
->
add_return
({
l2
});
auto
ret
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"if"
),
{
cond
},
{
then_mod
,
else_mod
});
auto
r
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"get_tuple_elem"
,
{{
"index"
,
0
}}),
ret
);
mm
->
add_return
({
r
});
auto
prog
=
migraphx
::
parse_onnx
(
"if_literal_test.onnx"
);
EXPECT
(
p
==
prog
);
}
test/onnx/parse/if_param_excp1_test.cpp
0 → 100644
View file @
93c89587
#include <onnx_test.hpp>
TEST_CASE
(
if_param_excp1_test
)
{
EXPECT
(
test
::
throws
([
&
]
{
migraphx
::
parse_onnx
(
"if_param_excp1_test.onnx"
);
}));
}
test/onnx/parse/if_param_excp_test.cpp
0 → 100644
View file @
93c89587
#include <onnx_test.hpp>
TEST_CASE
(
if_param_excp_test
)
{
EXPECT
(
test
::
throws
([
&
]
{
migraphx
::
parse_onnx
(
"if_param_excp_test.onnx"
);
}));
}
test/onnx/parse/if_param_test.cpp
0 → 100644
View file @
93c89587
#include <onnx_test.hpp>
TEST_CASE
(
if_param_test
)
{
migraphx
::
program
p
;
auto
*
mm
=
p
.
get_main_module
();
migraphx
::
shape
cond_s
{
migraphx
::
shape
::
bool_type
};
auto
cond
=
mm
->
add_parameter
(
"cond"
,
cond_s
);
migraphx
::
shape
ds
{
migraphx
::
shape
::
float_type
,
{
2
,
3
}};
auto
x
=
mm
->
add_parameter
(
"x"
,
ds
);
auto
y
=
mm
->
add_parameter
(
"y"
,
ds
);
auto
*
then_mod
=
p
.
create_module
(
"If_3_if"
);
std
::
vector
<
float
>
data1
=
{
0.384804
,
-
1.77948
,
-
0.453775
,
0.477438
,
-
1.06333
,
-
1.12893
};
auto
l1
=
then_mod
->
add_literal
(
migraphx
::
literal
(
ds
,
data1
));
auto
a1
=
then_mod
->
add_instruction
(
migraphx
::
make_op
(
"add"
),
x
,
l1
);
then_mod
->
add_return
({
a1
});
auto
*
else_mod
=
p
.
create_module
(
"If_3_else"
);
std
::
vector
<
float
>
data2
=
{
-
0.258047
,
0.360394
,
0.536804
,
-
0.577762
,
1.0217
,
1.02442
};
auto
l2
=
else_mod
->
add_literal
(
migraphx
::
literal
(
ds
,
data2
));
auto
a2
=
else_mod
->
add_instruction
(
migraphx
::
make_op
(
"mul"
),
y
,
l2
);
else_mod
->
add_return
({
a2
});
auto
ret
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"if"
),
{
cond
},
{
then_mod
,
else_mod
});
auto
r
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"get_tuple_elem"
,
{{
"index"
,
0
}}),
ret
);
mm
->
add_return
({
r
});
auto
prog
=
migraphx
::
parse_onnx
(
"if_param_test.onnx"
);
EXPECT
(
p
==
prog
);
}
test/onnx/parse/if_pl_test.cpp
0 → 100644
View file @
93c89587
#include <onnx_test.hpp>
TEST_CASE
(
if_pl_test
)
{
migraphx
::
program
p
;
auto
*
mm
=
p
.
get_main_module
();
migraphx
::
shape
cond_s
{
migraphx
::
shape
::
bool_type
};
migraphx
::
shape
xs
{
migraphx
::
shape
::
float_type
,
{
2
,
3
}};
migraphx
::
shape
ys
{
migraphx
::
shape
::
float_type
,
{
3
,
3
}};
std
::
vector
<
float
>
datax
=
{
1
,
2
,
3
,
4
,
5
,
6
};
std
::
vector
<
float
>
datay
=
{
8
,
7
,
6
,
5
,
4
,
3
,
2
,
1
,
0
};
auto
lx
=
mm
->
add_literal
(
migraphx
::
literal
(
xs
,
datax
));
auto
ly
=
mm
->
add_literal
(
migraphx
::
literal
(
ys
,
datay
));
auto
cond
=
mm
->
add_parameter
(
"cond"
,
cond_s
);
auto
x
=
mm
->
add_parameter
(
"x"
,
xs
);
auto
y
=
mm
->
add_parameter
(
"y"
,
ys
);
auto
*
then_mod
=
p
.
create_module
(
"If_5_if"
);
auto
l1
=
then_mod
->
add_literal
(
migraphx
::
literal
(
ys
,
datay
));
auto
a1
=
then_mod
->
add_instruction
(
migraphx
::
make_op
(
"add"
),
x
,
lx
);
then_mod
->
add_return
({
a1
,
l1
});
auto
*
else_mod
=
p
.
create_module
(
"If_5_else"
);
auto
l2
=
else_mod
->
add_literal
(
migraphx
::
literal
(
xs
,
datax
));
auto
a2
=
else_mod
->
add_instruction
(
migraphx
::
make_op
(
"mul"
),
y
,
ly
);
else_mod
->
add_return
({
l2
,
a2
});
auto
ret
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"if"
),
{
cond
},
{
then_mod
,
else_mod
});
auto
r
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"get_tuple_elem"
,
{{
"index"
,
0
}}),
ret
);
mm
->
add_instruction
(
migraphx
::
make_op
(
"get_tuple_elem"
,
{{
"index"
,
1
}}),
ret
);
mm
->
add_return
({
r
});
auto
prog
=
migraphx
::
parse_onnx
(
"if_pl_test.onnx"
);
EXPECT
(
p
==
prog
);
}
test/onnx/parse/if_then_else_multi_output_shapes_inlined_test.cpp
0 → 100644
View file @
93c89587
#include <onnx_test.hpp>
TEST_CASE
(
if_then_else_multi_output_shapes_inlined_test
)
{
migraphx
::
program
p
;
auto
*
mm
=
p
.
get_main_module
();
migraphx
::
shape
sc
{
migraphx
::
shape
::
bool_type
,
{
1
}};
mm
->
add_literal
(
migraphx
::
literal
(
sc
,
{
1
}));
migraphx
::
shape
s
{
migraphx
::
shape
::
float_type
,
{
2
,
3
}};
migraphx
::
shape
s_trail
{
migraphx
::
shape
::
float_type
,
{
2
,
3
,
1
}};
std
::
vector
<
float
>
ones
(
s
.
elements
(),
1.0
f
);
auto
l1
=
mm
->
add_literal
(
s_trail
,
ones
);
std
::
vector
<
float
>
rand
=
{
-
1.01837
,
-
0.305541
,
-
0.254105
,
0.892955
,
1.38714
,
-
0.584205
};
mm
->
add_literal
(
s
,
rand
);
auto
x
=
mm
->
add_parameter
(
"x"
,
s_trail
);
mm
->
add_parameter
(
"y"
,
s
);
auto
rt
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"add"
),
x
,
l1
);
auto
rt2
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"add"
),
x
,
x
);
mm
->
add_return
({
rt
,
rt2
});
auto
prog
=
migraphx
::
parse_onnx
(
"if_then_else_multi_output_shapes_inlined_test.onnx"
);
EXPECT
(
p
==
prog
);
}
test/onnx/parse/if_then_else_multi_output_shapes_test.cpp
0 → 100644
View file @
93c89587
#include <onnx_test.hpp>
TEST_CASE
(
if_then_else_multi_output_shapes_test
)
{
migraphx
::
program
p
;
auto
*
mm
=
p
.
get_main_module
();
migraphx
::
shape
sc
{
migraphx
::
shape
::
bool_type
,
{
1
}};
migraphx
::
shape
s
{
migraphx
::
shape
::
float_type
,
{
2
,
3
,
1
}};
migraphx
::
shape
s_trail
{
migraphx
::
shape
::
float_type
,
{
2
,
3
,
1
}};
std
::
vector
<
float
>
ones
(
s
.
elements
(),
1.0
f
);
auto
l1
=
mm
->
add_literal
(
s_trail
,
ones
);
std
::
vector
<
float
>
rand
=
{
-
0.753997
,
0.707831
,
-
0.865795
,
2.49574
,
0.464937
,
-
0.168745
};
auto
l2
=
mm
->
add_literal
(
s
,
rand
);
auto
x
=
mm
->
add_parameter
(
"x"
,
s_trail
);
auto
y
=
mm
->
add_parameter
(
"y"
,
s
);
auto
cond
=
mm
->
add_parameter
(
"cond"
,
sc
);
auto
*
then_mod
=
p
.
create_module
(
"If_5_if"
);
auto
rt
=
then_mod
->
add_instruction
(
migraphx
::
make_op
(
"add"
),
x
,
l1
);
auto
rt2
=
then_mod
->
add_instruction
(
migraphx
::
make_op
(
"add"
),
x
,
x
);
then_mod
->
add_return
({
rt
,
rt2
});
auto
*
else_mod
=
p
.
create_module
(
"If_5_else"
);
auto
re
=
else_mod
->
add_instruction
(
migraphx
::
make_op
(
"mul"
),
y
,
l2
);
auto
re2
=
else_mod
->
add_instruction
(
migraphx
::
make_op
(
"sub"
),
y
,
l2
);
else_mod
->
add_return
({
re
,
re2
});
auto
ret
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"if"
),
{
cond
},
{
then_mod
,
else_mod
});
auto
r1
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"get_tuple_elem"
,
{{
"index"
,
0
}}),
ret
);
auto
r2
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"get_tuple_elem"
,
{{
"index"
,
1
}}),
ret
);
mm
->
add_return
({
r1
,
r2
});
auto
prog
=
migraphx
::
parse_onnx
(
"if_then_else_multi_output_shapes_test.onnx"
);
EXPECT
(
p
==
prog
);
}
test/onnx/parse/if_then_test.cpp
0 → 100644
View file @
93c89587
#include <onnx_test.hpp>
TEST_CASE
(
if_then_test
)
{
migraphx
::
program
p
;
auto
*
mm
=
p
.
get_main_module
();
migraphx
::
shape
sc
{
migraphx
::
shape
::
bool_type
,
{
1
}};
migraphx
::
shape
s
{
migraphx
::
shape
::
float_type
,
{
2
,
3
}};
std
::
vector
<
float
>
ones
(
s
.
elements
(),
1.0
f
);
std
::
vector
<
float
>
rand
=
{
-
0.266913
,
-
0.180328
,
-
0.124268
,
-
1.23768
,
0.312334
,
1.18475
};
auto
l1
=
mm
->
add_literal
(
s
,
ones
);
auto
l2
=
mm
->
add_literal
(
s
,
rand
);
auto
x
=
mm
->
add_parameter
(
"x"
,
s
);
auto
y
=
mm
->
add_parameter
(
"y"
,
s
);
auto
cond
=
mm
->
add_parameter
(
"cond"
,
sc
);
auto
*
then_mod
=
p
.
create_module
(
"If_5_if"
);
auto
rt
=
then_mod
->
add_instruction
(
migraphx
::
make_op
(
"add"
),
x
,
l1
);
then_mod
->
add_return
({
rt
});
auto
*
else_mod
=
p
.
create_module
(
"If_5_else"
);
auto
re
=
else_mod
->
add_instruction
(
migraphx
::
make_op
(
"mul"
),
y
,
l2
);
else_mod
->
add_return
({
re
});
auto
ret
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"if"
),
{
cond
},
{
then_mod
,
else_mod
});
auto
r
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"get_tuple_elem"
,
{{
"index"
,
0
}}),
ret
);
mm
->
add_return
({
r
});
auto
prog
=
migraphx
::
parse_onnx
(
"if_then_test.onnx"
);
EXPECT
(
p
==
prog
);
}
test/onnx/parse/if_then_test_inlined.cpp
0 → 100644
View file @
93c89587
#include <onnx_test.hpp>
TEST_CASE
(
if_then_test_inlined
)
{
migraphx
::
program
p
;
auto
*
mm
=
p
.
get_main_module
();
migraphx
::
shape
sc
{
migraphx
::
shape
::
bool_type
,
{
1
}};
mm
->
add_literal
(
migraphx
::
literal
(
sc
,
{
1
}));
migraphx
::
shape
s
{
migraphx
::
shape
::
float_type
,
{
2
,
3
}};
std
::
vector
<
float
>
ones
(
s
.
elements
(),
1.0
f
);
auto
l1
=
mm
->
add_literal
(
s
,
ones
);
std
::
vector
<
float
>
rand
=
{
-
1.26487
,
-
2.42279
,
0.990835
,
1.63072
,
0.812238
,
-
0.174946
};
mm
->
add_literal
(
s
,
rand
);
auto
x
=
mm
->
add_parameter
(
"x"
,
s
);
mm
->
add_parameter
(
"y"
,
s
);
auto
rt
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"add"
),
x
,
l1
);
mm
->
add_return
({
rt
});
auto
prog
=
migraphx
::
parse_onnx
(
"if_then_test_inlined.onnx"
);
EXPECT
(
p
==
prog
);
}
test/onnx/parse/if_tuple_test.cpp
0 → 100644
View file @
93c89587
#include <onnx_test.hpp>
TEST_CASE
(
if_tuple_test
)
{
migraphx
::
program
p
;
auto
*
mm
=
p
.
get_main_module
();
migraphx
::
shape
sd
{
migraphx
::
shape
::
float_type
,
{
1
}};
auto
l1
=
mm
->
add_literal
(
migraphx
::
literal
(
sd
,
{
1
}));
auto
l2
=
mm
->
add_literal
(
migraphx
::
literal
(
sd
,
{
2
}));
auto
l3
=
mm
->
add_literal
(
migraphx
::
literal
(
sd
,
{
3
}));
migraphx
::
shape
sx
{
migraphx
::
shape
::
float_type
,
{
1
,
4
}};
migraphx
::
shape
sy
{
migraphx
::
shape
::
float_type
,
{
3
,
4
}};
migraphx
::
shape
sc
{
migraphx
::
shape
::
bool_type
};
auto
cond
=
mm
->
add_parameter
(
"cond"
,
sc
);
auto
x
=
mm
->
add_parameter
(
"x"
,
sx
);
auto
y
=
mm
->
add_parameter
(
"y"
,
sy
);
auto
*
then_mod
=
p
.
create_module
(
"If_6_if"
);
auto
m1
=
then_mod
->
add_instruction
(
migraphx
::
make_op
(
"multibroadcast"
,
{{
"out_lens"
,
{
1
,
4
}}}),
l1
);
auto
add0
=
then_mod
->
add_instruction
(
migraphx
::
make_op
(
"add"
),
x
,
m1
);
auto
m2
=
then_mod
->
add_instruction
(
migraphx
::
make_op
(
"multibroadcast"
,
{{
"out_lens"
,
{
3
,
4
}}}),
l2
);
auto
mul0
=
then_mod
->
add_instruction
(
migraphx
::
make_op
(
"mul"
),
y
,
m2
);
then_mod
->
add_return
({
add0
,
mul0
});
auto
*
else_mod
=
p
.
create_module
(
"If_6_else"
);
auto
me1
=
else_mod
->
add_instruction
(
migraphx
::
make_op
(
"multibroadcast"
,
{{
"out_lens"
,
{
1
,
4
}}}),
l3
);
auto
mul1
=
else_mod
->
add_instruction
(
migraphx
::
make_op
(
"mul"
),
x
,
me1
);
auto
me2
=
else_mod
->
add_instruction
(
migraphx
::
make_op
(
"multibroadcast"
,
{{
"out_lens"
,
{
3
,
4
}}}),
l3
);
auto
add1
=
else_mod
->
add_instruction
(
migraphx
::
make_op
(
"add"
),
y
,
me2
);
else_mod
->
add_return
({
mul1
,
add1
});
auto
ret
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"if"
),
{
cond
},
{
then_mod
,
else_mod
});
auto
r0
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"get_tuple_elem"
,
{{
"index"
,
0
}}),
ret
);
auto
r1
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"get_tuple_elem"
,
{{
"index"
,
1
}}),
ret
);
mm
->
add_return
({
r0
,
r1
});
auto
prog
=
migraphx
::
parse_onnx
(
"if_tuple_test.onnx"
);
EXPECT
(
p
==
prog
);
}
test/onnx/parse/imagescaler_half_test.cpp
0 → 100644
View file @
93c89587
#include <onnx_test.hpp>
TEST_CASE
(
imagescaler_half_test
)
{
migraphx
::
program
p
;
auto
*
mm
=
p
.
get_main_module
();
migraphx
::
shape
s
{
migraphx
::
shape
::
half_type
,
{
1
,
3
,
16
,
16
}};
auto
l0
=
mm
->
add_parameter
(
"0"
,
s
);
auto
scale_val
=
mm
->
add_literal
(
migraphx
::
literal
{
migraphx
::
shape
{
migraphx
::
shape
::
half_type
},
{
0.5
f
}});
auto
bias_vals
=
mm
->
add_literal
(
migraphx
::
literal
{
migraphx
::
shape
{
migraphx
::
shape
::
half_type
,
{
3
}},
{
0.01
,
0.02
,
0.03
}});
auto
scaled_tensor
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"scalar"
,
{{
"scalar_bcst_dims"
,
s
.
lens
()}}),
scale_val
);
auto
img_scaled
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"mul"
),
l0
,
scaled_tensor
);
auto
bias_bcast
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"broadcast"
,
{{
"axis"
,
1
},
{
"out_lens"
,
s
.
lens
()}}),
bias_vals
);
mm
->
add_instruction
(
migraphx
::
make_op
(
"add"
),
img_scaled
,
bias_bcast
);
auto
prog
=
optimize_onnx
(
"imagescaler_half_test.onnx"
);
EXPECT
(
p
==
prog
);
}
test/onnx/parse/imagescaler_test.cpp
0 → 100644
View file @
93c89587
#include <onnx_test.hpp>
TEST_CASE
(
imagescaler_test
)
{
migraphx
::
program
p
;
auto
*
mm
=
p
.
get_main_module
();
migraphx
::
shape
s
{
migraphx
::
shape
::
float_type
,
{
1
,
3
,
16
,
16
}};
auto
l0
=
mm
->
add_parameter
(
"0"
,
s
);
auto
scale_val
=
mm
->
add_literal
(
0.5
f
);
auto
bias_vals
=
mm
->
add_literal
(
migraphx
::
literal
{
migraphx
::
shape
{
migraphx
::
shape
::
float_type
,
{
3
}},
{
0.01
,
0.02
,
0.03
}});
auto
scaled_tensor
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"scalar"
,
{{
"scalar_bcst_dims"
,
s
.
lens
()}}),
scale_val
);
auto
img_scaled
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"mul"
),
l0
,
scaled_tensor
);
auto
bias_bcast
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"broadcast"
,
{{
"axis"
,
1
},
{
"out_lens"
,
s
.
lens
()}}),
bias_vals
);
mm
->
add_instruction
(
migraphx
::
make_op
(
"add"
),
img_scaled
,
bias_bcast
);
auto
prog
=
optimize_onnx
(
"imagescaler_test.onnx"
);
EXPECT
(
p
==
prog
);
}
Prev
1
…
6
7
8
9
10
11
12
13
14
…
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