Skip to content
Snippets Groups Projects
Commit cbdb3438 authored by Axel Farrugia's avatar Axel Farrugia
Browse files

[Chore] get_node -> get_node_from_metaop

parent 244a6b20
No related branches found
No related tags found
No related merge requests found
...@@ -2,7 +2,7 @@ import os ...@@ -2,7 +2,7 @@ import os
from collections import OrderedDict from collections import OrderedDict
import aidge_core import aidge_core
from aidge_core.export_utils import get_node from aidge_core.export_utils import get_node_from_metaop
def cpp_fuse_to_metaops(graph_view: aidge_core.GraphView): def cpp_fuse_to_metaops(graph_view: aidge_core.GraphView):
""" """
...@@ -198,7 +198,7 @@ def set_scaling_attributes(export_node: aidge_core.export_utils.ExportNode, node ...@@ -198,7 +198,7 @@ def set_scaling_attributes(export_node: aidge_core.export_utils.ExportNode, node
:type node: aidge_core.Node :type node: aidge_core.Node
""" """
QNode = get_node(node, "Quantizer") QNode = get_node_from_metaop(node, "Quantizer")
if QNode is not None: if QNode is not None:
for n in QNode.get_operator().get_micro_graph().get_nodes(): for n in QNode.get_operator().get_micro_graph().get_nodes():
......
import aidge_core import aidge_core
from aidge_core.export_utils import ExportNodeCpp, get_node from aidge_core.export_utils import ExportNodeCpp, get_node_from_metaop
from aidge_export_cpp import ROOT, ExportLibCpp, set_scaling_attributes from aidge_export_cpp import ROOT, ExportLibCpp, set_scaling_attributes
@ExportLibCpp.register("Conv2D", aidge_core.ImplSpec(aidge_core.IOSpec(aidge_core.dtype.any))) @ExportLibCpp.register("Conv2D", aidge_core.ImplSpec(aidge_core.IOSpec(aidge_core.dtype.any)))
...@@ -17,7 +17,7 @@ class Conv(ExportNodeCpp): ...@@ -17,7 +17,7 @@ class Conv(ExportNodeCpp):
self.attributes["shift_value"] = 0 self.attributes["shift_value"] = 0
# Browse the metaop to update kernel attributes # Browse the metaop to update kernel attributes
ConvNode = get_node(node, "Conv2D") ConvNode = get_node_from_metaop(node, "Conv2D")
self.attributes["kernel_dims"] = ConvNode.get_operator().attr.kernel_dims self.attributes["kernel_dims"] = ConvNode.get_operator().attr.kernel_dims
self.attributes["stride_dims"] = ConvNode.get_operator().attr.stride_dims self.attributes["stride_dims"] = ConvNode.get_operator().attr.stride_dims
self.attributes["dilation_dims"] = ConvNode.get_operator().attr.dilation_dims self.attributes["dilation_dims"] = ConvNode.get_operator().attr.dilation_dims
...@@ -60,7 +60,7 @@ class PadConv(QConv): ...@@ -60,7 +60,7 @@ class PadConv(QConv):
super().__init__(node, mem_info) super().__init__(node, mem_info)
# Browse the metaop to update kernel attributes # Browse the metaop to update kernel attributes
PadNode = get_node(node, "Pad2D") PadNode = get_node_from_metaop(node, "Pad2D")
self.attributes["padding"] = PadNode.get_operator().attr.begin_end_borders self.attributes["padding"] = PadNode.get_operator().attr.begin_end_borders
...@@ -70,9 +70,9 @@ class ConvAct(QConv): ...@@ -70,9 +70,9 @@ class ConvAct(QConv):
super().__init__(node, mem_info) super().__init__(node, mem_info)
# Browse the metaop to update kernel attributes # Browse the metaop to update kernel attributes
if get_node(node, "ReLU") is not None: if get_node_from_metaop(node, "ReLU") is not None:
self.attributes["activation"] = "Rectifier" self.attributes["activation"] = "Rectifier"
elif get_node(node, "LeakyReLU") is not None: elif get_node_from_metaop(node, "LeakyReLU") is not None:
aidge_core.Log.fatal(f"{node.type()} activation is not yet supported.") aidge_core.Log.fatal(f"{node.type()} activation is not yet supported.")
# TODO : Should not be checked manually for each activation # TODO : Should not be checked manually for each activation
......
import aidge_core import aidge_core
from aidge_core.export_utils import ExportNodeCpp, get_node from aidge_core.export_utils import ExportNodeCpp, get_node_from_metaop
from aidge_export_cpp import ROOT, ExportLibCpp, set_scaling_attributes from aidge_export_cpp import ROOT, ExportLibCpp, set_scaling_attributes
class ElemWise(ExportNodeCpp): class ElemWise(ExportNodeCpp):
...@@ -66,9 +66,9 @@ class AddAct(QAdd): ...@@ -66,9 +66,9 @@ class AddAct(QAdd):
super().__init__(node, mem_info) super().__init__(node, mem_info)
# Browse the metaop to update kernel attributes # Browse the metaop to update kernel attributes
if get_node(node, "ReLU") is not None: if get_node_from_metaop(node, "ReLU") is not None:
self.attributes["activation"] = "Rectifier" self.attributes["activation"] = "Rectifier"
elif get_node(node, "LeakyReLU") is not None: elif get_node_from_metaop(node, "LeakyReLU") is not None:
aidge_core.Log.fatal(f"{node.type()} activation is not yet supported.") aidge_core.Log.fatal(f"{node.type()} activation is not yet supported.")
# TODO : Should not be checked manually for each activation # TODO : Should not be checked manually for each activation
...@@ -92,9 +92,9 @@ class SubAct(QSub): ...@@ -92,9 +92,9 @@ class SubAct(QSub):
super().__init__(node, mem_info) super().__init__(node, mem_info)
# Browse the metaop to update kernel attributes # Browse the metaop to update kernel attributes
if get_node(node, "ReLU") is not None: if get_node_from_metaop(node, "ReLU") is not None:
self.attributes["activation"] = "Rectifier" self.attributes["activation"] = "Rectifier"
elif get_node(node, "LeakyReLU") is not None: elif get_node_from_metaop(node, "LeakyReLU") is not None:
aidge_core.Log.fatal(f"{node.type()} activation is not yet supported.") aidge_core.Log.fatal(f"{node.type()} activation is not yet supported.")
# TODO : Should not be checked manually for each activation # TODO : Should not be checked manually for each activation
...@@ -118,8 +118,8 @@ class MulAct(QMul): ...@@ -118,8 +118,8 @@ class MulAct(QMul):
super().__init__(node, mem_info) super().__init__(node, mem_info)
# Browse the metaop to update kernel attributes # Browse the metaop to update kernel attributes
if get_node(node, "ReLU") is not None: if get_node_from_metaop(node, "ReLU") is not None:
self.attributes["activation"] = "Rectifier" self.attributes["activation"] = "Rectifier"
elif get_node(node, "LeakyReLU") is not None: elif get_node_from_metaop(node, "LeakyReLU") is not None:
aidge_core.Log.fatal(f"{node.type()} activation is not yet supported.") aidge_core.Log.fatal(f"{node.type()} activation is not yet supported.")
# TODO : Should not be checked manually for each activation # TODO : Should not be checked manually for each activation
\ No newline at end of file
import aidge_core import aidge_core
from aidge_core.export_utils import ExportNodeCpp, get_node from aidge_core.export_utils import ExportNodeCpp, get_node_from_metaop
from aidge_export_cpp import ROOT from aidge_export_cpp import ROOT
from aidge_export_cpp import ExportLibCpp from aidge_export_cpp import ExportLibCpp
...@@ -37,7 +37,7 @@ class PadPool(Pool): ...@@ -37,7 +37,7 @@ class PadPool(Pool):
super().__init__(node, mem_info) super().__init__(node, mem_info)
# Browse the metaop to update kernel attributes # Browse the metaop to update kernel attributes
PadNode = get_node(node, "Pad2D") PadNode = get_node_from_metaop(node, "Pad2D")
self.attributes["padding"] = PadNode.get_operator().attr.begin_end_borders self.attributes["padding"] = PadNode.get_operator().attr.begin_end_borders
...@@ -46,9 +46,9 @@ class PoolAct(Pool): ...@@ -46,9 +46,9 @@ class PoolAct(Pool):
super().__init__(node, mem_info) super().__init__(node, mem_info)
# Browse the metaop to update kernel attributes # Browse the metaop to update kernel attributes
if get_node(node, "ReLU") is not None: if get_node_from_metaop(node, "ReLU") is not None:
self.attributes["activation"] = "Rectifier" self.attributes["activation"] = "Rectifier"
elif get_node(node, "LeakyReLU") is not None: elif get_node_from_metaop(node, "LeakyReLU") is not None:
aidge_core.Log.fatal(f"{node.type()} activation is not yet supported.") aidge_core.Log.fatal(f"{node.type()} activation is not yet supported.")
# TODO : Should not be checked manually for each activation # TODO : Should not be checked manually for each activation
...@@ -59,7 +59,7 @@ class MaxPool(Pool): ...@@ -59,7 +59,7 @@ class MaxPool(Pool):
super().__init__(node, mem_info) super().__init__(node, mem_info)
# Browse the metaop to update kernel attributes # Browse the metaop to update kernel attributes
PoolNode = get_node(node, "MaxPooling2D") PoolNode = get_node_from_metaop(node, "MaxPooling2D")
self.attributes["pool_type"] = "Max" self.attributes["pool_type"] = "Max"
self.attributes["kernel_dims"] = PoolNode.get_operator().attr.kernel_dims self.attributes["kernel_dims"] = PoolNode.get_operator().attr.kernel_dims
self.attributes["stride_dims"] = PoolNode.get_operator().attr.stride_dims self.attributes["stride_dims"] = PoolNode.get_operator().attr.stride_dims
...@@ -89,7 +89,7 @@ class AvgPool(Pool): ...@@ -89,7 +89,7 @@ class AvgPool(Pool):
super().__init__(node, mem_info) super().__init__(node, mem_info)
# Browse the metaop to update kernel attributes # Browse the metaop to update kernel attributes
PoolNode = get_node(node, "AvgPooling2D") PoolNode = get_node_from_metaop(node, "AvgPooling2D")
self.attributes["pool_type"] = "Average" self.attributes["pool_type"] = "Average"
self.attributes["kernel_dims"] = PoolNode.get_operator().attr.kernel_dims self.attributes["kernel_dims"] = PoolNode.get_operator().attr.kernel_dims
self.attributes["stride_dims"] = PoolNode.get_operator().attr.stride_dims self.attributes["stride_dims"] = PoolNode.get_operator().attr.stride_dims
......
import aidge_core import aidge_core
from aidge_core.export_utils import ExportNodeCpp, get_node from aidge_core.export_utils import ExportNodeCpp, get_node_from_metaop
from aidge_export_cpp import ROOT, ExportLibCpp, set_scaling_attributes from aidge_export_cpp import ROOT, ExportLibCpp, set_scaling_attributes
@ExportLibCpp.register_metaop("Quantizer", aidge_core.ImplSpec(aidge_core.IOSpec(aidge_core.dtype.any))) @ExportLibCpp.register_metaop("Quantizer", aidge_core.ImplSpec(aidge_core.IOSpec(aidge_core.dtype.any)))
...@@ -15,9 +15,9 @@ class CppRescaling(ExportNodeCpp): ...@@ -15,9 +15,9 @@ class CppRescaling(ExportNodeCpp):
self.attributes["aidge_cmp"] = node.attributes().has_attr("aidge_cmp") self.attributes["aidge_cmp"] = node.attributes().has_attr("aidge_cmp")
# Browse the metaop to update kernel attributes # Browse the metaop to update kernel attributes
if get_node(node, "ReLU") is not None: if get_node_from_metaop(node, "ReLU") is not None:
self.attributes["activation"] = "Rectifier" self.attributes["activation"] = "Rectifier"
elif get_node(node, "LeakyReLU") is not None: elif get_node_from_metaop(node, "LeakyReLU") is not None:
aidge_core.Log.fatal(f"{node.type()} activation is not yet supported.") aidge_core.Log.fatal(f"{node.type()} activation is not yet supported.")
# TODO : Should not be checked manually for each activation # TODO : Should not be checked manually for each activation
......
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