Skip to content
Snippets Groups Projects
Commit 8f0d40a7 authored by Yaman Umuroglu's avatar Yaman Umuroglu
Browse files

[CustomOp] add helper function to get custom op for onnx node

parent ce4d70c9
No related branches found
No related tags found
No related merge requests found
# make sure new CustomOp subclasses are imported here so that they get
# registered and plug in correctly into the infrastructure
from finn.custom_op.fpgadataflow.convolutioninputgenerator import (
ConvolutionInputGenerator
ConvolutionInputGenerator,
)
from finn.custom_op.fpgadataflow.streamingfclayer_batch import StreamingFCLayer_Batch
from finn.custom_op.fpgadataflow.streamingmaxpool_batch import StreamingMaxPool_Batch
......@@ -18,3 +18,15 @@ custom_op["StreamingMaxPool_Batch"] = StreamingMaxPool_Batch
custom_op["StreamingFCLayer_Batch"] = StreamingFCLayer_Batch
custom_op["ConvolutionInputGenerator"] = ConvolutionInputGenerator
custom_op["TLastMarker"] = TLastMarker
def getCustomOp(node):
"Return a FINN CustomOp instance for the given ONNX node, if it exists."
op_type = node.op_type
try:
# lookup op_type in registry of CustomOps
inst = custom_op[op_type](node)
return inst
except KeyError:
# exception if op_type is not supported
raise Exception("Custom op_type %s is currently not supported." % op_type)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment