Operators#

Operator base class#

Operator is Aidge’s base class for describing a mathematical Operator. It does not make any assumption on the data coding.

class aidge_core.Operator#
__init__(*args, **kwargs)#
associate_input(self: aidge_core.aidge_core.Operator, inputIdx: int, data: aidge_core.aidge_core.Data) None#
backend(self: aidge_core.aidge_core.Operator) str#
clone(self: aidge_core.aidge_core.Operator) aidge_core.aidge_core.Operator#
forward(self: aidge_core.aidge_core.Operator) None#
get_impl(self: aidge_core.aidge_core.Operator) aidge_core.aidge_core.OperatorImpl#
get_raw_input(self: aidge_core.aidge_core.Operator, inputIdx: int) aidge_core.aidge_core.Data#
get_raw_output(self: aidge_core.aidge_core.Operator, outputIdx: int) aidge_core.aidge_core.Data#
input_category(*args, **kwargs)#

Overloaded function.

  1. input_category(self: aidge_core.aidge_core.Operator) -> List[aidge_core.aidge_core.InputCategory]

    Category of the inputs (Data or Param, optional or not). Data inputs exclude inputs expecting parameters (weights or bias).

    rtype:

    list(InputCategory)

  2. input_category(self: aidge_core.aidge_core.Operator, idx: int) -> aidge_core.aidge_core.InputCategory

    Category of a specific input (Data or Param, optional or not). Data inputs exclude inputs expecting parameters (weights or bias).

    rtype:

    InputCategory

is_atomic(self: aidge_core.aidge_core.Operator) bool#
is_back_edge(self: aidge_core.aidge_core.Operator, input_index: int) bool#
is_optional_input(self: aidge_core.aidge_core.Operator, inputIdx: int) bool#
nb_inputs(self: aidge_core.aidge_core.Operator) int#
nb_outputs(self: aidge_core.aidge_core.Operator) int#
set_back_edges(self: aidge_core.aidge_core.Operator, input_indexes: Set[int]) None#
set_backend(*args, **kwargs)#

Overloaded function.

  1. set_backend(self: aidge_core.aidge_core.Operator, name: str, device: int = 0) -> None

  2. set_backend(self: aidge_core.aidge_core.Operator, backends: List[Tuple[str, int]]) -> None

set_dataformat(self: aidge_core.aidge_core.Operator, dataFormat: aidge_core.aidge_core.dformat) None#
set_datatype(self: aidge_core.aidge_core.Operator, dataType: aidge_core.aidge_core.dtype) None#
set_impl(self: aidge_core.aidge_core.Operator, implementation: aidge_core.aidge_core.OperatorImpl) None#
set_input(*args, **kwargs)#

Overloaded function.

  1. set_input(self: aidge_core.aidge_core.Operator, inputIdx: int, data: aidge_core.aidge_core.Data) -> None

  2. set_input(self: aidge_core.aidge_core.Operator, inputIdx: int, data: aidge_core.aidge_core.Data) -> None

set_output(self: aidge_core.aidge_core.Operator, outputIdx: int, data: aidge_core.aidge_core.Data) None#
type(self: aidge_core.aidge_core.Operator) str#
class Operator : public std::enable_shared_from_this<Operator>#

Base class for all operator types in the Aidge framework.

The Operator class provides a foundation for implementing various operator types. Derived classes must implement specific behaviors for computation, attributes, and input/output handling.

Subclassed by Aidge::OperatorTensor

Public Functions

Operator() = delete#

Deleted default constructor.

inline Operator(const std::string &type, const std::vector<InputCategory> &inputsCategory, const IOIndex_t nbOut, const OperatorType operatorType = OperatorType::Data)#

Constructs an Operator instance.

Parameters:
  • type[in] The type of operator (e.g., “Add”, “AveragePool”).

  • inputsCategory[in] Categories of each input.

  • nbOut[in] Number of outputs.

  • operatorType[in] Type of operator (Data or Tensor).

inline Operator(const Operator &op)#

Copy constructor.

Parameters:

op[in] The operator to copy.

virtual ~Operator() noexcept#

Virtual destructor.

inline void setInheritedAttrs(std::shared_ptr<DynamicAttributes> &attr)#
virtual std::shared_ptr<Operator> clone() const = 0#

Creates a clone of the current operator.

Derived classes must implement this method to provide a deep copy of the operator.

Returns:

A shared pointer to the cloned operator.

inline virtual std::shared_ptr<Attributes> attributes() const#

Returns the attributes of the operator.

inline virtual std::shared_ptr<DynamicAttributes> inheritedAttributes() const#

Get the currently associated Node’s attributes.

If no Node as be associated to the Operator, returns a nullptr.

Note

As Operators have only been tested with a single associated Node, only attributes of the first associated Node are returned. This should be updated.

Returns:

Shared pointer to the Attributes of the associated Node.

virtual void associateInput(const IOIndex_t inputIdx, const std::shared_ptr<Data> &data) = 0#

Associates a shallow copy of the specified input data with the operator.

Derived classes must implement this method.

Parameters:
  • inputIdx[in] Index of the input to associate.

  • data[in] Data to associate.

virtual void resetInput(const IOIndex_t inputIdx) = 0#

Resets the specified input.

virtual void setInput(const IOIndex_t inputIdx, const std::shared_ptr<Data> &data) = 0#

Sets the specified input with a deep copy of the given data.

Derived classes must implement this method.

Parameters:
  • inputIdx[in] Index of the input to set.

  • data[in] Data to set.

virtual std::shared_ptr<Data> getRawInput(const IOIndex_t inputIdx) const = 0#

Retrieves the raw input data for the specified index.

virtual void setOutput(const IOIndex_t outputIdx, const std::shared_ptr<Data> &data) const = 0#

Sets the specified output with a deep copy of the given data.

Derived classes must implement this method.

Parameters:
  • outputIdx[in] Index of the output to set.

  • data[in] Data to set.

virtual std::shared_ptr<Data> getRawOutput(const IOIndex_t outputIdx) const = 0#

Retrieves the raw output data for the specified index.

inline virtual std::string backend() const noexcept#

Returns the backend implementation name.

Returns:

The name of the backend implementation.

virtual void setBackend(const std::string &name, DeviceIdx_t device = 0) = 0#

Sets the backend implementation.

Parameters:
  • name[in] Name of the backend.

  • device[in] Device index.

void setBackend(const std::vector<std::pair<std::string, DeviceIdx_t>> &backends)#

Sets the backend implementation for multiple devices.

Parameters:

backends[in] A vector of backend and device index pairs.

virtual void setDataType(const DataType &dataType) const = 0#
virtual void setDataFormat(const DataFormat &dataFormat) const = 0#
virtual std::set<std::string> getAvailableBackends() const = 0#

Returns the available backend implementations.

Derived classes must implement this method.

Returns:

A set of available backend names.

inline void setImpl(std::shared_ptr<OperatorImpl> impl)#

Set a new OperatorImpl to the Operator.

inline std::shared_ptr<OperatorImpl> getImpl() const noexcept#

Get the OperatorImpl of the Operator.

virtual Elts_t getNbRequiredData(const IOIndex_t inputIdx) const#

Minimum amount of data from a specific input for one computation pass.

Parameters:

inputIdx – Index of the input analyzed.

Returns:

Elts_t

virtual Elts_t getNbRequiredProtected(const IOIndex_t inputIdx) const#
virtual Elts_t getRequiredMemory(const IOIndex_t outputIdx, const std::vector<DimSize_t> &inputsSize) const#
virtual Elts_t getNbConsumedData(const IOIndex_t inputIdx) const#

Total amount of consumed data from a specific input.

Parameters:

inputIdx – Index of the input analyzed.

Returns:

Elts_t

virtual Elts_t getNbProducedData(const IOIndex_t outputIdx) const#

