Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
H
hpvm-release
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
llvm
hpvm-release
Commits
c3ade693
Commit
c3ade693
authored
4 years ago
by
Yifan Zhao
Browse files
Options
Downloads
Patches
Plain Diff
Separate matmul and add nodes
parent
02bcd130
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
hpvm/projects/onnx/frontend/graph_builder.py
+15
-7
15 additions, 7 deletions
hpvm/projects/onnx/frontend/graph_builder.py
with
15 additions
and
7 deletions
hpvm/projects/onnx/frontend/graph_builder.py
+
15
−
7
View file @
c3ade693
...
...
@@ -107,10 +107,11 @@ class DFG(object):
defs
[
output
]
=
n
return
defs
,
uses
def
_allocate_var
(
self
):
def
_allocate_
insert_
var
(
self
,
node1
,
node2
,
input_pos
:
int
=
0
):
varname
=
f
"
conv_
{
self
.
_var_count
}
"
node1
.
output
=
[
varname
]
node2
.
input
[
input_pos
]
=
varname
self
.
_var_count
+=
1
return
varname
def
detect_flatten
(
self
,
graph
):
# Look for a shape-gather-unsqueeze-concat chain
...
...
@@ -203,17 +204,24 @@ class DFG(object):
return
[
g
.
Conv2DNode
(
onnx_node
)]
else
:
# Add an intermediate var between conv and add
interm_var
=
self
.
_allocate_var
()
conv_node
=
g
.
Conv2DNode
(
onnx_node
)
conv_node
.
output
=
[
interm_var
]
bias_node
=
g
.
BiasAddNode
(
onnx_node
)
bias_node
.
input
[
0
]
=
in
t
er
m
_var
self
.
_allocate_
in
s
er
t
_var
(
conv_node
,
bias_node
)
return
[
conv_node
,
bias_node
]
elif
onnx_node
.
op_type
in
(
"
MatMul
"
,
"
Gemm
"
):
weight_tensor
=
self
.
tensors
[
onnx_node
.
input
[
1
]]
assert
isinstance
(
weight_tensor
,
WeightTensor
)
if
len
(
onnx_node
.
input
)
==
2
:
return
[
g
.
MatMulNode
(
onnx_node
)]
else
:
# Add an intermediate var between matmul and add
mul_node
=
g
.
MatMulNode
(
onnx_node
)
bias_node
=
g
.
BiasAddNode
(
onnx_node
)
self
.
_allocate_insert_var
(
mul_node
,
bias_node
)
return
[
mul_node
,
bias_node
]
one_to_one_nodes
=
{
"
MaxPool
"
:
g
.
MaxPool2DNode
,
"
AveragePool
"
:
g
.
AveragePool2DNode
,
"
MatMul
"
:
g
.
MatMulNode
,
"
Gemm
"
:
g
.
MatMulNode
,
"
Add
"
:
g
.
AddNode
,
"
Softmax
"
:
g
.
SoftMaxNode
,
"
Relu
"
:
g
.
ReluNode
,
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment