projects
/
platform
/
upstream
/
tvm.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
2cd5117
)
[ONNX] Skip ADD inside Gemm op when vector is zero (#5697)
author
Balint Cristian
<cristian.balint@gmail.com>
Sat, 30 May 2020 01:10:22 +0000
(
04:10
+0300)
committer
GitHub
<noreply@github.com>
Sat, 30 May 2020 01:10:22 +0000
(10:10 +0900)
python/tvm/relay/frontend/onnx.py
patch
|
blob
|
history
diff --git
a/python/tvm/relay/frontend/onnx.py
b/python/tvm/relay/frontend/onnx.py
index
ea1ac90
..
be88683
100644
(file)
--- a/
python/tvm/relay/frontend/onnx.py
+++ b/
python/tvm/relay/frontend/onnx.py
@@
-462,6
+462,10
@@
class Gemm(OnnxOpConverter):
inputs[0] = _op.nn.batch_flatten(inputs[0])
out = _op.nn.dense(_expr.const(alpha) * inputs[0],
inputs[1], units=channels)
+ # skip (beta * C) if zero
+ C_array = params[inputs[2].name_hint].asnumpy()
+ if (beta == 0.0) or np.array_equal(C_array, np.array([0])):
+ return out
return _op.nn.bias_add(out, _expr.const(beta) * inputs[2])