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
e1bc2da9
Commit
e1bc2da9
authored
Nov 01, 2018
by
Khalique
Browse files
added error msg for missing params
parent
ca15d48a
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
22 additions
and
3 deletions
+22
-3
src/program.cpp
src/program.cpp
+5
-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 @
e1bc2da9
...
@@ -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,10 @@ argument generic_eval(const program& p,
...
@@ -329,8 +330,10 @@ 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 @
e1bc2da9
...
@@ -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"
));
}
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 @
e1bc2da9
...
@@ -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