Total amount of produced data ready to be used on a specific output.

Parameters:

outputIdx – Index of the output analyzed.

Returns:

Elts_t

virtual void updateConsummerProducer()#
virtual void resetConsummerProducer()#
virtual void forward()#
virtual void backward()#
inline std::string type() const noexcept#

Returns the type of the operator.

Returns:

The operator type as a string.

inline OperatorType operatorType() const noexcept#

Returns the type of the operator (Data or Tensor).

Returns:

The operator type as an OperatorType enum value.

inline std::vector<InputCategory> inputCategory() const#

Returns the categories of all inputs.

inline InputCategory inputCategory(IOIndex_t idx) const#

Returns the category of a specific input.

inline bool isOptionalInput(std::size_t inputIdx) const#
inline virtual bool isAtomic() const noexcept#
inline IOIndex_t nbInputs() const noexcept#

Returns the number of inputs.

inline IOIndex_t nbOutputs() const noexcept#

Returns the number of outputs.

inline void setBackEdges(const std::set<IOIndex_t> &backEdges)#

Sets the back edge input indexes for recurring operators.

Parameters:

backEdges[in] A set of input indexes representing back edges.

inline bool isBackEdge(IOIndex_t inputIdx) const#

Checks if a given input index is a back edge.

Parameters:

inputIdx[in] Index of the input to check.

Returns:

True if the input index is a back edge, false otherwise.

Public Static Functions

static inline const std::vector<std::string> getInputsName()#

Returns an empty vector of input names.

static inline const std::vector<std::string> getOutputsName()#

Returns an empty vector of output names.

OperatorTensor base class#

OperatorTensor derives from the Operator base class and is the base class for any tensor-based operator.

class aidge_core.OperatorTensor#
__init__(*args, **kwargs)#
associate_input(self: aidge_core.aidge_core.Operator, inputIdx: int, data: aidge_core.aidge_core.Data) None#
backend(self: aidge_core.aidge_core.Operator) str#
clone(self: aidge_core.aidge_core.Operator) aidge_core.aidge_core.Operator#
dims_forwarded(self: aidge_core.aidge_core.OperatorTensor) bool#
forward(self: aidge_core.aidge_core.Operator) None#
forward_dims(self: aidge_core.aidge_core.OperatorTensor, allow_data_dependency: bool = False) bool#
get_impl(self: aidge_core.aidge_core.Operator) aidge_core.aidge_core.OperatorImpl#
get_input(self: aidge_core.aidge_core.OperatorTensor, inputIdx: int) aidge_core.aidge_core.Tensor#
get_inputs(self: aidge_core.aidge_core.OperatorTensor) List[aidge_core.aidge_core.Tensor]#
get_output(self: aidge_core.aidge_core.OperatorTensor, outputIdx: int) aidge_core.aidge_core.Tensor#
get_outputs(self: aidge_core.aidge_core.OperatorTensor) List[aidge_core.aidge_core.Tensor]#
get_raw_input(self: aidge_core.aidge_core.Operator, inputIdx: int) aidge_core.aidge_core.Data#
get_raw_output(self: aidge_core.aidge_core.Operator, outputIdx: int) aidge_core.aidge_core.Data#
input_category(*args, **kwargs)#

Overloaded function.

  1. input_category(self: aidge_core.aidge_core.Operator) -> List[aidge_core.aidge_core.InputCategory]

    Category of the inputs (Data or Param, optional or not). Data inputs exclude inputs expecting parameters (weights or bias).

    rtype:

    list(InputCategory)

  2. input_category(self: aidge_core.aidge_core.Operator, idx: int) -> aidge_core.aidge_core.InputCategory

    Category of a specific input (Data or Param, optional or not). Data inputs exclude inputs expecting parameters (weights or bias).

    rtype:

    InputCategory

is_atomic(self: aidge_core.aidge_core.Operator) bool#
is_back_edge(self: aidge_core.aidge_core.Operator, input_index: int) bool#
is_optional_input(self: aidge_core.aidge_core.Operator, inputIdx: int) bool#
nb_inputs(self: aidge_core.aidge_core.Operator) int#
nb_outputs(self: aidge_core.aidge_core.Operator) int#
set_back_edges(self: aidge_core.aidge_core.Operator, input_indexes: Set[int]) None#
set_backend(*args, **kwargs)#

Overloaded function.

  1. set_backend(self: aidge_core.aidge_core.Operator, name: str, device: int = 0) -> None

  2. set_backend(self: aidge_core.aidge_core.Operator, backends: List[Tuple[str, int]]) -> None

set_dataformat(self: aidge_core.aidge_core.Operator, dataFormat: aidge_core.aidge_core.dformat) None#
set_datatype(self: aidge_core.aidge_core.Operator, dataType: aidge_core.aidge_core.dtype) None#
set_impl(self: aidge_core.aidge_core.Operator, implementation: aidge_core.aidge_core.OperatorImpl) None#
set_input(self: aidge_core.aidge_core.OperatorTensor, outputIdx: int, data: aidge_core.aidge_core.Data) None#
set_output(self: aidge_core.aidge_core.OperatorTensor, outputIdx: int, data: aidge_core.aidge_core.Data) None#
type(self: aidge_core.aidge_core.Operator) str#
class OperatorTensor : public Aidge::Operator#

Base class for all operators that work with tensor inputs and outputs.

The OperatorTensor class provides an abstraction for operations on tensors with features such as input/output management, dimension handling, and receptive field computation.

See also

Operator

Subclassed by Aidge::Abs_Op, Aidge::Add_Op, Aidge::And_Op, Aidge::ArgMax_Op, Aidge::Atan_Op, Aidge::AvgPooling_Op< DIM >, Aidge::BatchNorm_Op< DIM >, Aidge::BitShift_Op, Aidge::Cast_Op, Aidge::Clip_Op, Aidge::Concat_Op, Aidge::ConstantOfShape_Op, Aidge::ConvDepthWise_Op< DIM >, Aidge::Conv_Op< DIM >, Aidge::DepthToSpace_Op, Aidge::Div_Op, Aidge::Erf_Op, Aidge::Expand_Op, Aidge::FC_Op, Aidge::Flatten_Op, Aidge::Fold_Op< DIM >, Aidge::Gather_Op, Aidge::GenericOperator_Op, Aidge::GlobalAveragePooling_Op, Aidge::GridSample_Op, Aidge::Heaviside_Op, Aidge::ILayerNorm_Op, Aidge::Identity_Op, Aidge::LRN_Op, Aidge::LeakyReLU_Op, Aidge::Ln_Op, Aidge::MatMul_Op, Aidge::MaxPooling_Op< DIM >, Aidge::Memorize_Op, Aidge::MetaOperator_Op, Aidge::Move_Op, Aidge::Mul_Op, Aidge::Pad_Op< DIM >, Aidge::Pop_Op, Aidge::Pow_Op, Aidge::Producer_Op, Aidge::ReLU_Op, Aidge::ReduceMean_Op, Aidge::ReduceSum_Op, Aidge::Reshape_Op, Aidge::Resize_Op, Aidge::Round_Op, Aidge::Scaling_Op, Aidge::Shape_Op, Aidge::ShiftGELU_Op, Aidge::ShiftMax_Op, Aidge::Sigmoid_Op, Aidge::Slice_Op, Aidge::Softmax_Op, Aidge::Split_Op, Aidge::Sqrt_Op, Aidge::Squeeze_Op, Aidge::StackOp, Aidge::Sub_Op, Aidge::Tanh_Op, Aidge::Transpose_Op, Aidge::Unfold_Op< DIM >, Aidge::Unsqueeze_Op, Aidge::WeightInterleaving_Op

Public Functions

OperatorTensor() = delete#
OperatorTensor(const std::string &type, const std::vector<InputCategory> &inputsCategory, const IOIndex_t nbOut)#

