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
bc2146b0
"git@developer.sourcefind.cn:gaoqiong/migraphx.git" did not exist on "7746373c1999b1a02da70addd0bf43e4bddb1baa"
Commit
bc2146b0
authored
Aug 12, 2018
by
Scott Thornton
Browse files
Added code to read initializer data from ONNX
parent
b9890d91
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
29 additions
and
7 deletions
+29
-7
src/include/migraph/operators.hpp
src/include/migraph/operators.hpp
+2
-2
src/include/migraph/shape.hpp
src/include/migraph/shape.hpp
+4
-2
src/onnx/CMakeLists.txt
src/onnx/CMakeLists.txt
+4
-0
src/onnx/onnx.cpp
src/onnx/onnx.cpp
+19
-3
No files found.
src/include/migraph/operators.hpp
View file @
bc2146b0
...
...
@@ -155,12 +155,12 @@ struct pooling
std
::
size_t
(
std
::
max
<
std
::
ptrdiff_t
>
(
1
,
std
::
ptrdiff_t
(
std
::
floor
((
input
.
lens
()[
2
]
+
2
*
padding
[
0
]
-
lengths
[
0
])
/
static_cast
<
float
>
(
stride
[
0
])))
+
static_cast
<
float
>
(
stride
[
0
])))
+
1
)),
std
::
size_t
(
std
::
max
<
std
::
ptrdiff_t
>
(
1
,
std
::
ptrdiff_t
(
std
::
floor
((
input
.
lens
()[
3
]
+
2
*
padding
[
1
]
-
lengths
[
1
])
/
static_cast
<
float
>
(
stride
[
1
])))
+
static_cast
<
float
>
(
stride
[
1
])))
+
1
)),
// std::size_t(std::max<std::ptrdiff_t>(
// 1,
...
...
src/include/migraph/shape.hpp
View file @
bc2146b0
...
...
@@ -80,11 +80,13 @@ struct shape
/// Returns true if the shape is packed with no padding
bool
packed
()
const
;
/// Returns true is the shape has been transposed. That is the strides are not in descending order
/// Returns true is the shape has been transposed. That is the strides are not in descending
/// order
bool
transposed
()
const
;
/// Returns true if the shape is broadcasting a dimension. That is, one of the strides are zero
bool
broadcasted
()
const
;
/// Returns true if the shape is in its standard format. That is, the shape is both packed and not transposed.
/// Returns true if the shape is in its standard format. That is, the shape is both packed and
/// not transposed.
bool
standard
()
const
;
friend
bool
operator
==
(
const
shape
&
x
,
const
shape
&
y
);
...
...
src/onnx/CMakeLists.txt
View file @
bc2146b0
...
...
@@ -20,6 +20,10 @@ add_executable(mnist mnist.cpp)
rocm_clang_tidy_check
(
mnist
)
target_link_libraries
(
mnist migraph_cpu migraph_onnx
)
add_executable
(
resnet18 resnet18.cpp
)
rocm_clang_tidy_check
(
resnet18
)
target_link_libraries
(
resnet18 migraph_cpu migraph_onnx
)
if
(
MIGRAPH_ENABLE_GPU
)
add_executable
(
verify_onnx verify_onnx.cpp
)
rocm_clang_tidy_check
(
verify_onnx
)
...
...
src/onnx/onnx.cpp
View file @
bc2146b0
...
...
@@ -285,12 +285,28 @@ struct onnx_parser
void
parse_graph
(
const
onnx
::
GraphProto
&
graph
)
{
nodes
=
get_nodes
(
graph
);
std
::
unordered_map
<
std
::
string
,
size_t
>
initializer_data
;
auto
cnt
=
0
;
for
(
auto
&&
f
:
graph
.
initializer
())
{
initializer_data
[
f
.
name
()]
=
cnt
++
;
}
for
(
auto
&&
input
:
graph
.
input
())
{
const
std
::
string
&
name
=
input
.
name
();
// TODO: Get shape of input parameter
shape
s
=
parse_type
(
input
.
type
());
instructions
[
name
]
=
prog
.
add_parameter
(
name
,
s
);
// Does the input have an initializer?
if
(
initializer_data
.
find
(
name
)
!=
initializer_data
.
end
())
{
auto
idx
=
initializer_data
[
name
];
auto
t
=
graph
.
initializer
()[
idx
];
instructions
[
name
]
=
prog
.
add_literal
(
parse_tensor
(
t
));
}
else
{
// TODO: Get shape of input parameter
shape
s
=
parse_type
(
input
.
type
());
instructions
[
name
]
=
prog
.
add_parameter
(
name
,
s
);
}
}
for
(
auto
&&
p
:
nodes
)
{
...
...
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