Skip to content
Snippets Groups Projects
Commit 9b357959 authored by Cyril Moineau's avatar Cyril Moineau
Browse files

Move declaration enumstring attr for clang compatibility.

parent 629ed0d9
No related branches found
No related tags found
1 merge request!333[Fix] Attribute snake case
Pipeline #65772 failed
Showing
with 218 additions and 198 deletions
...@@ -41,20 +41,28 @@ enum class ArgMaxAttr { ...@@ -41,20 +41,28 @@ enum class ArgMaxAttr {
*/ */
SelectLastIndex SelectLastIndex
}; };
} // namespace Aidge
/**
* @brief Provides string representations for the ArgMaxAttr enumeration.
*/
namespace {
template <>
const char *const EnumStrings<Aidge::ArgMaxAttr>::data[] = {"axis", "keep_dims", "select_last_index"};
}
namespace Aidge {
/** /**
* @brief Description of the ArgMax operation on a Tensor. * @brief Description of the ArgMax operation on a Tensor.
* *
* The ArgMax operation identifies the index of the maximum value along a specified axis of a Tensor. * The ArgMax operation identifies the index of the maximum value along a specified axis of a Tensor.
* *
* The output of the ArgMax operation can retain the dimensionality of the input Tensor or reduce * The output of the ArgMax operation can retain the dimensionality of the input Tensor or reduce
* it by removing the specified axis. Additionally, in cases where multiple maximum values exist, * it by removing the specified axis. Additionally, in cases where multiple maximum values exist,
* the user can specify whether to select the first or the last occurrence of the maximum value. * the user can specify whether to select the first or the last occurrence of the maximum value.
* *
* Attributes: * Attributes:
* - `Axis`: The axis along which the ArgMax operation is performed. For example, if the axis is `0`, * - `Axis`: The axis along which the ArgMax operation is performed. For example, if the axis is `0`,
* the operation is applied along rows; if it is `1`, it is applied along columns. * the operation is applied along rows; if it is `1`, it is applied along columns.
* - `KeepDims`: A boolean indicating whether to retain the reduced axis as a dimension of size `1` * - `KeepDims`: A boolean indicating whether to retain the reduced axis as a dimension of size `1`
* (`true`) or to completely remove it (`false`). * (`true`) or to completely remove it (`false`).
* - `SelectLastIndex`: A boolean indicating how to handle ties (multiple maximum values along the axis): * - `SelectLastIndex`: A boolean indicating how to handle ties (multiple maximum values along the axis):
* - If `true`, the last index of the maximum value is selected. * - If `true`, the last index of the maximum value is selected.
...@@ -183,7 +191,7 @@ public: ...@@ -183,7 +191,7 @@ public:
* @return A vector containing the attributes name. * @return A vector containing the attributes name.
*/ */
static const char* const* attributesName(){ static const char* const* attributesName(){
return EnumStrings<Aidge::ArgMaxAttr>::data; return EnumStrings<Aidge::ArgMaxAttr>::data;
} }
}; };
...@@ -206,12 +214,6 @@ std::shared_ptr<Node> ArgMax(std::int32_t axis = 0, ...@@ -206,12 +214,6 @@ std::shared_ptr<Node> ArgMax(std::int32_t axis = 0,
} // namespace Aidge } // namespace Aidge
/**
* @brief Provides string representations for the ArgMaxAttr enumeration.
*/
namespace {
template <>
const char *const EnumStrings<Aidge::ArgMaxAttr>::data[] = {"axis", "keep_dims", "select_last_index"};
}
#endif /* AIDGE_CORE_OPERATOR_ARGMAX_H_ */ #endif /* AIDGE_CORE_OPERATOR_ARGMAX_H_ */
...@@ -40,7 +40,18 @@ enum class AvgPoolingAttr { ...@@ -40,7 +40,18 @@ enum class AvgPoolingAttr {
*/ */
KernelDims KernelDims
}; };
} // namespace Aidge
namespace {
/**
* @brief String representation of the AvgPooling attributes.
*/
template <>
const char *const EnumStrings<Aidge::AvgPoolingAttr>::data[] = {
"stride_dims",
"kernel_dims"
};
}
namespace Aidge {
/** /**
* @brief Class representing an Average Pooling operation. * @brief Class representing an Average Pooling operation.
* *
...@@ -181,7 +192,7 @@ public: ...@@ -181,7 +192,7 @@ public:
* @return A vector containing the attributes name. * @return A vector containing the attributes name.
*/ */
static const char* const* attributesName(){ static const char* const* attributesName(){
return EnumStrings<Aidge::AvgPoolingAttr>::data; return EnumStrings<Aidge::AvgPoolingAttr>::data;
} }
}; };
...@@ -224,15 +235,6 @@ extern template class Aidge::AvgPooling_Op<2>; ...@@ -224,15 +235,6 @@ extern template class Aidge::AvgPooling_Op<2>;
extern template class Aidge::AvgPooling_Op<3>; extern template class Aidge::AvgPooling_Op<3>;
extern template class Aidge::AvgPooling_Op<4>; extern template class Aidge::AvgPooling_Op<4>;
namespace {
/**
* @brief String representation of the AvgPooling attributes.
*/
template <>
const char *const EnumStrings<Aidge::AvgPoolingAttr>::data[] = {
"stride_dims",
"kernel_dims"
};
}
#endif /* AIDGE_CORE_OPERATOR_AVGPOOLING_H_ */ #endif /* AIDGE_CORE_OPERATOR_AVGPOOLING_H_ */
...@@ -50,7 +50,12 @@ enum class BatchNormAttr { ...@@ -50,7 +50,12 @@ enum class BatchNormAttr {
*/ */
TrainingMode TrainingMode
}; };
} // namespace Aidge
namespace {
template <>
const char *const EnumStrings<Aidge::BatchNormAttr>::data[] = { "epsilon", "momentum", "training_mode" };
}
namespace Aidge {
/** /**
* @class BatchNorm_Op * @class BatchNorm_Op
* @brief Implements the Batch Normalization (BN) operation, a technique used to normalize the inputs of a layer. * @brief Implements the Batch Normalization (BN) operation, a technique used to normalize the inputs of a layer.
...@@ -158,7 +163,7 @@ public: ...@@ -158,7 +163,7 @@ public:
* @return A vector containing the attributes name. * @return A vector containing the attributes name.
*/ */
static const char* const* attributesName(){ static const char* const* attributesName(){
return EnumStrings<Aidge::BatchNormAttr>::data; return EnumStrings<Aidge::BatchNormAttr>::data;
} }
}; };
...@@ -178,9 +183,4 @@ extern template std::shared_ptr<Aidge::Node> Aidge::BatchNorm<2>(const DimSize_t ...@@ -178,9 +183,4 @@ extern template std::shared_ptr<Aidge::Node> Aidge::BatchNorm<2>(const DimSize_t
extern template std::shared_ptr<Aidge::Node> Aidge::BatchNorm<3>(const DimSize_t, const float, const float, const bool, const std::string&); extern template std::shared_ptr<Aidge::Node> Aidge::BatchNorm<3>(const DimSize_t, const float, const float, const bool, const std::string&);
extern template std::shared_ptr<Aidge::Node> Aidge::BatchNorm<4>(const DimSize_t, const float, const float, const bool, const std::string&); extern template std::shared_ptr<Aidge::Node> Aidge::BatchNorm<4>(const DimSize_t, const float, const float, const bool, const std::string&);
namespace {
template <>
const char *const EnumStrings<Aidge::BatchNormAttr>::data[] = { "epsilon", "momentum", "training_mode" };
}
#endif /* AIDGE_CORE_OPERATOR_BATCHNORM_H_ */ #endif /* AIDGE_CORE_OPERATOR_BATCHNORM_H_ */
...@@ -32,7 +32,15 @@ enum class BitShiftAttr { ...@@ -32,7 +32,15 @@ enum class BitShiftAttr {
*/ */
BitShiftdirection BitShiftdirection
}; };
}
namespace {
/**
* @brief Specialization of `EnumStrings` for `BitShiftAttr`.
*/
template <>
const char* const EnumStrings<Aidge::BitShiftAttr>::data[] = {"bit_shift_direction"};
}
namespace Aidge {
/** /**
* @class BitShift_Op * @class BitShift_Op
* @brief A tensor operator to perform element-wise bitwise shift operations on tensors. * @brief A tensor operator to perform element-wise bitwise shift operations on tensors.
...@@ -169,12 +177,6 @@ inline std::shared_ptr<Node> BitShift(const BitShift_Op::BitShiftDirection direc ...@@ -169,12 +177,6 @@ inline std::shared_ptr<Node> BitShift(const BitShift_Op::BitShiftDirection direc
} // namespace Aidge } // namespace Aidge
namespace {
/**
* @brief Specialization of `EnumStrings` for `BitShiftAttr`.
*/
template <>
const char* const EnumStrings<Aidge::BitShiftAttr>::data[] = {"bit_shift_direction"};
}
#endif /* AIDGE_CORE_OPERATOR_BITSHIFT_H_ */ #endif /* AIDGE_CORE_OPERATOR_BITSHIFT_H_ */
...@@ -40,7 +40,12 @@ enum class CastAttr { ...@@ -40,7 +40,12 @@ enum class CastAttr {
*/ */
TargetType TargetType
}; };
} // namespace Aidge
namespace {
template <>
const char* const EnumStrings<Aidge::CastAttr>::data[] = { "target_type" };
}
namespace Aidge {
/** /**
* @brief Description of the Cast operation to convert a tensor's data type. * @brief Description of the Cast operation to convert a tensor's data type.
* *
...@@ -143,7 +148,7 @@ public: ...@@ -143,7 +148,7 @@ public:
* @return A vector containing the attributes name. * @return A vector containing the attributes name.
*/ */
static const char* const* attributesName(){ static const char* const* attributesName(){
return EnumStrings<Aidge::CastAttr>::data; return EnumStrings<Aidge::CastAttr>::data;
} }
}; };
...@@ -157,9 +162,4 @@ std::shared_ptr<Node> Cast(const DataType targetType, const std::string& name = ...@@ -157,9 +162,4 @@ std::shared_ptr<Node> Cast(const DataType targetType, const std::string& name =
} // namespace Aidge } // namespace Aidge
namespace {
template <>
const char* const EnumStrings<Aidge::CastAttr>::data[] = { "target_type" };
}
#endif /* AIDGE_CORE_OPERATOR_CAST_H_ */ #endif /* AIDGE_CORE_OPERATOR_CAST_H_ */
...@@ -33,14 +33,23 @@ enum class ClipAttr { ...@@ -33,14 +33,23 @@ enum class ClipAttr {
Min, /**< Minimum value for clipping. */ Min, /**< Minimum value for clipping. */
Max /**< Maximum value for clipping. */ Max /**< Maximum value for clipping. */
}; };
}
namespace {
/**
* @brief Specialization of EnumStrings for ClipAttr.
*/
template <>
const char* const EnumStrings<Aidge::ClipAttr>::data[] = { "min", "max" };
}
namespace Aidge {
/** /**
* @brief Description of the Clip operation to limit tensor values within a specified range. * @brief Description of the Clip operation to limit tensor values within a specified range.
* *
* The Clip operator ensures tensor elements are within the range `[min, max]`. * The Clip operator ensures tensor elements are within the range `[min, max]`.
* - Values less than `min` are set to `min`. * - Values less than `min` are set to `min`.
* - Values greater than `max` are set to `max`. * - Values greater than `max` are set to `max`.
* *
* The input and output Tensors have the same dimensions. * The input and output Tensors have the same dimensions.
* *
* ### Attributes: * ### Attributes:
...@@ -154,7 +163,7 @@ public: ...@@ -154,7 +163,7 @@ public:
* @return A vector containing the attributes name. * @return A vector containing the attributes name.
*/ */
static const char* const* attributesName(){ static const char* const* attributesName(){
return EnumStrings<Aidge::ClipAttr>::data; return EnumStrings<Aidge::ClipAttr>::data;
} }
}; };
...@@ -173,12 +182,4 @@ std::shared_ptr<Aidge::Node> Clip( ...@@ -173,12 +182,4 @@ std::shared_ptr<Aidge::Node> Clip(
} // namespace Aidge } // namespace Aidge
namespace {
/**
* @brief Specialization of EnumStrings for ClipAttr.
*/
template <>
const char* const EnumStrings<Aidge::ClipAttr>::data[] = { "min", "max" };
}
#endif /* AIDGE_CORE_OPERATOR_CLIP_H_ */ #endif /* AIDGE_CORE_OPERATOR_CLIP_H_ */
...@@ -58,7 +58,17 @@ enum class ConcatAttr { ...@@ -58,7 +58,17 @@ enum class ConcatAttr {
*/ */
Axis Axis
}; };
} // namespace Aidge
namespace {
/**
* @brief Specialization of EnumStrings for ConcatAttr.
*/
template <>
const char* const EnumStrings<Aidge::ConcatAttr>::data[] = {
"axis"
};
}
namespace Aidge {
/** /**
* @class Concat_Op * @class Concat_Op
* @brief Implements the Concat operation to concatenate multiple tensors along a specified axis. * @brief Implements the Concat operation to concatenate multiple tensors along a specified axis.
...@@ -175,7 +185,7 @@ public: ...@@ -175,7 +185,7 @@ public:
* @return A vector containing the attributes name. * @return A vector containing the attributes name.
*/ */
static const char* const* attributesName(){ static const char* const* attributesName(){
return EnumStrings<Aidge::ConcatAttr>::data; return EnumStrings<Aidge::ConcatAttr>::data;
} }
}; };
...@@ -190,14 +200,4 @@ std::shared_ptr<Node> Concat(const IOIndex_t nbIn, const std::int32_t axis = 0, ...@@ -190,14 +200,4 @@ std::shared_ptr<Node> Concat(const IOIndex_t nbIn, const std::int32_t axis = 0,
} // namespace Aidge } // namespace Aidge
namespace {
/**
* @brief Specialization of EnumStrings for ConcatAttr.
*/
template <>
const char* const EnumStrings<Aidge::ConcatAttr>::data[] = {
"axis"
};
}
#endif /* AIDGE_CORE_OPERATOR_CONCAT_H_ */ #endif /* AIDGE_CORE_OPERATOR_CONCAT_H_ */
...@@ -40,6 +40,12 @@ enum class ConstantOfShapeAttr { ...@@ -40,6 +40,12 @@ enum class ConstantOfShapeAttr {
Value, Value,
}; };
namespace {
template <>
const char *const EnumStrings<Aidge::ConstantOfShapeAttr>::data[] = {"value"};
}
/** /**
* @brief This operator's purpose is to generate a tensor of shape given via * @brief This operator's purpose is to generate a tensor of shape given via
* input and filled with a given value set via attribute. * input and filled with a given value set via attribute.
...@@ -135,10 +141,5 @@ inline std::shared_ptr<Node> ConstantOfShape(const Tensor value = Tensor(0.f), ...@@ -135,10 +141,5 @@ inline std::shared_ptr<Node> ConstantOfShape(const Tensor value = Tensor(0.f),
} }
} // namespace Aidge } // namespace Aidge
namespace {
template <>
const char *const EnumStrings<Aidge::ConstantOfShapeAttr>::data[] = {"value"};
}
#endif // AIDGE_CORE_OPERATOR_CONSTANT_OF_SHAPE_H_ #endif // AIDGE_CORE_OPERATOR_CONSTANT_OF_SHAPE_H_
...@@ -40,15 +40,24 @@ enum class ConvAttr { ...@@ -40,15 +40,24 @@ enum class ConvAttr {
DilationDims, // The dilation dimensions DilationDims, // The dilation dimensions
KernelDims // The kernel dimensions KernelDims // The kernel dimensions
}; };
} // namespace Aidge
namespace {
template <>
const char *const EnumStrings<Aidge::ConvAttr>::data[] = {
"stride_dims",
"dilation_dims",
"kernel_dims"
};
}
namespace Aidge {
/** /**
* @class Conv_Op * @class Conv_Op
* @brief Convolution operator for performing a multi-dimensional convolution. * @brief Convolution operator for performing a multi-dimensional convolution.
* *
* The Conv_Op class implements a convolution operator for tensors with customizable * The Conv_Op class implements a convolution operator for tensors with customizable
* kernel dimensions, stride, and dilation values. The operator performs a convolution * kernel dimensions, stride, and dilation values. The operator performs a convolution
* operation on the input tensor and produces an output tensor. * operation on the input tensor and produces an output tensor.
* *
* ### Attributes: * ### Attributes:
* - `strideDims`: Stride for each dimension of the input. * - `strideDims`: Stride for each dimension of the input.
* - `dilationDims`: Dilation for each dimension of the input. * - `dilationDims`: Dilation for each dimension of the input.
...@@ -63,7 +72,7 @@ enum class ConvAttr { ...@@ -63,7 +72,7 @@ enum class ConvAttr {
* - Stride dimensions: {1, 1} (stride of 1 in both height and width) * - Stride dimensions: {1, 1} (stride of 1 in both height and width)
* - Dilation dimensions: {1, 1} (no dilation) * - Dilation dimensions: {1, 1} (no dilation)
* - Padding: None * - Padding: None
* - Output shape: * - Output shape:
* (1, 64, (32−3+2×0)/1+1, (32−3+2×0)/1+1) = (1, 64, 30, 30) * (1, 64, (32−3+2×0)/1+1, (32−3+2×0)/1+1) = (1, 64, 30, 30)
* *
* @see OperatorTensor * @see OperatorTensor
...@@ -215,7 +224,7 @@ public: ...@@ -215,7 +224,7 @@ public:
* @return A vector containing the attributes name. * @return A vector containing the attributes name.
*/ */
static const char* const* attributesName(){ static const char* const* attributesName(){
return EnumStrings<Aidge::ConvAttr>::data; return EnumStrings<Aidge::ConvAttr>::data;
} }
}; };
...@@ -268,13 +277,5 @@ inline std::shared_ptr<Node> Conv( ...@@ -268,13 +277,5 @@ inline std::shared_ptr<Node> Conv(
extern template class Aidge::Conv_Op<1>; extern template class Aidge::Conv_Op<1>;
extern template class Aidge::Conv_Op<2>; extern template class Aidge::Conv_Op<2>;
namespace {
template <>
const char *const EnumStrings<Aidge::ConvAttr>::data[] = {
"stride_dims",
"dilation_dims",
"kernel_dims"
};
}
#endif /* AIDGE_CORE_OPERATOR_CONV_H_ */ #endif /* AIDGE_CORE_OPERATOR_CONV_H_ */
...@@ -34,15 +34,24 @@ enum class ConvDepthWiseAttr { ...@@ -34,15 +34,24 @@ enum class ConvDepthWiseAttr {
DilationDims, // The dilation dimensions for the convolution. DilationDims, // The dilation dimensions for the convolution.
KernelDims // The kernel dimensions for the convolution. KernelDims // The kernel dimensions for the convolution.
}; };
} // namespace Aidge
namespace {
template <>
const char *const EnumStrings<Aidge::ConvDepthWiseAttr>::data[] = {
"stride_dims",
"dilation_dims",
"kernel_dims"
};
}
namespace Aidge {
/** /**
* @class ConvDepthWise_Op * @class ConvDepthWise_Op
* @brief Depthwise Convolution operator for performing a multi-dimensional depthwise convolution. * @brief Depthwise Convolution operator for performing a multi-dimensional depthwise convolution.
* *
* The ConvDepthWise_Op class implements a depthwise convolution operator for tensors with customizable * The ConvDepthWise_Op class implements a depthwise convolution operator for tensors with customizable
* kernel dimensions, stride, and dilation values. It performs a depthwise convolution operation on the * kernel dimensions, stride, and dilation values. It performs a depthwise convolution operation on the
* input tensor and produces an output tensor. * input tensor and produces an output tensor.
* *
* ### Attributes: * ### Attributes:
* - strideDims: Stride for each dimension of the input. * - strideDims: Stride for each dimension of the input.
* - dilationDims: Dilation for each dimension of the input. * - dilationDims: Dilation for each dimension of the input.
...@@ -195,7 +204,7 @@ public: ...@@ -195,7 +204,7 @@ public:
* @return A vector containing the attributes name. * @return A vector containing the attributes name.
*/ */
static const char* const* attributesName(){ static const char* const* attributesName(){
return EnumStrings<Aidge::ConvDepthWiseAttr>::data; return EnumStrings<Aidge::ConvDepthWiseAttr>::data;
} }
}; };
...@@ -245,13 +254,4 @@ inline std::shared_ptr<Node> ConvDepthWise( ...@@ -245,13 +254,4 @@ inline std::shared_ptr<Node> ConvDepthWise(
extern template class Aidge::ConvDepthWise_Op<1>; extern template class Aidge::ConvDepthWise_Op<1>;
extern template class Aidge::ConvDepthWise_Op<2>; extern template class Aidge::ConvDepthWise_Op<2>;
namespace {
template <>
const char *const EnumStrings<Aidge::ConvDepthWiseAttr>::data[] = {
"stride_dims",
"dilation_dims",
"kernel_dims"
};
}
#endif /* AIDGE_CORE_OPERATOR_CONVDEPTHWISE_H_ */ #endif /* AIDGE_CORE_OPERATOR_CONVDEPTHWISE_H_ */
...@@ -51,7 +51,12 @@ enum class DepthToSpaceAttr { ...@@ -51,7 +51,12 @@ enum class DepthToSpaceAttr {
BlockSize, /**< The block size for rearranging depth to spatial dimensions. */ BlockSize, /**< The block size for rearranging depth to spatial dimensions. */
Mode /**< The mode for depth-to-space transformation. */ Mode /**< The mode for depth-to-space transformation. */
}; };
} // namespace Aidge
namespace {
template <>
const char *const EnumStrings<Aidge::DepthToSpaceAttr>::data[] = { "block_size", "mode" };
}
namespace Aidge{
/** /**
* @class DepthToSpace_Op * @class DepthToSpace_Op
* @brief Represents the DepthToSpace operation to rearrange data from depth to spatial dimensions. * @brief Represents the DepthToSpace operation to rearrange data from depth to spatial dimensions.
...@@ -170,7 +175,7 @@ public: ...@@ -170,7 +175,7 @@ public:
* @return A vector containing the attributes name. * @return A vector containing the attributes name.
*/ */
static const char* const* attributesName(){ static const char* const* attributesName(){
return EnumStrings<Aidge::DepthToSpaceAttr>::data; return EnumStrings<Aidge::DepthToSpaceAttr>::data;
} }
}; };
...@@ -187,9 +192,5 @@ std::shared_ptr<Node> DepthToSpace(const std::uint32_t blockSize, ...@@ -187,9 +192,5 @@ std::shared_ptr<Node> DepthToSpace(const std::uint32_t blockSize,
} // namespace Aidge } // namespace Aidge
namespace {
template <>
const char *const EnumStrings<Aidge::DepthToSpaceAttr>::data[] = { "block_size", "mode" };
}
#endif //AIDGE_CORE_OPERATOR_DEPTHTOSPACE_H_ #endif //AIDGE_CORE_OPERATOR_DEPTHTOSPACE_H_
...@@ -54,7 +54,12 @@ enum class FlattenAttr { ...@@ -54,7 +54,12 @@ enum class FlattenAttr {
*/ */
Axis Axis
}; };
} // namespace Aidge
namespace {
template <>
const char *const EnumStrings<Aidge::FlattenAttr>::data[] = { "axis" };
}
namespace Aidge {
/** /**
* @brief Description the Flatten operation to reshape a tensor into a 2D matrix. * @brief Description the Flatten operation to reshape a tensor into a 2D matrix.
* *
...@@ -161,7 +166,7 @@ public: ...@@ -161,7 +166,7 @@ public:
* @return A vector containing the attributes name. * @return A vector containing the attributes name.
*/ */
static const char* const* attributesName(){ static const char* const* attributesName(){
return EnumStrings<Aidge::FlattenAttr>::data; return EnumStrings<Aidge::FlattenAttr>::data;
} }
}; };
...@@ -179,9 +184,5 @@ std::shared_ptr<Node> Flatten(std::int64_t axis = 1, ...@@ -179,9 +184,5 @@ std::shared_ptr<Node> Flatten(std::int64_t axis = 1,
const std::string &name = ""); const std::string &name = "");
} // namespace Aidge } // namespace Aidge
namespace {
template <>
const char *const EnumStrings<Aidge::FlattenAttr>::data[] = { "axis" };
}
#endif /* AIDGE_CORE_OPERATOR_FLATTEN_H_ */ #endif /* AIDGE_CORE_OPERATOR_FLATTEN_H_ */
...@@ -64,7 +64,17 @@ enum class FoldAttr { ...@@ -64,7 +64,17 @@ enum class FoldAttr {
*/ */
KernelDims KernelDims
}; };
} // namespace Aidge
namespace {
template <>
const char* const EnumStrings<Aidge::FoldAttr>::data[] = {
"output_dims",
"stride_dims",
"dilation_dims",
"kernel_dims"
};
}
namespace Aidge {
/** /**
* @class Fold_Op * @class Fold_Op
* @brief Implements the Fold operation to combine or transform tensor dimensions. * @brief Implements the Fold operation to combine or transform tensor dimensions.
...@@ -82,7 +92,7 @@ enum class FoldAttr { ...@@ -82,7 +92,7 @@ enum class FoldAttr {
* output height (out_h) = floor((input height - kernel height) / stride height) + 1 * output height (out_h) = floor((input height - kernel height) / stride height) + 1
* output width (out_w) = floor((input width - kernel width) / stride width) + 1 * output width (out_w) = floor((input width - kernel width) / stride width) + 1
* - The exact output shape will depend on these calculations for each spatial dimension (height, width) and the number of output channels. * - The exact output shape will depend on these calculations for each spatial dimension (height, width) and the number of output channels.
* *
* @example: * @example:
* - Input shape: (1, 16, 32, 32) // Batch size: 1, Channels: 16, Height: 32, Width: 32 * - Input shape: (1, 16, 32, 32) // Batch size: 1, Channels: 16, Height: 32, Width: 32
* - Kernel dimensions: (3, 3) // 3x3 kernel * - Kernel dimensions: (3, 3) // 3x3 kernel
...@@ -216,13 +226,13 @@ public: ...@@ -216,13 +226,13 @@ public:
* @return A vector containing the attributes name. * @return A vector containing the attributes name.
*/ */
static const char* const* attributesName(){ static const char* const* attributesName(){
return EnumStrings<Aidge::FoldAttr>::data; return EnumStrings<Aidge::FoldAttr>::data;
} }
}; };
/** /**
* @brief Create a Fold operation node. * @brief Create a Fold operation node.
* *
* This function creates a Fold operation node that applies a fold transformation * This function creates a Fold operation node that applies a fold transformation
* to a tensor based on the specified attributes. * to a tensor based on the specified attributes.
* *
...@@ -255,14 +265,4 @@ extern template class Aidge::Fold_Op<2>; ...@@ -255,14 +265,4 @@ extern template class Aidge::Fold_Op<2>;
} // namespace Aidge } // namespace Aidge
namespace {
template <>
const char* const EnumStrings<Aidge::FoldAttr>::data[] = {
"output_dims",
"stride_dims",
"dilation_dims",
"kernel_dims"
};
}
#endif /* AIDGE_CORE_OPERATOR_FOLD_H_ */ #endif /* AIDGE_CORE_OPERATOR_FOLD_H_ */
...@@ -61,6 +61,12 @@ enum class GatherAttr { ...@@ -61,6 +61,12 @@ enum class GatherAttr {
GatheredShape GatheredShape
}; };
} // namespace Aidge
namespace {
template <>
const char *const EnumStrings<Aidge::GatherAttr>::data[] = {"axis", "indices", "gathered_shape"};
}
namespace Aidge {
/** /**
* @brief Description for the Gather operation on an input tensor. * @brief Description for the Gather operation on an input tensor.
* *
...@@ -190,7 +196,7 @@ public: ...@@ -190,7 +196,7 @@ public:
* @return A vector containing the attributes name. * @return A vector containing the attributes name.
*/ */
static const char* const* attributesName(){ static const char* const* attributesName(){
return EnumStrings<Aidge::GatherAttr>::data; return EnumStrings<Aidge::GatherAttr>::data;
} }
}; };
...@@ -213,9 +219,5 @@ std::shared_ptr<Node> Gather(std::int8_t axis = 0, ...@@ -213,9 +219,5 @@ std::shared_ptr<Node> Gather(std::int8_t axis = 0,
} // namespace Aidge } // namespace Aidge
namespace {
template <>
const char *const EnumStrings<Aidge::GatherAttr>::data[] = {"axis", "indices", "gathered_shape"};
}
#endif /* AIDGE_CORE_OPERATOR_GATHER_H_ */ #endif /* AIDGE_CORE_OPERATOR_GATHER_H_ */
...@@ -29,6 +29,16 @@ enum class GridSampleAttr { ...@@ -29,6 +29,16 @@ enum class GridSampleAttr {
PaddingMode, // Specifies how to handle out-of-boundary grid values. PaddingMode, // Specifies how to handle out-of-boundary grid values.
AlignCorners // Determines whether grid values are normalized to align with the image corners. AlignCorners // Determines whether grid values are normalized to align with the image corners.
}; };
} // namespace Aidge
namespace {
template <>
const char* const EnumStrings<Aidge::GridSampleAttr>::data[] = {
"mode",
"padding_mode",
"align_corners"
};
}
namespace Aidge {
/** /**
* @class GridSample_Op * @class GridSample_Op
...@@ -176,7 +186,7 @@ public: ...@@ -176,7 +186,7 @@ public:
* @return A vector containing the attributes name. * @return A vector containing the attributes name.
*/ */
static const char* const* attributesName(){ static const char* const* attributesName(){
return EnumStrings<Aidge::GridSampleAttr>::data; return EnumStrings<Aidge::GridSampleAttr>::data;
} }
}; };
...@@ -197,13 +207,4 @@ std::shared_ptr<Node> GridSample( ...@@ -197,13 +207,4 @@ std::shared_ptr<Node> GridSample(
} // namespace Aidge } // namespace Aidge
namespace {
template <>
const char* const EnumStrings<Aidge::GridSampleAttr>::data[] = {
"mode",
"padding_mode",
"align_corners"
};
}
#endif /* AIDGE_CORE_OPERATOR_GRIDSAMPLE_H_ */ #endif /* AIDGE_CORE_OPERATOR_GRIDSAMPLE_H_ */
...@@ -31,6 +31,15 @@ enum class HeavisideAttr { ...@@ -31,6 +31,15 @@ enum class HeavisideAttr {
*/ */
Value Value
}; };
} // namespace Aidge
namespace {
/**
* @brief Define string representations for Heaviside attributes.
*/
template <>
const char *const EnumStrings<Aidge::HeavisideAttr>::data[] = {"value"};
}
namespace Aidge {
/** /**
* @class Heaviside_Op * @class Heaviside_Op
...@@ -115,7 +124,7 @@ public: ...@@ -115,7 +124,7 @@ public:
* @return A vector containing the attributes name. * @return A vector containing the attributes name.
*/ */
static const char* const* attributesName(){ static const char* const* attributesName(){
return EnumStrings<Aidge::HeavisideAttr>::data; return EnumStrings<Aidge::HeavisideAttr>::data;
} }
/** /**
...@@ -149,12 +158,5 @@ std::shared_ptr<Node> Heaviside(float value, const std::string &name = ""); ...@@ -149,12 +158,5 @@ std::shared_ptr<Node> Heaviside(float value, const std::string &name = "");
} // namespace Aidge } // namespace Aidge
namespace {
/**
* @brief Define string representations for Heaviside attributes.
*/
template <>
const char *const EnumStrings<Aidge::HeavisideAttr>::data[] = {"value"};
}
#endif /* AIDGE_CORE_OPERATOR_HEAVISIDE_H_ */ #endif /* AIDGE_CORE_OPERATOR_HEAVISIDE_H_ */
...@@ -30,20 +30,28 @@ enum class LRNAttr { ...@@ -30,20 +30,28 @@ enum class LRNAttr {
Bias, ///< Constant bias added to the normalization term. Bias, ///< Constant bias added to the normalization term.
Size ///< Number of channels to normalize over. Size ///< Number of channels to normalize over.
}; };
} // namespace Aidge
namespace {
/**
* @brief EnumStrings specialization for LRNAttr.
*/
template <>
const char *const EnumStrings<Aidge::LRNAttr>::data[] = {"alpha", "beta", "bias", "size", nullptr};
}
namespace Aidge {
/** /**
* @brief Description of a Local Response Normalization (LRN) operation on an input Tensor. * @brief Description of a Local Response Normalization (LRN) operation on an input Tensor.
* *
* LRN is a normalization technique that applies across channels in a local region * LRN is a normalization technique that applies across channels in a local region
* to enhance generalization and promote competition between neurons. It is commonly * to enhance generalization and promote competition between neurons. It is commonly
* used in Convolutional Neural Networks (CNNs). * used in Convolutional Neural Networks (CNNs).
* *
* For each element x in the input Tensor, the function is defined as: * For each element x in the input Tensor, the function is defined as:
* `f(x) = x / (bias + alpha * sum(x_i^2))^beta`, where: * `f(x) = x / (bias + alpha * sum(x_i^2))^beta`, where:
* - `x` is the current element being normalized. * - `x` is the current element being normalized.
* - The summation `sum(x_i^2)` is taken over a local region of `size` channels * - The summation `sum(x_i^2)` is taken over a local region of `size` channels
* surrounding `x` (both before and after the current channel, if available). * surrounding `x` (both before and after the current channel, if available).
* - `bias`, `alpha`, and `beta` are scalar hyperparameters controlling the * - `bias`, `alpha`, and `beta` are scalar hyperparameters controlling the
* normalization behavior. * normalization behavior.
* *
* Parameters: * Parameters:
...@@ -52,7 +60,7 @@ enum class LRNAttr { ...@@ -52,7 +60,7 @@ enum class LRNAttr {
* - `alpha`: A scaling factor for the squared sum of elements in the local region. * - `alpha`: A scaling factor for the squared sum of elements in the local region.
* - `beta`: The exponent applied to the normalization term. * - `beta`: The exponent applied to the normalization term.
* *
* The input and output Tensors have the same shape. If the input Tensor has shape `(N, C, H, W)`, * The input and output Tensors have the same shape. If the input Tensor has shape `(N, C, H, W)`,
* the output Tensor will also have shape `(N, C, H, W)`. * the output Tensor will also have shape `(N, C, H, W)`.
* *
* @see OperatorTensor * @see OperatorTensor
...@@ -164,7 +172,7 @@ public: ...@@ -164,7 +172,7 @@ public:
* @return A vector containing the attributes name. * @return A vector containing the attributes name.
*/ */
static const char* const* attributesName(){ static const char* const* attributesName(){
return EnumStrings<Aidge::LRNAttr>::data; return EnumStrings<Aidge::LRNAttr>::data;
} }
}; };
...@@ -179,12 +187,4 @@ std::shared_ptr<Node> LRN(std::int32_t size, const std::string& name = ""); ...@@ -179,12 +187,4 @@ std::shared_ptr<Node> LRN(std::int32_t size, const std::string& name = "");
} // namespace Aidge } // namespace Aidge
namespace {
/**
* @brief EnumStrings specialization for LRNAttr.
*/
template <>
const char *const EnumStrings<Aidge::LRNAttr>::data[] = {"alpha", "beta", "bias", "size", nullptr};
}
#endif /* AIDGE_CORE_OPERATOR_LRN_H_ */ #endif /* AIDGE_CORE_OPERATOR_LRN_H_ */
...@@ -30,7 +30,13 @@ enum class LeakyReLUAttr { ...@@ -30,7 +30,13 @@ enum class LeakyReLUAttr {
*/ */
NegativeSlope NegativeSlope
}; };
} // namespace Aidge
namespace {
template <>
const char* const EnumStrings<Aidge::LeakyReLUAttr>::data[]
= {"negative_slope"};
}
namespace Aidge{
/** /**
* @class LeakyReLU_Op * @class LeakyReLU_Op
* @brief Implements the LeakyReLU activation function. * @brief Implements the LeakyReLU activation function.
...@@ -77,7 +83,7 @@ public: ...@@ -77,7 +83,7 @@ public:
/** /**
* @brief Copy-constructor. * @brief Copy-constructor.
* @param[in] op LeakyReLU_Op to copy. * @param[in] op LeakyReLU_Op to copy.
* @details Copies the operator attributes and its output tensor(s), but not its input tensors. * @details Copies the operator attributes and its output tensor(s), but not its input tensors.
* The new operator has no associated input. * The new operator has no associated input.
*/ */
LeakyReLU_Op(const LeakyReLU_Op& op); LeakyReLU_Op(const LeakyReLU_Op& op);
...@@ -121,7 +127,7 @@ public: ...@@ -121,7 +127,7 @@ public:
* @return A vector containing the attributes name. * @return A vector containing the attributes name.
*/ */
static const char* const* attributesName(){ static const char* const* attributesName(){
return EnumStrings<Aidge::LeakyReLUAttr>::data; return EnumStrings<Aidge::LeakyReLUAttr>::data;
} }
}; };
...@@ -135,10 +141,4 @@ public: ...@@ -135,10 +141,4 @@ public:
std::shared_ptr<Node> LeakyReLU(float negativeSlope = 0.0f, const std::string& name = ""); std::shared_ptr<Node> LeakyReLU(float negativeSlope = 0.0f, const std::string& name = "");
} }
namespace {
template <>
const char* const EnumStrings<Aidge::LeakyReLUAttr>::data[]
= {"negative_slope"};
}
#endif /* AIDGE_CORE_OPERATOR_LEAKYRELU_H_ */ #endif /* AIDGE_CORE_OPERATOR_LEAKYRELU_H_ */
...@@ -56,6 +56,16 @@ enum class MaxPoolingAttr { ...@@ -56,6 +56,16 @@ enum class MaxPoolingAttr {
*/ */
CeilMode, CeilMode,
}; };
} // namespace Aidge
namespace {
/**
* @brief String representations of MaxPooling attributes for debugging and logging.
*/
template <>
const char *const EnumStrings<Aidge::MaxPoolingAttr>::data[] = {"stride_dims", "kernel_dims", "ceil_mode"};
}
namespace Aidge{
/** /**
* @class MaxPooling_Op * @class MaxPooling_Op
...@@ -188,7 +198,7 @@ public: ...@@ -188,7 +198,7 @@ public:
* @return A vector containing the attributes name. * @return A vector containing the attributes name.
*/ */
static const char* const* attributesName(){ static const char* const* attributesName(){
return EnumStrings<Aidge::MaxPoolingAttr>::data; return EnumStrings<Aidge::MaxPoolingAttr>::data;
} }
}; };
...@@ -235,12 +245,5 @@ inline std::shared_ptr<Node> MaxPooling( ...@@ -235,12 +245,5 @@ inline std::shared_ptr<Node> MaxPooling(
} // namespace Aidge } // namespace Aidge
namespace {
/**
* @brief String representations of MaxPooling attributes for debugging and logging.
*/
template <>
const char *const EnumStrings<Aidge::MaxPoolingAttr>::data[] = {"stride_dims", "kernel_dims", "ceil_mode"};
}
#endif /* AIDGE_CORE_OPERATOR_MAXPOOLING_H_ */ #endif /* AIDGE_CORE_OPERATOR_MAXPOOLING_H_ */
...@@ -120,10 +120,22 @@ enum class MemorizeAttr { ...@@ -120,10 +120,22 @@ enum class MemorizeAttr {
ForwardStep, // Tracks the current step in the forward pass. ForwardStep, // Tracks the current step in the forward pass.
EndStep // The final step for which memory updates will occur. EndStep // The final step for which memory updates will occur.
}; };
} // namespace Aidge
namespace {
/**
* @brief String representations of the Memorize operator's attributes.
*/
template <>
const char *const EnumStrings<Aidge::MemorizeAttr>::data[] = {
"schedule_step",
"forward_step",
"end_step"
};
}
namespace Aidge {
/** /**
* @class Memorize_Op * @class Memorize_Op
* @brief The Memorize Operator is responsible for storing a tensor's state over a defined * @brief The Memorize Operator is responsible for storing a tensor's state over a defined
* number of iterations and providing the stored value as output at each iteration. * number of iterations and providing the stored value as output at each iteration.
* *
* Memorize operators are used in models with recurrent structures or feedback loops, such as LSTMs. * Memorize operators are used in models with recurrent structures or feedback loops, such as LSTMs.
...@@ -246,7 +258,7 @@ public: ...@@ -246,7 +258,7 @@ public:
* @return A vector containing the attributes name. * @return A vector containing the attributes name.
*/ */
static const char* const* attributesName(){ static const char* const* attributesName(){
return EnumStrings<Aidge::MemorizeAttr>::data; return EnumStrings<Aidge::MemorizeAttr>::data;
} }
}; };
...@@ -259,16 +271,5 @@ public: ...@@ -259,16 +271,5 @@ public:
std::shared_ptr<Node> Memorize(const std::uint32_t endStep, const std::string& name = ""); std::shared_ptr<Node> Memorize(const std::uint32_t endStep, const std::string& name = "");
} // namespace Aidge } // namespace Aidge
namespace {
/**
* @brief String representations of the Memorize operator's attributes.
*/
template <>
const char *const EnumStrings<Aidge::MemorizeAttr>::data[] = {
"schedule_step",
"forward_step",
"end_step"
};
}
#endif /* AIDGE_CORE_OPERATOR_MEMORIZE_H_ */ #endif /* AIDGE_CORE_OPERATOR_MEMORIZE_H_ */
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