Operator tensor constructor. This function is not meant to be called directly but by a derived class constructor every operator class derive from this class.

Parameters:
  • type[in] : type of operator (i.e. “Add”, “AveragePool”,…)

  • inputsCategory[in] : describes the type of each input.

  • nbOut[in] : Number of tensors this operator will output

OperatorTensor(const OperatorTensor &other)#

Copy constructor.

Parameters:

other[in] Another OperatorTensor instance to copy.

~OperatorTensor()#

Destructor for the OperatorTensor class.

virtual void associateInput(const IOIndex_t inputIdx, const std::shared_ptr<Data> &data) override#

Associates an input tensor to the operator.

Parameters:
  • inputIdx[in] Index of the input to associate.

  • data[in] Shared pointer to the data to associate.

virtual void resetInput(const IOIndex_t inputIdx) final override#

Resets the input tensor at a given index.

Parameters:

inputIdx[in] Index of the input to reset.

virtual void setInput(const IOIndex_t inputIdx, const std::shared_ptr<Data> &data) override#

Sets an input tensor for the operator.

Parameters:
  • inputIdx[in] Index of the input to set.

  • data[in] Shared pointer to the data to set.

const std::shared_ptr<Tensor> &getInput(const IOIndex_t inputIdx) const#

Retrieves an input tensor.

Parameters:

inputIdx[in] Index of the input to retrieve.

Returns:

Shared pointer to the input tensor.

virtual const std::vector<std::shared_ptr<Tensor>> &getInputs() const#
virtual std::shared_ptr<Data> getRawInput(const IOIndex_t inputIdx) const final override#

Retrieves a raw input tensor.

Parameters:

inputIdx[in] Index of the input to retrieve.

Returns:

Shared pointer to the raw input tensor.

virtual void setOutput(const IOIndex_t outputIdx, const std::shared_ptr<Data> &data) const override#

Sets an output tensor for the operator.

Parameters:
  • outputIdx[in] Index of the output to set.

  • data[in] Shared pointer to the data to set.

virtual const std::shared_ptr<Tensor> &getOutput(const IOIndex_t outputIdx) const#

Retrieves an output tensor.

Parameters:

outputIdx[in] Index of the output to retrieve.

Returns:

Shared pointer to the output tensor.

virtual const std::vector<std::shared_ptr<Tensor>> &getOutputs() const#
virtual std::shared_ptr<Aidge::Data> getRawOutput(const Aidge::IOIndex_t outputIdx) const final override#

Retrieves a raw output tensor.

Parameters:

outputIdx[in] Index of the output to retrieve.

Returns:

Shared pointer to the raw output tensor.

virtual std::vector<std::pair<std::vector<Aidge::DimSize_t>, std::vector<DimSize_t>>> computeReceptiveField(const std::vector<DimSize_t> &firstEltDims, const std::vector<DimSize_t> &outputDims, const IOIndex_t outputIdx = 0) const#

Computes the receptive field for a given output feature area.

Parameters:
  • firstIdx[in] First index of the output feature.

  • outputDims[in] Dimensions of the output feature.

  • outputIdx[in] Index of the output (default is 0).

Returns:

Vector of pairs containing, for each data input tensor, the first index and dimensions of the feature area.

virtual bool forwardDims(bool allowDataDependency = false)#

Computes the dimensions of the operator’s output tensor based on input sizes.

  • If the output dimensions depend on undefined inputs, this function returns false and enters TOKEN mode.

  • TOKEN mode ensures that all inputs and outputs of the graph the node belongs to are connected.

Parameters:

allowDataDependency[in] Flag to indicate if output dimensions depend on optional parameter tensors.

Returns:

True if dimensions are successfully computed, false otherwise.

virtual bool dimsForwarded() const#

Checks if dimensions have been successfully forwarded.

Returns:

True if dimensions are forwarded, false otherwise.

virtual void setDataType(const DataType &dataType) const override#

Sets the data type of the operator’s tensors.

Parameters:

dataType – Data type to set.

virtual void setDataFormat(const DataFormat &dataFormat) const override#

Sets the data format of the operator’s tensors.

Parameters:

dataFormat – Data format to set.

virtual void forward() override#

Executes the forward operation for the operator.

Generic Operator#

A generic tensor-based operator can be used to model any kind of mathematical operator that takes a defined number of inputs, produces a defined number of outputs and can have some attributes. It is possible to provide a function that produces the output tensors size w.r.t. the inputs size. It has a default consumer-producer model (require and consume all inputs full tensors and produces output full tensors).

This is the default operator used for unsupported ONNX operators when loading an ONNX model. While it obviously cannot be executed, a generic operator has still some usefulness:

  • It allows loading any graph even with unknown operators. It is possible to identify exactly all the missing operator types and their position in the graph;

  • It can be searched and manipuled with graph matching, allowing for example to replace it with alternative operators;

  • It can be scheduled and included in the graph static scheduling;

  • 🚧 A custom implementation may be provided in the future, even in pure Python, for rapid integration and prototyping.

aidge_core.GenericOperator(*args, **kwargs)#

Overloaded function.

  1. GenericOperator(type: str, input_category: List[aidge_core.aidge_core.InputCategory], nb_out: int, name: str = ‘’, **kwargs) -> aidge_core.aidge_core.Node

  2. GenericOperator(type: str, nb_data: int, nb_param: int, nb_out: int, name: str = ‘’, **kwargs) -> aidge_core.aidge_core.Node

  3. GenericOperator(type: str, op: aidge_core.aidge_core.OperatorTensor, name: str = ‘’) -> aidge_core.aidge_core.Node

Warning

doxygenfunction: Unable to resolve function “Aidge::GenericOperator” with arguments None in doxygen xml output for project “aidge” from directory: xml/. Potential matches:

- std::shared_ptr<Aidge::Node> GenericOperator(const std::string &type, std::shared_ptr<OperatorTensor> op, const std::string &name = "")
- std::shared_ptr<Node> GenericOperator(const std::string &type, IOIndex_t nbData, IOIndex_t nbParam, IOIndex_t nbOut, const std::string &name = "")
- std::shared_ptr<Node> GenericOperator(const std::string &type, const std::vector<InputCategory> &inputCategory, IOIndex_t nbOut, const std::string &name = "")

Meta Operator#

A meta-operator (or composite operator) is internally built from a sub-graph.

aidge_core.meta_operator(type: str, graph: aidge_core.aidge_core.GraphView, forced_inputs_category: List[aidge_core.aidge_core.InputCategory] = [], name: str = '') aidge_core.aidge_core.Node#
std::shared_ptr<Node> Aidge::MetaOperator(const char *type, const std::shared_ptr<GraphView> &graph, const std::vector<InputCategory> &forcedInputsCategory = {}, const std::string &name = "")#

Helper function to create a MetaOperator node.

Parameters:
  • type – The type of the meta-operator.

  • graph – The micro-graph defining the meta-operator.

  • forcedInputsCategory – Optional input categories to override default behavior.

  • name – Optional name for the operator.

Returns:

A shared pointer to the created Node.

Building a new meta-operator is simple:

auto graph = Sequential({
    Pad<2>(padding_dims, (!name.empty()) ? name + "_pad" : ""),
    MaxPooling(kernel_dims, (!name.empty()) ? name + "_maxpooling" : "", stride_dims, ceil_mode)
});

return MetaOperator("PaddedMaxPooling2D", graph, name);

You can use the Expand meta operators recipe to flatten the meta-operators in a graph.

Predefined operators#

Add#

        %%{init: {'flowchart': { 'curve': 'monotoneY'}, 'fontFamily': 'Verdana' } }%%
