Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support MatMul operator when loading onnx #17

Closed

Conversation

kindsenior
Copy link

Nice to send you a Pull Request.
I'm Kunio Kojima at the University of Tokyo and a beginner of nngen.

When we loaded a network from an onnx file like nngen.from_onnx(filename),
we got the follow.

/usr/local/lib/python3.7/dist-packages/nngen-1.3.0-py3.7.egg/nngen/onnx/init.py in _get_func(op_type)
def _get_func(op_type)
--->return func_map[op_type]
KeyError: 'Mat'

It seems that nngen supports MatMul (nngen.operator.matmul).
However, it does not support loading MatMul operator from onnx file.

func_map = {
'Add': basic.Add,
'Sub': basic.Sub,
'Mul': basic.Mul,
'Div': basic.Div,
'Exp': exp.Exp,
'ReduceSum': reduce.ReduceSum,
'ReduceMax': reduce.ReduceMax,
'ReduceMin': reduce.ReduceMin,
'ArgMax': reduce.ArgMax,
'ArgMin': reduce.ArgMin,
'Conv': conv.Conv,
'Gemm': gemm.Gemm,
'AveragePool': pool.AveragePool,
'GlobalAveragePool': pool.GlobalAveragePool,
'MaxPool': pool.MaxPool,
'Pad': pad.Pad,
'Relu': act_func.Relu,
'LeakyRelu': act_func.LeakyRelu,
'Sigmoid': act_func.Sigmoid,
'BatchNormalization': batchnormalization.BatchNormalization,
'Shape': shape.Shape,
'Reshape': reshape.Reshape,
'Flatten': flatten.Flatten,
'Upsample': upsample.Upsample,
'Transpose': transpose.Transpose,
'Concat': concat.Concat,
'Squeeze': squeeze.Squeeze,
'Unsqueeze': squeeze.Unsqueeze,
'Gather': gather.Gather,
'Slice': slice_.Slice,
'Cast': cast.Cast,
'Ceil': ceil.Ceil,
'Floor': floor.Floor,
'Identity': identity.Identity,
}

Therefore, we added a mapping from onnx's MatMul to nngen.operator.matmul.

@kindsenior
Copy link
Author

Sorry.
I have misunderstood the operator.basic.
I understand it is the operator for element-wise procedures.
Therefore, my implementation is wrong.

@kindsenior kindsenior closed this Jun 5, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants