Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
T
tic
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wenyuanbo
tic
Commits
a82656d4
Commit
a82656d4
authored
Apr 24, 2018
by
Pariksheet Pinjari
Committed by
Tianqi Chen
May 29, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Support imagescalar operator for onnx (#448)
parent
435201ee
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
2 deletions
+15
-2
nnvm/python/nnvm/frontend/onnx.py
+15
-2
No files found.
nnvm/python/nnvm/frontend/onnx.py
View file @
a82656d4
# pylint: disable=import-self, invalid-name, unused-argument
# pylint: disable=import-self, invalid-name, unused-argument
"""ONNX: Open Neural Network Exchange frontend."""
"""ONNX: Open Neural Network Exchange frontend."""
from
__future__
import
absolute_import
as
_abs
from
__future__
import
absolute_import
as
_abs
import
numpy
as
np
import
tvm
import
tvm
from
..
import
symbol
as
_sym
from
..
import
symbol
as
_sym
from
..
import
graph
as
_graph
from
..
import
graph
as
_graph
from
..compiler
import
graph_util
from
..compiler
import
graph_util
from
.common
import
get_nnvm_op
,
Renamer
,
AttrConverter
as
AttrCvt
from
.common
import
get_nnvm_op
,
Renamer
,
SymbolTable
,
AttrConverter
as
AttrCvt
__all__
=
[
'from_onnx'
]
__all__
=
[
'from_onnx'
]
...
@@ -322,6 +323,18 @@ class ThresholdedRelu(OnnxOpConverter):
...
@@ -322,6 +323,18 @@ class ThresholdedRelu(OnnxOpConverter):
return
_sym
.
relu
(
inputs
[
0
]
-
alpha
)
return
_sym
.
relu
(
inputs
[
0
]
-
alpha
)
class
ImageScaler
(
OnnxOpConverter
):
@classmethod
def
_impl_v1
(
cls
,
inputs
,
attr
,
params
):
channelScale
=
attr
[
'scale'
]
bias_attr
=
attr
[
'bias'
]
bias
=
SymbolTable
()
.
new_const
(
np
.
array
(
bias_attr
)
.
reshape
([
3
,
1
,
1
]))
scaledChannel
=
_sym
.
__mul_scalar__
(
inputs
[
0
],
scalar
=
channelScale
)
ret
=
_sym
.
broadcast_add
(
scaledChannel
,
bias
)
return
ret
def
_revert_caffe2_pad
(
attr
):
def
_revert_caffe2_pad
(
attr
):
"""Caffe2 require two times the normal padding."""
"""Caffe2 require two times the normal padding."""
if
len
(
attr
)
==
4
:
if
len
(
attr
)
==
4
:
...
@@ -410,7 +423,7 @@ def _get_convert_map(opset):
...
@@ -410,7 +423,7 @@ def _get_convert_map(opset):
'Scale'
:
Scale
.
get_converter
(
opset
),
'Scale'
:
Scale
.
get_converter
(
opset
),
# 'GRUUnit'
# 'GRUUnit'
# 'ATen'
# 'ATen'
# 'ImageScaler'
'ImageScaler'
:
ImageScaler
.
get_converter
(
opset
),
# 'MeanVarianceNormalization'
# 'MeanVarianceNormalization'
# 'Crop'
# 'Crop'
# 'Embedding'
# 'Embedding'
...
...
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