Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
gaoqiong
MIGraphX
Commits
71e1382d
Commit
71e1382d
authored
May 22, 2019
by
Paul
Browse files
Add test for replace op
parent
44194a24
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
45 additions
and
0 deletions
+45
-0
test/eval_test.cpp
test/eval_test.cpp
+25
-0
test/include/basic_ops.hpp
test/include/basic_ops.hpp
+20
-0
No files found.
test/eval_test.cpp
View file @
71e1382d
...
@@ -263,6 +263,31 @@ TEST_CASE(replace_ins_test2)
...
@@ -263,6 +263,31 @@ TEST_CASE(replace_ins_test2)
EXPECT
(
result
!=
migraphx
::
literal
{
3
});
EXPECT
(
result
!=
migraphx
::
literal
{
3
});
}
}
TEST_CASE
(
replace_op_test
)
{
migraphx
::
program
p
;
auto
one
=
p
.
add_literal
(
1
);
auto
two
=
p
.
add_literal
(
2
);
auto
sum
=
p
.
add_instruction
(
sum_op
{},
two
,
one
);
sum
->
replace
(
minus_op
{});
EXPECT
(
bool
{
p
.
validate
()
==
p
.
end
()});
auto
result
=
p
.
eval
({});
EXPECT
(
result
==
migraphx
::
literal
{
1
});
EXPECT
(
result
!=
migraphx
::
literal
{
3
});
}
TEST_CASE
(
replace_op_recompute_shape_throw
)
{
migraphx
::
program
p
;
auto
one
=
p
.
add_literal
(
1
);
auto
two
=
p
.
add_literal
(
2
);
auto
sum
=
p
.
add_instruction
(
sum_op
{},
one
,
two
);
EXPECT
(
test
::
throws
([
&
]
{
sum
->
replace
(
unary_pass_op
{});
}));
}
TEST_CASE
(
insert_replace_test
)
TEST_CASE
(
insert_replace_test
)
{
{
migraphx
::
program
p
;
migraphx
::
program
p
;
...
...
test/include/basic_ops.hpp
View file @
71e1382d
...
@@ -82,6 +82,26 @@ struct pass_op
...
@@ -82,6 +82,26 @@ struct pass_op
int
output_alias
(
const
std
::
vector
<
migraphx
::
shape
>&
)
const
{
return
0
;
}
int
output_alias
(
const
std
::
vector
<
migraphx
::
shape
>&
)
const
{
return
0
;
}
};
};
struct
unary_pass_op
{
std
::
string
name
()
const
{
return
"unary_pass"
;
}
migraphx
::
argument
compute
(
migraphx
::
context
&
,
const
migraphx
::
shape
&
,
std
::
vector
<
migraphx
::
argument
>
args
)
const
{
if
(
args
.
empty
())
return
{};
return
args
.
front
();
}
migraphx
::
shape
compute_shape
(
std
::
vector
<
migraphx
::
shape
>
inputs
)
const
{
if
(
inputs
.
size
()
!=
1
)
MIGRAPHX_THROW
(
"Wrong inputs"
);
return
inputs
.
front
();
}
int
output_alias
(
const
std
::
vector
<
migraphx
::
shape
>&
)
const
{
return
0
;
}
};
struct
pass_standard_op
struct
pass_standard_op
{
{
std
::
string
name
()
const
{
return
"pass"
;
}
std
::
string
name
()
const
{
return
"pass"
;
}
...
...
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