Slice node wrong nb_inputs ?
Context
I want to export the Slice
node to CPP. So I create a node with aidge_core
:
def test_slice(self):
print("Slice")
model = aidge_core.sequential([
aidge_core.Slice([0,0,2], [1,1,5], [0,1,2], [1,1,1], name="slice")
])
self.unit_test_export(model, "Slice", [[1, 1, 6]])
And implement it in Slice.py
:
@ExportLibCpp.register("Slice",
aidge_core.ImplSpec(aidge_core.IOSpec(aidge_core.dtype.any)))
class SliceCPP(ExportNodeCpp):
def __init__(self, node, mem_info):
super().__init__(node, mem_info)
self.attributes["starts"] = node.get_operator().attr.starts
self.attributes["ends"] = node.get_operator().attr.ends
self.attributes["axes"] = node.get_operator().attr.axes
self.attributes["steps"] = node.get_operator().attr.steps
[...]
Error
The problem comes from _meminfo.jinja
:
// MEMINFO CONF
{% for inidx in range(nb_in) -%}
[...]
#define {{ in_name[inidx]|upper }}_MEM_SIZE {{ in_size[inidx] * in_sizeof[inidx] }}
The problem is that Slice for aidge_core
defines 5 inputs ! nb_in
is 5 = 1 for the input + 4 for the attributes (starts,ends,axes,steps). But the attributes are not parent nodes so in_size[inidx]
and in_sizeof[inidx]
are None
for indices 1 to 4 (attributes).
My quick fix is to manually set nb_in
in Slice.py
:
self.attributes["nb_in"] = 1
But I'm not sure it is the right way to do it. So how to handle the export of nodes that have attributes not set as parent nodes ?
How to do it ?
Should I change Slice in aidge_core
so it has only 1 input ? Or should I set the slice attribute tensors as actual parent nodes ?
Thanks