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
3e15b7a0
Commit
3e15b7a0
authored
Jan 06, 2019
by
Paul
Browse files
Add const eval test
parent
559cefca
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
80 additions
and
1 deletion
+80
-1
cppcheck.rules
cppcheck.rules
+1
-1
test/const_eval_test.cpp
test/const_eval_test.cpp
+79
-0
No files found.
cppcheck.rules
View file @
3e15b7a0
...
...
@@ -74,7 +74,7 @@
</message>
</rule>
<rule>
<pattern>
(fclose|free|hipFree|hipHostFree|hipFreeArray|hipMemFree|hipStreamDestroy|hipEventDestroy|hipArrayDestroy|hipCtxDestroy|hipDestroyTextureObject|hipDestroySurfaceObject) \(
</pattern>
<pattern>
\\W
(fclose|free|hipFree|hipHostFree|hipFreeArray|hipMemFree|hipStreamDestroy|hipEventDestroy|hipArrayDestroy|hipCtxDestroy|hipDestroyTextureObject|hipDestroySurfaceObject) \(
</pattern>
<message>
<id>
useManagePointer
</id>
<severity>
style
</severity>
...
...
test/const_eval_test.cpp
0 → 100644
View file @
3e15b7a0
#include <migraphx/program.hpp>
#include <migraphx/instruction.hpp>
#include <sstream>
#include "test.hpp"
#include <basic_ops.hpp>
struct
sum_cf_op
{
std
::
string
name
()
const
{
return
"sum_cf"
;
}
migraphx
::
argument
compute
(
const
migraphx
::
shape
&
,
std
::
vector
<
migraphx
::
argument
>
args
)
const
{
migraphx
::
argument
result
;
if
(
args
.
size
()
!=
2
)
MIGRAPHX_THROW
(
"Wrong args"
);
if
(
args
[
0
].
get_shape
()
!=
args
[
1
].
get_shape
())
MIGRAPHX_THROW
(
"Wrong args"
);
if
(
args
[
0
].
get_shape
().
lens
().
size
()
!=
1
)
MIGRAPHX_THROW
(
"Wrong args"
);
if
(
args
[
0
].
get_shape
().
lens
().
front
()
!=
1
)
MIGRAPHX_THROW
(
"Wrong args"
);
args
[
0
].
visit_at
([
&
](
auto
x
)
{
args
[
1
].
visit_at
([
&
](
auto
y
)
{
result
=
migraphx
::
literal
{
x
+
y
}.
get_argument
();
});
});
return
result
;
}
migraphx
::
shape
compute_shape
(
std
::
vector
<
migraphx
::
shape
>
inputs
)
const
{
if
(
inputs
.
size
()
!=
2
)
MIGRAPHX_THROW
(
"Wrong inputs"
);
return
inputs
.
front
();
}
};
TEST_CASE
(
literal_test
)
{
migraphx
::
program
p
;
auto
lit
=
p
.
add_literal
(
1
);
CHECK
(
lit
->
eval
()
==
migraphx
::
literal
{
1
});
}
TEST_CASE
(
param_test
)
{
migraphx
::
program
p
;
auto
lit
=
p
.
add_parameter
(
"param"
,
migraphx
::
shape
{
migraphx
::
shape
::
float_type
,
{
1
}});
CHECK
(
lit
->
eval
().
empty
());
}
TEST_CASE
(
op_test1
)
{
migraphx
::
program
p
;
auto
one
=
p
.
add_literal
(
1
);
auto
two
=
p
.
add_literal
(
2
);
auto
sum
=
p
.
add_instruction
(
sum_cf_op
{},
one
,
two
);
CHECK
(
sum
->
eval
()
==
migraphx
::
literal
{
3
});
}
TEST_CASE
(
op_test2
)
{
migraphx
::
program
p
;
auto
x
=
p
.
add_parameter
(
"param"
,
migraphx
::
shape
{
migraphx
::
shape
::
float_type
,
{
1
}});;
auto
two
=
p
.
add_literal
(
2
);
auto
sum
=
p
.
add_instruction
(
sum_cf_op
{},
x
,
two
);
CHECK
(
sum
->
eval
().
empty
());
}
TEST_CASE
(
op_test3
)
{
migraphx
::
program
p
;
auto
one
=
p
.
add_literal
(
1
);
auto
two
=
p
.
add_literal
(
2
);
auto
sum1
=
p
.
add_instruction
(
sum_op
{},
one
,
two
);
auto
sum2
=
p
.
add_instruction
(
sum_cf_op
{},
sum1
,
two
);
CHECK
(
sum2
->
eval
().
empty
());
}
int
main
(
int
argc
,
const
char
*
argv
[])
{
test
::
run
(
argc
,
argv
);
}
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