Skip to content

[export_cpp] Issue with the tutorial "add custom operator" when using compute_output_dims

In the tutorial to add a custom operator in the CPP generic export, the user will have a problem when he/she has to set the compute_output_dims function for the Swish operator.

class SwishImpl(aidge_core.OperatorImpl): # Inherit OperatorImpl to interface with Aidge !
    def __init__(self, op: aidge_core.Operator):
        aidge_core.OperatorImpl.__init__(self, op, 'cpu')
    # no need to define forward() function in python as we do not intend to run a scheduler on the model

for node in model.get_nodes():
    if node.type() == "Swish":
        node.get_operator().set_compute_output_dims(lambda x: x) # to propagate dimensions in the model
        node.get_operator().set_impl(SwishImpl(node.get_operator())) # Setting implementation
---------------------------------------------------------------------------
IndexError                                Traceback (most recent call last)
Cell In[10], line 8
      6 for node in model.get_nodes():
      7     if node.type() == "Swish":
----> 8         node.get_operator().set_compute_output_dims(lambda x: x) # to propagate dimensions in the model
      9         node.get_operator().set_impl(SwishImpl(node.get_operator())) # Setting implementation

IndexError: map::at

It seems there is an issue with the C++ code of the GenericOperator.