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

[Exec] use new custom op infra for exec'ing custom ops

parent dc8d8b7f
No related branches found
No related tags found
No related merge requests found
# import onnx.helper as helper
import finn.core.multithreshold as multiThresh
from finn.core.utils import get_by_name
import finn.custom_op.registry as registry
def execute_custom_node(node, context, graph):
"""Call custom implementation to execute a single custom node.
Input/output provided via context."""
if node.op_type == "MultiThreshold":
# save inputs
v = context[node.input[0]]
thresholds = context[node.input[1]]
# retrieve attributes if output scaling is used
try:
out_scale = get_by_name(node.attribute, "out_scale").f
except AttributeError:
out_scale = None
try:
out_bias = get_by_name(node.attribute, "out_bias").f
except AttributeError:
out_bias = None
# calculate output
output = multiThresh.execute(v, thresholds, out_scale, out_bias)
# setting context according to output
context[node.output[0]] = output
else:
op_type = node.op_type
try:
# lookup op_type in registry of CustomOps
inst = registry.custom_op[op_type]()
inst.execute_node(node, context, graph)
except KeyError:
# exception if op_type is not supported
raise Exception("This custom node is currently 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