Skip to content
Snippets Groups Projects
Commit df97d44b authored by auphelia's avatar auphelia
Browse files

[Transformation] Integrate util function into prepare rtlsim trafo

parent e15e8afa
No related branches found
No related tags found
No related merge requests found
...@@ -27,7 +27,8 @@ ...@@ -27,7 +27,8 @@
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
import finn.custom_op.registry as registry import finn.custom_op.registry as registry
import finn.util.basic as util from finn.util.fpgadataflow import is_fpgadataflow_node
from finn.transformation import NodeLocalTransformation from finn.transformation import NodeLocalTransformation
try: try:
...@@ -55,22 +56,18 @@ class PrepareRTLSim(NodeLocalTransformation): ...@@ -55,22 +56,18 @@ class PrepareRTLSim(NodeLocalTransformation):
def applyNodeLocal(self, node): def applyNodeLocal(self, node):
op_type = node.op_type op_type = node.op_type
if node.domain == "finn": if is_fpgadataflow_node(node) is True:
backend_attribute = util.get_by_name(node.attribute, "backend") try:
if backend_attribute is not None: # lookup op_type in registry of CustomOps
backend_value = backend_attribute.s.decode("UTF-8") inst = registry.custom_op[op_type](node)
if backend_value == "fpgadataflow": inst.prepare_rtlsim()
try: # ensure that executable path is now set
# lookup op_type in registry of CustomOps assert (
inst = registry.custom_op[op_type](node) inst.get_nodeattr("rtlsim_so") != ""
inst.prepare_rtlsim() ), "Failed to prepare RTLSim, no rtlsim_so attribute found."
# ensure that executable path is now set except KeyError:
assert ( # exception if op_type is not supported
inst.get_nodeattr("rtlsim_so") != "" raise Exception(
), "Failed to prepare RTLSim, no rtlsim_so attribute found." "Custom op_type %s is currently not supported." % op_type
except KeyError: )
# exception if op_type is not supported
raise Exception(
"Custom op_type %s is currently not supported." % op_type
)
return (node, False) return (node, False)
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