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
2afa47f1
Commit
2afa47f1
authored
Jul 12, 2018
by
Paul
Browse files
Add test for literals
parent
0a9d6a09
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
35 additions
and
3 deletions
+35
-3
src/generate.cpp
src/generate.cpp
+13
-2
src/include/migraph/generate.hpp
src/include/migraph/generate.hpp
+4
-1
test/miopen/miopen.cpp
test/miopen/miopen.cpp
+18
-0
No files found.
src/generate.cpp
View file @
2afa47f1
...
@@ -2,9 +2,9 @@
...
@@ -2,9 +2,9 @@
namespace
migraph
{
namespace
migraph
{
migraph
::
argument
generate_argument
(
migraph
::
shape
s
,
std
::
mt19937
::
result_type
seed
)
argument
generate_argument
(
shape
s
,
std
::
mt19937
::
result_type
seed
)
{
{
migraph
::
argument
result
;
argument
result
;
s
.
visit_type
([
&
](
auto
as
)
{
s
.
visit_type
([
&
](
auto
as
)
{
using
type
=
typename
decltype
(
as
)
::
type
;
using
type
=
typename
decltype
(
as
)
::
type
;
auto
v
=
generate_tensor_data
<
type
>
(
s
,
seed
);
auto
v
=
generate_tensor_data
<
type
>
(
s
,
seed
);
...
@@ -13,4 +13,15 @@ migraph::argument generate_argument(migraph::shape s, std::mt19937::result_type
...
@@ -13,4 +13,15 @@ migraph::argument generate_argument(migraph::shape s, std::mt19937::result_type
return
result
;
return
result
;
}
}
literal
generate_literal
(
shape
s
,
std
::
mt19937
::
result_type
seed
)
{
literal
result
;
s
.
visit_type
([
&
](
auto
as
)
{
using
type
=
typename
decltype
(
as
)
::
type
;
auto
v
=
generate_tensor_data
<
type
>
(
s
,
seed
);
result
=
{
s
,
v
};
});
return
result
;
}
}
// namespace migraph
}
// namespace migraph
src/include/migraph/generate.hpp
View file @
2afa47f1
...
@@ -2,6 +2,7 @@
...
@@ -2,6 +2,7 @@
#define MIGRAPH_GUARD_MIGRAPHLIB_GENERATE_HPP
#define MIGRAPH_GUARD_MIGRAPHLIB_GENERATE_HPP
#include <migraph/argument.hpp>
#include <migraph/argument.hpp>
#include <migraph/literal.hpp>
#include <random>
#include <random>
namespace
migraph
{
namespace
migraph
{
...
@@ -16,7 +17,9 @@ std::vector<T> generate_tensor_data(migraph::shape s, std::mt19937::result_type
...
@@ -16,7 +17,9 @@ std::vector<T> generate_tensor_data(migraph::shape s, std::mt19937::result_type
return
result
;
return
result
;
}
}
migraph
::
argument
generate_argument
(
migraph
::
shape
s
,
std
::
mt19937
::
result_type
seed
=
0
);
argument
generate_argument
(
shape
s
,
std
::
mt19937
::
result_type
seed
=
0
);
literal
generate_literal
(
shape
s
,
std
::
mt19937
::
result_type
seed
=
0
);
}
// namespace migraph
}
// namespace migraph
...
...
test/miopen/miopen.cpp
View file @
2afa47f1
...
@@ -49,6 +49,24 @@ void verify_program()
...
@@ -49,6 +49,24 @@ void verify_program()
visit_all
(
cpu_arg
,
gpu_arg
)([](
auto
cpu
,
auto
gpu
)
{
EXPECT
(
test
::
verify_range
(
cpu
,
gpu
));
});
visit_all
(
cpu_arg
,
gpu_arg
)([](
auto
cpu
,
auto
gpu
)
{
EXPECT
(
test
::
verify_range
(
cpu
,
gpu
));
});
}
}
struct
test_literals
{
migraph
::
program
create_program
()
const
{
migraph
::
program
p
;
auto
input
=
p
.
add_literal
(
generate_literal
(
migraph
::
shape
{
migraph
::
shape
::
float_type
,
{
4
,
3
,
3
,
3
}}));
auto
weights
=
p
.
add_literal
(
generate_literal
(
migraph
::
shape
{
migraph
::
shape
::
float_type
,
{
4
,
3
,
3
,
3
}}));
auto
conv
=
p
.
add_instruction
(
migraph
::
convolution
{},
input
,
weights
);
p
.
add_instruction
(
migraph
::
activation
{
"relu"
},
conv
);
return
p
;
}
migraph
::
program
::
parameter_map
create_params
()
const
{
return
{};
}
};
struct
test_add
struct
test_add
{
{
migraph
::
program
create_program
()
const
migraph
::
program
create_program
()
const
...
...
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