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
3a2469f4
Commit
3a2469f4
authored
Aug 02, 2018
by
Scott Thornton
Browse files
added ONNX parser for batchnorm
parent
415476ae
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
32 additions
and
1 deletion
+32
-1
src/include/migraph/operators.hpp
src/include/migraph/operators.hpp
+4
-1
src/onnx/onnx.cpp
src/onnx/onnx.cpp
+28
-0
No files found.
src/include/migraph/operators.hpp
View file @
3a2469f4
...
@@ -105,7 +105,10 @@ struct not_computable
...
@@ -105,7 +105,10 @@ struct not_computable
struct
batch_norm_inference
struct
batch_norm_inference
{
{
double
epsilon
=
1.0e-6
;
float
epsilon
=
1.0e-6
f
;
float
momentum
=
0.9
f
;
bool
spatial
=
true
;
bool
is_test
=
false
;
std
::
string
name
()
const
{
return
"batch_norm_inference"
;
}
std
::
string
name
()
const
{
return
"batch_norm_inference"
;
}
...
...
src/onnx/onnx.cpp
View file @
3a2469f4
...
@@ -62,6 +62,7 @@ struct onnx_parser
...
@@ -62,6 +62,7 @@ struct onnx_parser
add_mem_op
(
"Conv"
,
&
onnx_parser
::
parse_conv
);
add_mem_op
(
"Conv"
,
&
onnx_parser
::
parse_conv
);
add_mem_op
(
"MaxPool"
,
&
onnx_parser
::
parse_pooling
);
add_mem_op
(
"MaxPool"
,
&
onnx_parser
::
parse_pooling
);
add_mem_op
(
"Reshape"
,
&
onnx_parser
::
parse_reshape
);
add_mem_op
(
"Reshape"
,
&
onnx_parser
::
parse_reshape
);
add_mem_op
(
"BatchNormalization"
,
&
onnx_parser
::
parse_batchnorm
);
}
}
template
<
class
F
>
template
<
class
F
>
...
@@ -167,6 +168,33 @@ struct onnx_parser
...
@@ -167,6 +168,33 @@ struct onnx_parser
return
prog
.
add_literal
(
v
);
return
prog
.
add_literal
(
v
);
}
}
instruction_ref
parse_batchnorm
(
std
::
string
,
attribute_map
attributes
,
std
::
vector
<
instruction_ref
>
args
)
{
float
epsilon
=
1e-5
f
;
float
momentum
=
0.9
f
;
bool
spatial
=
true
;
bool
is_test
=
false
;
if
(
contains
(
attributes
,
"epsilon"
))
{
epsilon
=
parse_value
(
attributes
.
at
(
"epsilon"
)).
at
<
float
>
();
}
if
(
contains
(
attributes
,
"momentum"
))
{
epsilon
=
parse_value
(
attributes
.
at
(
"momentum"
)).
at
<
float
>
();
}
if
(
contains
(
attributes
,
"is_test"
))
{
is_test
=
(
parse_value
(
attributes
.
at
(
"is_test"
)).
at
<
uint64_t
>
()
>
0
)
?
true
:
false
;
}
if
(
contains
(
attributes
,
"spatial"
))
{
spatial
=
(
parse_value
(
attributes
.
at
(
"spatial"
)).
at
<
uint64_t
>
()
>
0
)
?
true
:
false
;
}
batch_norm_inference
op
{
epsilon
,
momentum
,
spatial
,
is_test
};
return
prog
.
add_instruction
(
op
,
args
);
}
void
parse_from
(
std
::
istream
&
is
)
void
parse_from
(
std
::
istream
&
is
)
{
{
onnx
::
ModelProto
model
;
onnx
::
ModelProto
model
;
...
...
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