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
4debaf07
Unverified
Commit
4debaf07
authored
Nov 05, 2018
by
Paul Fultz II
Committed by
GitHub
Nov 05, 2018
Browse files
Merge pull request #103 from ROCmSoftwarePlatform/errormsg
added error msg for missing params
parents
9ca0fbf1
32e24988
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
23 additions
and
3 deletions
+23
-3
src/program.cpp
src/program.cpp
+6
-2
test/eval_test.cpp
test/eval_test.cpp
+16
-0
test/include/test.hpp
test/include/test.hpp
+1
-1
No files found.
src/program.cpp
View file @
4debaf07
...
@@ -2,6 +2,7 @@
...
@@ -2,6 +2,7 @@
#include <migraph/stringutils.hpp>
#include <migraph/stringutils.hpp>
#include <migraph/instruction.hpp>
#include <migraph/instruction.hpp>
#include <migraph/env.hpp>
#include <migraph/env.hpp>
#include <migraph/ranges.hpp>
#include <migraph/time.hpp>
#include <migraph/time.hpp>
#include <migraph/iterator_for.hpp>
#include <migraph/iterator_for.hpp>
#include <iostream>
#include <iostream>
...
@@ -329,8 +330,11 @@ argument generic_eval(const program& p,
...
@@ -329,8 +330,11 @@ argument generic_eval(const program& p,
else
if
(
ins
->
name
()
==
"@param"
)
else
if
(
ins
->
name
()
==
"@param"
)
{
{
results
.
emplace
(
ins
,
trace
(
ins
,
[
&
]
{
results
.
emplace
(
ins
,
trace
(
ins
,
[
&
]
{
return
params
.
at
(
auto
param_name
=
any_cast
<
builtin
::
param
>
(
ins
->
get_operator
()).
parameter
);
any_cast
<
builtin
::
param
>
(
ins
->
get_operator
()).
parameter
;
if
(
not
contains
(
params
,
param_name
))
MIGRAPH_THROW
(
"Parameter not found: "
+
param_name
);
return
params
.
at
(
param_name
);
}));
}));
}
}
else
if
(
ins
->
name
()
==
"@outline"
)
else
if
(
ins
->
name
()
==
"@outline"
)
...
...
test/eval_test.cpp
View file @
4debaf07
...
@@ -104,6 +104,21 @@ void param_test()
...
@@ -104,6 +104,21 @@ void param_test()
EXPECT
(
result
!=
migraph
::
literal
{
4
});
EXPECT
(
result
!=
migraph
::
literal
{
4
});
}
}
void
param_error_test
()
{
migraph
::
program
p
;
auto
x
=
p
.
add_parameter
(
"x"
,
{
migraph
::
shape
::
int64_type
});
auto
y
=
p
.
add_parameter
(
"y"
,
{
migraph
::
shape
::
int64_type
});
p
.
add_instruction
(
sum_op
{},
x
,
y
);
EXPECT
(
test
::
throws
<
migraph
::
exception
>
(
[
&
]
{
p
.
eval
({{
"x"
,
migraph
::
literal
{
1
}.
get_argument
()}});
},
"Parameter not found: y"
));
}
void
replace_test
()
void
replace_test
()
{
{
migraph
::
program
p
;
migraph
::
program
p
;
...
@@ -215,6 +230,7 @@ int main()
...
@@ -215,6 +230,7 @@ int main()
literal_test2
();
literal_test2
();
print_test
();
print_test
();
param_test
();
param_test
();
param_error_test
();
replace_test
();
replace_test
();
replace_ins_test
();
replace_ins_test
();
replace_ins_test2
();
replace_ins_test2
();
...
...
test/include/test.hpp
View file @
4debaf07
...
@@ -140,7 +140,7 @@ bool throws(F f)
...
@@ -140,7 +140,7 @@ bool throws(F f)
}
}
}
}
template
<
class
F
,
class
Exception
>
template
<
class
Exception
,
class
F
>
bool
throws
(
F
f
,
const
std
::
string
&
msg
=
""
)
bool
throws
(
F
f
,
const
std
::
string
&
msg
=
""
)
{
{
try
try
...
...
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