[Fix] Checking nullptr on Node.cpp and ConstantFolding.cpp
Context
In the context of using expand_metaops(), adapt_to_backend() and constant_folding() to export arm_cortex_m with the LibCMSIS_NN backend, I encountered SIGSEGV when using two expand_metaops() or two constant_folding() in a row.
Example
model = aidge_core.sequential([
aidge_core.Conv2D(in_channels=2, out_channels = 2, kernel_dims = [1,1], name = 'conv', stride_dims= [1, 1], dilation_dims = [1, 1], no_bias= False),
aidge_quantization.Quantizer(scalingFactor = 0.005, clip_min = -128.0, clip_max = 127.0, name="scale")
])
model.set_datatype(aidge_core.dtype.float32)
model.set_backend("cpu")
model.save("PreFuse")
print("Fuse ConvScaling")
aidge_core.fuse_to_metaops(model, "Conv2D->Quantizer", "PaddedConvScalingRelu")
model.compile('cpu',aidge_core.dtype.float32, dims=[input_dims])
model.save("PostFuse")
scheduler = aidge_core.SequentialScheduler(model)
scheduler.generate_scheduling()
from aidge_export_arm_cortexm.export_registry import ExportLibAidgeARM, ExportLibCMSISNN
for node in model.get_nodes():
aidge_core.Log.debug(f"Setting backend {ExportLibCMSISNN._name} to {node.name()}[{node.type()}].")
node.get_operator().set_backend(ExportLibCMSISNN._name)
aidge_core.adapt_to_backend(model)
model.save("adapt_to_backend")
aidge_core.constant_folding(model)
aidge_core.constant_folding(model)
model.save("constant_folding")
# aidge_core.remove_constantOfShape(model)
aidge_core.expand_metaops(model)
aidge_core.expand_metaops(model)
model.save("exploded")
print("print")
Modified files
-
Node.cpp
andConstantFolding.cpp
, nullptr methods can no longer be accessed ;
Observations
With this MR, nullptr methods can no longer be accessed, but the problems may come from the calling functions.