graph TD

    Op("<b>AddOp</b>
    
    
    "):::operator

    In0[data_input_0]:::text-only -->|"In[0]"| Op
    In1[data_input_n]:::text-only -->|"In[1]"| Op
    

    Op -->|"Out[0]"| Out0[data_output]:::text-only
    

    classDef text-only fill-opacity:0, stroke-opacity:0;

    classDef operator stroke-opacity:0;
    
aidge_core.Add(name: str = '') aidge_core.aidge_core.Node#

Initialize a node containing an Add operator that performs element-wise addition between two tensors. The operation is defined as:

Output = Input1 + Input2

The output tensor shape is determined by taking the maximum size along each dimension of the input tensors after broadcasting. Examples:

Input A: (3, 4, 2), Input B: (2), Output: (3, 4, 2) Input A: (1, 5, 3), Input B: (2, 1, 3), Output: (2, 5, 3)

:param name : Name of the node (optional). :type name : str :return: A node containing the Add operator. :rtype: AddOp

std::shared_ptr<Node> Aidge::Add(const std::string &name = "")#

Average Pooling#

        %%{init: {'flowchart': { 'curve': 'monotoneY'}, 'fontFamily': 'Verdana' } }%%
graph TD

    Op("<b>AvgPooling2DOp</b>
    
    
    "):::operator

    In0[data_input]:::text-only -->|"In[0]"| Op
    

    Op -->|"Out[0]"| Out0[data_output]:::text-only
    

    classDef text-only fill-opacity:0, stroke-opacity:0;

    classDef operator stroke-opacity:0;
    
aidge_core.AvgPooling1D(kernel_dims: List[int], name: str = '', stride_dims: List[int] = [1]) aidge_core.aidge_core.Node#

Initialize a node containing an AvgPooling operator.

This function performs average pooling on the tensor with the given kernel and stride dimensions.

Parameters:
  • kernel_dims (List[int]) – Size of the kernel applied during pooling.

  • name (str) – Name of the operator node (optional).

  • stride_dims (List[int], optional) – Stride dimensions for the pooling operation.

aidge_core.AvgPooling2D(kernel_dims: List[int], name: str = '', stride_dims: List[int] = [1, 1]) aidge_core.aidge_core.Node#

Initialize a node containing an AvgPooling operator.

This function performs average pooling on the tensor with the given kernel and stride dimensions.

Parameters:
  • kernel_dims (List[int]) – Size of the kernel applied during pooling.

  • name (str) – Name of the operator node (optional).

  • stride_dims (List[int], optional) – Stride dimensions for the pooling operation.

aidge_core.AvgPooling3D(kernel_dims: List[int], name: str = '', stride_dims: List[int] = [1, 1, 1]) aidge_core.aidge_core.Node#

Initialize a node containing an AvgPooling operator.

This function performs average pooling on the tensor with the given kernel and stride dimensions.

Parameters:
  • kernel_dims (List[int]) – Size of the kernel applied during pooling.

  • name (str) – Name of the operator node (optional).

  • stride_dims (List[int], optional) – Stride dimensions for the pooling operation.

template<DimSize_t DIM>
inline std::shared_ptr<Node> Aidge::AvgPooling(DimSize_t const (&kernel_dims)[DIM], const std::string &name = "", const std::array<DimSize_t, DIM> &stride_dims = create_array<DimSize_t, DIM>(1))#

Overload of AvgPooling for C-style arrays.

Template Parameters:

DIM – Number of dimensions for the pooling operation.

Parameters:
  • kernel_dims – C-style array specifying the kernel dimensions.

  • name – Name of the operator node. Defaults to an empty string.

  • stride_dims – Step size (stride) for sliding the pooling window across the input dimensions. Defaults to 1 for each dimension.

Returns:

A shared pointer to the created operator node.

BatchNorm#

        %%{init: {'flowchart': { 'curve': 'monotoneY'}, 'fontFamily': 'Verdana' } }%%
graph TD

    Op("<b>BatchNorm2DOp</b>
    
    
    "):::operator

    In0[data_input]:::text-only -->|"In[0]"| Op
    In1[scale]:::text-only -->|"In[1]"| Op
    In2[shift]:::text-only -->|"In[2]"| Op
    In3[mean]:::text-only -->|"In[3]"| Op
    In4[variance]:::text-only -->|"In[4]"| Op
    

    Op -->|"Out[0]"| Out0[data_output]:::text-only
    

    classDef text-only fill-opacity:0, stroke-opacity:0;

    classDef operator stroke-opacity:0;
    
aidge_core.BatchNorm2D(nb_features: int, epsilon: float = 9.999999747378752e-06, momentum: float = 0.10000000149011612, training_mode: bool = False, name: str = '') aidge_core.aidge_core.Node#

Initialize a node containing a BatchNorm operator.

:param nb_features : The number of features in the input tensor. :type nb_features : int :param epsilon : A small value added to the denominator for numerical stability. :type epsilon : float :param momentum : The momentum factor for the moving averages. :type momentum : float :param training_mode : Whether the operator is in training mode or inference mode. :type training_mode : bool :param name : Name of the node. :type name : str

template<DimSize_t DIM>
std::shared_ptr<Node> Aidge::BatchNorm(const DimSize_t nbFeatures, const float epsilon = 1.0e-5F, const float momentum = 0.1F, const bool trainingMode = false, const std::string &name = "")#

Cast#

Not available yet !

std::shared_ptr<Node> Aidge::Cast(const DataType targetType, const std::string &name = "")#

Factory function to create a Cast node.

Parameters:
  • targetType[in] The desired data type to cast to.

  • name[in] Name of the operator node.

Returns:

A shared pointer to the created Cast node.

Concat#

aidge_core.Concat(nb_inputs: int, axis: int, name: str = '') aidge_core.aidge_core.Node#

Initialize a node containing a Concat operator.

:param nb_inputs : The number of input tensors to concatenate. :type nb_inputs : int :param axis : The axis along which to concatenate the tensors. :type axis : int :param name : Name of the node. :type name : str

std::shared_ptr<Node> Aidge::Concat(const IOIndex_t nbIn, const std::int32_t axis = 0, const std::string &name = "")#

Factory function to create a Concat node.

Parameters:
  • nbIn[in] Number of input tensors.

  • axis[in] Axis along which concatenation is performed (default: 0).

  • name[in] (Optional) Name of the node.

Returns:

A shared pointer to the created node.

Conv#

        %%{init: {'flowchart': { 'curve': 'monotoneY'}, 'fontFamily': 'Verdana' } }%%
graph TD

    Op("<b>Conv2DOp</b>
    
    
    "):::operator

    In0[data_input]:::text-only -->|"In[0]"| Op
    In1[weight]:::text-only -->|"In[1]"| Op
    In2[bias]:::text-only -->|"In[2]"| Op
    

    Op -->|"Out[0]"| Out0[data_output]:::text-only
    

    classDef text-only fill-opacity:0, stroke-opacity:0;

    classDef operator stroke-opacity:0;
    
aidge_core.Conv1D(in_channels: int, out_channels: int, kernel_dims: List[int], name: str = '', stride_dims: List[int] = [1], dilation_dims: List[int] = [1], no_bias: bool = False) aidge_core.aidge_core.Node#

Initialize a node containing a convolution operator.

:param in_channels : The number of input channels (depth of the input tensor). :type in_channels : int :param out_channels : The number of output channels (depth of the output tensor). :type out_channels : int :param kernel_dims : The dimensions of the convolution kernel (filter size). :type kernel_dims : List[int] :param name : The name of the operator (optional). :type name : str :param stride_dims : The stride size for the convolution (default is [1]). :type stride_dims : List[int] :param dilation_dims : The dilation size for the convolution (default is [1]). :type dilation_dims : List[int] :param no_bias : Whether to disable bias (default is False). :type no_bias : bool :return : A new Convolution operator node. :rtype : ConvOp

aidge_core.Conv2D(in_channels: int, out_channels: int, kernel_dims: List[int], name: str = '', stride_dims: List[int] = [1, 1], dilation_dims: List[int] = [1, 1], no_bias: bool = False) aidge_core.aidge_core.Node#

Initialize a node containing a convolution operator.

:param in_channels : The number of input channels (depth of the input tensor). :type in_channels : int :param out_channels : The number of output channels (depth of the output tensor). :type out_channels : int :param kernel_dims : The dimensions of the convolution kernel (filter size). :type kernel_dims : List[int] :param name : The name of the operator (optional). :type name : str :param stride_dims : The stride size for the convolution (default is [1]). :type stride_dims : List[int] :param dilation_dims : The dilation size for the convolution (default is [1]). :type dilation_dims : List[int] :param no_bias : Whether to disable bias (default is False). :type no_bias : bool :return : A new Convolution operator node. :rtype : ConvOp

template<DimSize_t DIM>
inline std::shared_ptr<Node> Aidge::Conv(DimSize_t inChannels, DimSize_t outChannels, DimSize_t const (&kernelDims)[DIM], const std::string &name = "", const std::array<DimSize_t, DIM> &strideDims = create_array<DimSize_t, DIM>(1), const std::array<DimSize_t, DIM> &dilationDims = create_array<DimSize_t, DIM>(1), bool noBias = false)#

Helper function for Conv with C-style arrays.

This helper function allows automatic template deduction of the number of dimensions (DIM) based on the kernel dimensions provided.

ConvDepthWise#

        %%{init: {'flowchart': { 'curve': 'monotoneY'}, 'fontFamily': 'Verdana' } }%%
graph TD

    Op("<b>ConvDepthWise2DOp</b>
    
    
    "):::operator

    In0[data_input]:::text-only -->|"In[0]"| Op
    In1[weight]:::text-only -->|"In[1]"| Op
    In2[bias]:::text-only -->|"In[2]"| Op
    

    Op -->|"Out[0]"| Out0[data_output]:::text-only
    

    classDef text-only fill-opacity:0, stroke-opacity:0;

    classDef operator stroke-opacity:0;
    
aidge_core.ConvDepthWise1D(nb_channels: int, kernel_dims: List[int], name: str = '', stride_dims: List[int] = [1], dilation_dims: List[int] = [1], no_bias: bool = False) aidge_core.aidge_core.Node#

Initialize a node containing a depthwise convolution operator.

:param nb_channels : The number of channels in the input tensor (i.e., depth of the tensor). :type nb_channels : int :param kernel_dims : The dimensions of the convolution kernel (filter size). :type kernel_dims : List[int] :param name : The name of the operator node (optional). :type name : str :param stride_dims : The stride size for the convolution (default is [1]). :type stride_dims : List[int] :param dilation_dims : The dilation size for the convolution (default is [1]). :type dilation_dims : List[int] :param no_bias : Whether to disable bias in the operation (default is False). :type no_bias : bool :return : A new Depthwise Convolution operator node. :rtype : ConvDepthWiseOp

aidge_core.ConvDepthWise2D(nb_channels: int, kernel_dims: List[int], name: str = '', stride_dims: List[int] = [1, 1], dilation_dims: List[int] = [1, 1], no_bias: bool = False) aidge_core.aidge_core.Node#

Initialize a node containing a depthwise convolution operator.

:param nb_channels : The number of channels in the input tensor (i.e., depth of the tensor). :type nb_channels : int :param kernel_dims : The dimensions of the convolution kernel (filter size). :type kernel_dims : List[int] :param name : The name of the operator node (optional). :type name : str :param stride_dims : The stride size for the convolution (default is [1]). :type stride_dims : List[int] :param dilation_dims : The dilation size for the convolution (default is [1]). :type dilation_dims : List[int] :param no_bias : Whether to disable bias in the operation (default is False). :type no_bias : bool :return : A new Depthwise Convolution operator node. :rtype : ConvDepthWiseOp

template<DimSize_t DIM>
inline std::shared_ptr<Node> Aidge::ConvDepthWise(const DimSize_t nbChannels, DimSize_t const (&kernelDims)[DIM], const std::string &name = "", const std::array<DimSize_t, DIM> &strideDims = create_array<DimSize_t, DIM>(1), const std::array<DimSize_t, DIM> &dilationDims = create_array<DimSize_t, DIM>(1), bool noBias = false)#

Helper function for ConvDepthWise with C-style arrays.

This helper function allows automatic template deduction of the number of dimensions (DIM) based on the kernel dimensions provided.

Div#

aidge_core.Div(name: str = '') aidge_core.aidge_core.Node#

Initialize a node containing a Div operator that performs element-wise division between two tensors. The operation is defined as:

Output = Input1 / Input2

The output tensor shape is determined by taking the maximum size along each dimension of the input tensors after broadcasting. Examples:

Input A: (3, 4, 2), Input B: (2), Output: (3, 4, 2) Input A: (1, 5, 3), Input B: (2, 1, 3), Output: (2, 5, 3)

:param name : Name of the node (optional). :type name : str :return: A node containing the Div operator. :rtype: DivOp

std::shared_ptr<Node> Aidge::Div(const std::string &name = "")#

Erf#

aidge_core.Erf(name: str = '') aidge_core.aidge_core.Node#

Initialize a node containing an Erf operator that computes the error function (erf) element-wise. The error function (erf) is computed element-wise as follows:

erf(x) = (2 / sqrt(pi)) * integral from 0 to x of exp(-t^2) dt

:param name : name of the node (optional). :type name : str :return : A node containing the Erf operator. :rtype : ErfOp

std::shared_ptr<Node> Aidge::Erf(const std::string &name = "")#

FC#

        %%{init: {'flowchart': { 'curve': 'monotoneY'}, 'fontFamily': 'Verdana' } }%%
graph TD

    Op("<b>FCOp</b>
    
    
    "):::operator

    In0[data_input]:::text-only -->|"In[0]"| Op
    In1[weight]:::text-only -->|"In[1]"| Op
    In2[bias]:::text-only -->|"In[2]"| Op
    

    Op -->|"Out[0]"| Out0[data_output]:::text-only
    

    classDef text-only fill-opacity:0, stroke-opacity:0;

    classDef operator stroke-opacity:0;
    
aidge_core.FC(in_channels: int, out_channels: int, no_bias: bool = False, name: str = '') aidge_core.aidge_core.Node#

Initialize a node containing a Fully Connected (FC) operator.

:param in_channels : The number of input channels (features). :type in_channels : int :param out_channels : The number of output channels (features). :type out_channels : int :param no_bias : Whether to include bias in the operation. Defaults to False. :type no_bias : bool :param name : Name of the node. :type name : str

std::shared_ptr<Node> Aidge::FC(const DimSize_t inChannels, const DimSize_t outChannels, bool noBias = false, const std::string &name = "")#

Creates a Fully Connected operation node.

Constructs an FC operator node with the specified input and output channels.

Parameters:
  • inChannels[in] Number of input channels.

  • outChannels[in] Number of output channels.

  • noBias[in] Flag indicating whether to use a bias term (default is false).

  • name[in] Name of the operator (optional).

Returns:

A shared pointer to the Node containing the FC operator.

Gather#

aidge_core.Gather(axis: int = 0, indices: List[int] = [], gathered_shape: List[int] = [], name: str = '') aidge_core.aidge_core.Node#

Initialize a node containing a Gather operator that extracts elements from a tensor along a specified axis.

This operation selects values along the specified axis using the provided indices. The resulting tensor will have the same shape as the input tensor except along the given axis, where the size will be determined by the indices.

:param axis : Axis along which to gather the elements (default is 0). :type axis : int :param indices : Indices to gather along the axis. :type indices : List[int] :param gathered_shape : Shape of the gathered result. :type gathered_shape : List[int] :param name : Name of the node (optional). :type name : str :return : A node containing the Gather operator. :rtype : GatherOp

std::shared_ptr<Node> Aidge::Gather(std::int8_t axis = 0, const std::vector<int64_t> &indices = {}, const std::vector<DimSize_t> &gatheredShape = {}, const std::string &name = "")#

Create a Gather node.

Initializes a Gather node that extracts elements from an input tensor along a specified axis using a set of indices.

Parameters:
  • axis[in] The axis along which to gather elements. Default is 0.

  • indices[in] A vector specifying which elements to gather. Default is an empty vector.

  • gatheredShape[in] The shape of the resulting gathered tensor. Default is an empty vector.

  • name[in] Optional. The name of the node.

Returns:

A shared pointer to a Node representing the Gather operation.

Identity#

aidge_core.Identity(name: str = '') aidge_core.aidge_core.Node#

Creates an Identity operation, which returns the input as-is.

Parameters:

name – Name of the node.

std::shared_ptr<Node> Aidge::Identity(const std::string &name = "")#

LeakyReLU#

        %%{init: {'flowchart': { 'curve': 'monotoneY'}, 'fontFamily': 'Verdana' } }%%
graph TD

    Op("<b>LeakyReLUOp</b>
    
    
    "):::operator

    In0[data_input]:::text-only -->|"In[0]"| Op
    

    Op -->|"Out[0]"| Out0[data_output]:::text-only
    

    classDef text-only fill-opacity:0, stroke-opacity:0;

    classDef operator stroke-opacity:0;
    
aidge_core.LeakyReLU(negative_slope: float = 0.0, name: str = '') aidge_core.aidge_core.Node#

Create a LeakyReLU node with a specified negative slope.

Parameters:
  • negative_slope – The slope for the negative part of the function. Defaults to 0.0.

  • name – The name of the node.

std::shared_ptr<Node> Aidge::LeakyReLU(float negativeSlope = 0.0f, const std::string &name = "")#

Apply the LeakyReLU activation function to a tensor.

Parameters:
  • negativeSlope[in] Slope for the negative input values.

  • name[in] Name of the Operator.

Returns:

std::shared_ptr<Node> Node containing the Operator.

MatMul#

        %%{init: {'flowchart': { 'curve': 'monotoneY'}, 'fontFamily': 'Verdana' } }%%
graph TD

    Op("<b>MatMulOp</b>
    
    
    "):::operator

    In0[data_input1]:::text-only -->|"In[0]"| Op
    In1[data_input2]:::text-only -->|"In[1]"| Op
    

    Op -->|"Out[0]"| Out0[data_output]:::text-only
    

    classDef text-only fill-opacity:0, stroke-opacity:0;

    classDef operator stroke-opacity:0;
    
aidge_core.MatMul(name: str = '') aidge_core.aidge_core.Node#

Initialize a node containing an MatMul operator that performs Matrix Multiplication between two tensors. The operation is defined as:

Output = Input1 @ Input2

This operator implements generalized matrix multiplication, supporting batched matrix multiplication and broadcasting rules consistent with Numpy. Example:

Input A: (M, K), Input B: (K, N) -> Output: (M, N) Input A: (batch_size, M, K), Input B: (K, N) -> Output: (batch_size, M, N)

Parameters:

name (str) – Optional name of the node.

Returns:

A node containing the MatMul operator.

Return type:

MatMulOp

std::shared_ptr<Node> Aidge::MatMul(const std::string &name = "")#

Memorize#

Not available yet !

std::shared_ptr<Node> Aidge::Memorize(const std::uint32_t endStep, const std::string &name = "")#

Create a Memorize operator node.

Parameters:
  • endStep – The step duration for memory storage.

  • name – The optional name for the node.

Returns:

A shared pointer to the newly created Memorize operator node.

Move#

Not available yet !

std::shared_ptr<Node> Aidge::Move(const std::string &name = "")#

Mul#

aidge_core.Mul(name: str = '') aidge_core.aidge_core.Node#

Initialize a node containing a Mul operator that performs element-wise multiplication.

This operator performs element-wise multiplication between two tensors.

Parameters:

name (str) – Name of the node (optional).

Returns:

A node containing the Mul operator.

Return type:

MulOp

std::shared_ptr<Node> Aidge::Mul(const std::string &name = "")#

Pad#

Not available yet !

Warning

doxygenfunction: Unable to resolve function “Aidge::Pad” with arguments (const std::array<DimSize_t, 2 * DIM>&, const std::string&, const PadBorderType&, double) in doxygen xml output for project “aidge” from directory: xml/. Potential matches:

- template<DimSize_t DIM> std::shared_ptr<Node> Pad(DimSize_t const (&beginEndTuples)[2 * DIM], const std::string &name = "", PadBorderType borderType = PadBorderType::Constant, double borderValue = 0.0)
- template<std::array<DimSize_t, 1>::size_type DIM> std::shared_ptr<Node> Pad(const std::array<DimSize_t, 2 * DIM> &beginEndTuples, const std::string &name = "", PadBorderType borderType = PadBorderType::Constant, double borderValue = 0.0)

Pop#

aidge_core.Pop(name: str = '') aidge_core.aidge_core.Node#
std::shared_ptr<Node> Aidge::Pop(const std::string &name = "")#

Create a Pop operator node.

Parameters:

name – The optional name for the node.

Returns:

A shared pointer to the newly created Pop operator node.

Pow#

aidge_core.Pow(name: str = '') aidge_core.aidge_core.Node#

Initialize a node containing an Pow operator that performs element-wise power between two tensors. The operation is defined as:

Output = Input1 ^ Input2

The output tensor shape is determined by taking the maximum size along each dimension of the input tensors after broadcasting. Examples:

Input A: (3, 4, 2), Input B: (2), Output: (3, 4, 2) Input A: (1, 5, 3), Input B: (2, 1, 3), Output: (2, 5, 3)

:param name : Name of the node (optional). :type name : str :return: A node containing the Pow operator. :rtype: PowOp

std::shared_ptr<Node> Aidge::Pow(const std::string &name = "")#

Producer#

        %%{init: {'flowchart': { 'curve': 'monotoneY'}, 'fontFamily': 'Verdana' } }%%
graph TD

    Op("<b>ProducerOp</b>
    
    
    "):::operator

    

    Op -->|"Out[0]"| Out0[data_output]:::text-only
    

    classDef text-only fill-opacity:0, stroke-opacity:0;

    classDef operator stroke-opacity:0;
    
aidge_core.Producer(*args, **kwargs)#

Overloaded function.

  1. Producer(tensor: aidge_core.aidge_core.Tensor, name: str = ‘’, constant: bool = False) -> aidge_core.aidge_core.Node

  2. Producer(dims: List[int[1]], name: str = ‘’, constant: bool = False) -> aidge_core.aidge_core.Node

  3. Producer(dims: List[int[2]], name: str = ‘’, constant: bool = False) -> aidge_core.aidge_core.Node

  4. Producer(dims: List[int[3]], name: str = ‘’, constant: bool = False) -> aidge_core.aidge_core.Node

  5. Producer(dims: List[int[4]], name: str = ‘’, constant: bool = False) -> aidge_core.aidge_core.Node

  6. Producer(dims: List[int[5]], name: str = ‘’, constant: bool = False) -> aidge_core.aidge_core.Node

  7. Producer(dims: List[int[6]], name: str = ‘’, constant: bool = False) -> aidge_core.aidge_core.Node

std::shared_ptr<Node> Aidge::Producer(const std::shared_ptr<Tensor> tensor, const std::string &name = "", bool constant = false)#
template<std::size_t DIM>
std::shared_ptr<Node> Aidge::Producer(const std::array<DimSize_t, DIM> &dims, const std::string &name = "", bool constant = false)#

Helper function to create a producer node with specified dimensions.

Template Parameters:

DIM – The number of dimensions.

Parameters:
  • dims[in] Array defining the dimensions of the tensor.

  • name[in] Optional name for the node.

  • constant[in] Indicates whether the tensor should be constant.

Returns:

A shared pointer to the created node.

ReduceMean#

aidge_core.ReduceMean(axes: List[int] = [], keep_dims: bool = True, noop_with_empty_axes: bool = False, name: str = '') aidge_core.aidge_core.Node#
Initialize a node containing a ReduceMean operator.
param axes:

Axes along which to do the reduction. The accepted range is [-r, r-1], where r is the rank of the input tensor.

type axes:

List[int]

param keepdims:

If True (default), retains the reduced dimensions with size 1. If False, the reduced dimensions are removed.

type keepdims:

bool

param noop_with_empty_axes:

If True, the operator just copies the input,

if False, the operatpr reduces all the dimensions.
type noop_with_empty_axes:

bool

:param name : name of the node.

std::shared_ptr<Node> Aidge::ReduceMean(const std::vector<std::int32_t> &axes, bool keep_dims = true, bool noop_with_empty_axes = false, const std::string &name = "")#

Compute the mean value of a Tensor over the specified axes.

Dimensions may be reduced by erasing the specified axes or retaining them with size 1.

Parameters:
  • axes[in] Dimensions over which data mean should be computed.

  • keep_dims[in] Whether or not reduced dimensions are to be retained.

  • noop_with_empty_axes[in] Behavior when no axes are specified.

  • name[in] Name of the Operator.

Returns:

std::shared_ptr<Node> Node containing the Operator.

ReLU#

        %%{init: {'flowchart': { 'curve': 'monotoneY'}, 'fontFamily': 'Verdana' } }%%
graph TD

    Op("<b>ReLUOp</b>
    
    
    "):::operator

    In0[data_input]:::text-only -->|"In[0]"| Op
    

    Op -->|"Out[0]"| Out0[data_output]:::text-only
    

    classDef text-only fill-opacity:0, stroke-opacity:0;

    classDef operator stroke-opacity:0;
    
aidge_core.ReLU(name: str = '') aidge_core.aidge_core.Node#

Initialize a node containing a ReLU operator that applies the ReLU function element-wise.

The ReLU function is applied element-wise and is defined as:

ReLU(x) = max(0, x)

The operation sets all negative values to zero and leaves positive values unchanged.

Parameters:

name (str) – Name of the node (optional).

Returns:

A node containing the ReLU operator.

Return type:

ReLUOp

std::shared_ptr<Node> Aidge::ReLU(const std::string &name = "")#

Reshape#

aidge_core.Reshape(shape: List[int] = [], allowzero: bool = False, name: str = '') aidge_core.aidge_core.Node#

Initialize a node containing a Reshape operator.

This operator reshapes the input tensor to the specified shape. The shape should be provided as a list of integers, where values are between [-r; r-1], with r = input_tensor.nbDims(), representing the dimensions of the input tensor. The operator also has a flag for allowing zero-size dimensions.

Parameters:
  • shape (List[int]) – The target shape to reshape the tensor to.

  • allowzero (bool) – Whether to allow zero-size dimensions.

  • name (str) – Name of the node (optional).

Returns:

A node containing the Reshape operator.

Return type:

ReshapeOp

std::shared_ptr<Node> Aidge::Reshape(const std::vector<std::int64_t> &shape = {}, bool allowzero = false, const std::string &name = "")#

Create a Reshape operation node.

Parameters:
  • shape[in] Target shape for the output tensor (optional).

  • allowzero[in] Whether zeros in the shape retain input tensor dimensions.

  • name[in] Name of the operator (optional).

Returns:

A shared pointer to the Node containing the Reshape operator.

Scaling#

Not available yet !

std::shared_ptr<Node> Aidge::Scaling(float scalingFactor = 1.0f, std::size_t quantizedNbBits = 8, bool isOutputUnsigned = true, const std::string &name = "")#

Apply a scaling and quantization operation on a tensor.

Parameters:
  • scalingFactor[in] Scaling factor to apply to the input tensor.

  • quantizedNbBits[in] Number of bits for quantization.

  • isOutputUnsigned[in] Whether the quantized output should be unsigned.

  • name[in] Name of the Operator.

Returns:

std::shared_ptr<Node> Node containing the Operator.

Sigmoid#

aidge_core.Sigmoid(name: str = '') aidge_core.aidge_core.Node#

Initialize a node containing a Sigmoid operator that applies the Sigmoid function element-wise.

The Sigmoid function is applied element-wise and is defined as:

Sigmoid(x) = 1 / (1 + exp(-x))

This operation squashes each value of the tensor into the range (0, 1), making it commonly used for activation functions in neural networks.

Parameters:

name (str) – Name of the node (optional).

Returns:

A node containing the Sigmoid operator.

Return type:

SigmoidOp

std::shared_ptr<Node> Aidge::Sigmoid(const std::string &name = "")#

Slice#

aidge_core.Slice(starts: List[int] = [], ends: List[int] = [], axes: List[int] = [], steps: List[int] = [], name: str = '') aidge_core.aidge_core.Node#

Initialize a node containing a Slice operator that slices a tensor along specified axes.

The slicing is done by specifying the starts, ends, axes, and steps for each axis. The accepted range for each of the starts and ends is [-r, r-1], where r is the rank of the input tensor. The axes specify which axes to apply the slice on. The steps specify the step size along each axis. If steps is not provided, it defaults to 1.

Parameters:
  • starts (List[int]) – The start indices for the slice along each axis. The accepted range is [-r, r-1].

  • ends (List[int]) – The end indices for the slice along each axis. The accepted range is [-r, r-1], exclusive at the end index.

  • axes (List[int]) – The axes along which to slice the tensor. If not specified, slices all axes.

  • steps (List[int]) – The step size for each axis in the slice. Defaults to 1.

  • name (str) – Name of the node (optional).

Returns:

A node containing the Slice operator.

Return type:

SliceOp

std::shared_ptr<Node> Aidge::Slice(const std::vector<std::int64_t> &starts = {}, const std::vector<std::int64_t> &ends = {}, const std::vector<std::int8_t> &axes = {}, const std::vector<std::int64_t> &steps = {}, const std::string &name = "")#

Extract a sub-Tensor from a bigger original Tensor.

Parameters:
  • starts[in] Starting indices for the slice.

  • ends[in] Ending indices (exclusive) for the slice.

  • axes[in] Axes along which the slice operation is performed.

  • steps[in] Step sizes for slicing along each axis.

  • name[in] Name of the Operator.

Returns:

std::shared_ptr<Node> A Node containing the Operator.

Softmax#

        %%{init: {'flowchart': { 'curve': 'monotoneY'}, 'fontFamily': 'Verdana' } }%%
graph TD

    Op("<b>SoftmaxOp</b>
    
    
    "):::operator

    In0[data_input]:::text-only -->|"In[0]"| Op
    

    Op -->|"Out[0]"| Out0[data_output]:::text-only
    

    classDef text-only fill-opacity:0, stroke-opacity:0;

    classDef operator stroke-opacity:0;
    
aidge_core.Softmax(axis: int, name: str = '') aidge_core.aidge_core.Node#

Initialize a node containing a Softmax operator that computes the softmax along the specified axis.

Parameters:
  • axis (int) – Axis along which to compute the softmax. The accepted range is [-r, r-1], where r is the rank (number of dimensions) of the input tensor.

  • name (str) – Name of the node (optional).

Returns:

A node containing the Softmax operator.

Return type:

SoftmaxOp

std::shared_ptr<Node> Aidge::Softmax(std::int32_t axis, const std::string &name = "")#

Create a Softmax operation node.

Parameters:
  • axis[in] Axis along which the softmax operation is applied.

  • name[in] Name of the operator (optional).

Returns:

A shared pointer to the Node containing the Softmax operator.

Sqrt#

aidge_core.Sqrt(name: str = '') aidge_core.aidge_core.Node#

Initialize a node containing a Square Root operator that computes the element-wise square root of the input tensor. The input tensor values must be non-negative for the square root to be computed.

:param name : The name of the node (optional). :type name : str :return : A node containing the Sqrt operator. :rtype : SqrtOp

std::shared_ptr<Node> Aidge::Sqrt(const std::string &name = "")#

Sub#

aidge_core.Sub(name: str = '') aidge_core.aidge_core.Node#

Initialize a node containing a Subtraction operator that performs element-wise subtraction between two tensors. The operation is defined as:

Output = Input1 - Input2

The output tensor shape is determined by taking the maximum size along each dimension of the input tensors after broadcasting. Examples:

Input A: (3, 4, 2), Input B: (2), Output: (3, 4, 2) Input A: (1, 5, 3), Input B: (2, 1, 3), Output: (2, 5, 3)

:param name : Name of the node (optional). :type name : str :return: A node containing the Sub operator. :rtype: SubOp

std::shared_ptr<Node> Aidge::Sub(const std::string &name = "")#

Tanh#

aidge_core.Tanh(name: str = '') aidge_core.aidge_core.Node#

Initialize a node containing a Tanh operator that applies the tanh function element-wise.

The tanh function is applied element-wise, and the operation is defined as:

tanh(x) = (exp(x) - exp(-x)) / (exp(x) + exp(-x))

Parameters:

name (str) – Name of the node (optional).

Returns:

A node containing the Tanh operator.

Return type:

TanhOp

std::shared_ptr<Node> Aidge::Tanh(const std::string &name = "")#

Transpose#

aidge_core.Transpose(output_dims_order: List[int] = [], name: str = '') aidge_core.aidge_core.Node#
Initialize a node containing a transpose operator.
:param output_dims_orderaxes permutation order, must be of rank = r and values between [0;r-1]

with r = input_tensor.nbDims()

:type output_dims_order : :py:class: List[Int]

:param name : name of the node.

std::shared_ptr<Node> Aidge::Transpose(const std::vector<DimSize_t> &outputDimsOrder = {}, const std::string &name = "")#

Create a Transpose operation node.

Parameters:
  • outputDimsOrder[in] Axes permutation order (optional).

  • name[in] Name of the operator (optional).

Returns:

A shared pointer to the Node containing the Transpose operator.

Predefined meta-operators#

Some meta-operators (or composite operators) are predefined for conveniance and/or for compatibility with others frameworks.

PaddedConv#

aidge_core.PaddedConv2D(in_channels: int, out_channels: int, kernel_dims: List[int], name: str = '', stride_dims: List[int] = [1, 1], padding_dims: List[int] = [0, 0, 0, 0], dilation_dims: List[int] = [1, 1], no_bias: bool = False) aidge_core.aidge_core.Node#
template<DimSize_t DIM>
std::shared_ptr<Node> Aidge::PaddedConv(DimSize_t in_channels, DimSize_t out_channels, DimSize_t const (&kernel_dims)[DIM], const std::string &name = "", const std::array<DimSize_t, DIM> &stride_dims = create_array<DimSize_t, DIM>(1), const std::array<DimSize_t, 2 * DIM> &padding_dims = create_array<DimSize_t, 2 * DIM>(0), const std::array<DimSize_t, DIM> &dilation_dims = create_array<DimSize_t, DIM>(1), bool no_bias = false)#

PaddedConvDepthWise#

aidge_core.PaddedConvDepthWise2D(nb_channels: int, kernel_dims: List[int], name: str = '', stride_dims: List[int] = [1, 1], padding_dims: List[int] = [0, 0, 0, 0], dilation_dims: List[int] = [1, 1], no_bias: bool = False) aidge_core.aidge_core.Node#
template<std::array<DimSize_t, 1>::size_type DIM>
std::shared_ptr<Node> Aidge::PaddedConvDepthWise(const DimSize_t nb_channels, const std::array<DimSize_t, DIM> &kernel_dims, const std::string &name = "", const std::array<DimSize_t, DIM> &stride_dims = create_array<DimSize_t, DIM>(1), const std::array<DimSize_t, 2 * DIM> &padding_dims = create_array<DimSize_t, 2 * DIM>(0), const std::array<DimSize_t, DIM> &dilation_dims = create_array<DimSize_t, DIM>(1), bool no_bias = false)#

Creates a padded depthwise convolution operation (Conv2DDepthwise/Conv3DDepthwise).

This function creates a depthwise convolution operation with padding, where each input channel has its own filter.

Parameters:
  • nb_channels[in] The number of input/output channels (same for depthwise convolution).

  • kernel_dims[in] The dimensions of the convolution kernel.

  • name[in] Optional name for the operation.

  • stride_dims[in] The stride dimensions for the convolution operation (default is 1).

  • padding_dims[in] The padding dimensions to apply before convolution (default is 0).

  • dilation_dims[in] Dilation factor for convolution (default is 1).

  • no_bias[in] Whether to disable the bias (default is false).

Returns:

A shared pointer to the Node representing the padded depthwise convolution operation.

PaddedAvgPooling#

aidge_core.PaddedAvgPooling2D(kernel_dims: List[int], name: str = '', stride_dims: List[int] = [1, 1], padding_dims: List[int] = [0, 0, 0, 0]) aidge_core.aidge_core.Node#
template<DimSize_t DIM>
std::shared_ptr<Node> Aidge::PaddedAvgPooling(DimSize_t const (&kernel_dims)[DIM], const std::string &name = "", const std::array<DimSize_t, DIM> &stride_dims = create_array<DimSize_t, DIM>(1), const std::array<DimSize_t, 2 * DIM> &padding_dims = create_array<DimSize_t, 2 * DIM>(0))#

PaddedMaxPooling#

aidge_core.PaddedMaxPooling2D(kernel_dims: List[int], name: str = '', stride_dims: List[int] = [1, 1], padding_dims: List[int] = [0, 0, 0, 0], ceil_mode: bool = False) aidge_core.aidge_core.Node#
template<std::array<DimSize_t, 1>::size_type DIM>
inline std::shared_ptr<Node> Aidge::PaddedMaxPooling(const std::array<DimSize_t, DIM> &kernel_dims, const std::string &name = "", const std::array<DimSize_t, DIM> &stride_dims = create_array<DimSize_t, DIM>(1), const std::array<DimSize_t, 2 * DIM> &padding_dims = create_array<DimSize_t, 2 * DIM>(0), bool ceil_mode = false)#

Creates a padded max pooling operation.

This function creates a max pooling operation with padding before pooling.

Parameters:
  • kernel_dims[in] The dimensions of the pooling window.

  • name[in] Optional name for the operation.

  • stride_dims[in] The stride dimensions for pooling (default is 1).

  • padding_dims[in] Padding dimensions before pooling (default is 0).

  • ceil_mode[in] Whether to use ceiling mode for pooling (default is false).

Returns:

A shared pointer to the Node representing the padded max pooling operation.

LSTM#

aidge_core.LSTM(in_channels: int, hidden_channels: int, seq_length: int, nobias: bool = False, name: str = '') aidge_core.aidge_core.Node#
std::shared_ptr<Node> Aidge::LSTM(DimSize_t in_channels, DimSize_t hidden_channels, DimSize_t seq_length, bool noBias = false, const std::string &name = "")#

Creates an LSTM (Long Short-Term Memory) operator.

This function creates an LSTM operation which is a popular recurrent neural network (RNN) layer for sequence processing.

Parameters:
  • in_channels[in] The number of input channels.

  • hidden_channels[in] The number of hidden channels in the LSTM.

  • seq_length[in] The length of the input sequence.

  • noBias[in] Whether to disable the bias (default is false).

  • name[in] Optional name for the operation.

Returns:

A shared pointer to the Node representing the LSTM operation.