Skip to content
Snippets Groups Projects

fix failed onnx tests

Merged Houssem ROUIS requested to merge fix_operators into dev
Files
15
@@ -33,12 +33,21 @@ enum class AvgPoolingAttr {
* Specifies the step size of the sliding window along each spatial dimension.
*/
StrideDims,
/**
* @brief Dilation along each spatial axis. Default value is 1.
*/
Dilations,
/**
* @brief Kernel dimensions for the pooling operation.
* Specifies the size of the pooling window along each spatial dimension.
*/
KernelDims
KernelDims,
/**
* @brief Flag indicating whether to use ceil or floor when calculating output size.
* - `true`: Use `ceil` for output size calculation.
* - `false`: Use `floor` for output size calculation.
*/
CeilMode
};
/**
@@ -67,7 +76,9 @@ private:
*/
using Attributes_ = StaticAttributes<AvgPoolingAttr,
std::array<DimSize_t, DIM>,
std::array<DimSize_t, DIM>>;
std::array<DimSize_t, DIM>,
std::array<DimSize_t, DIM>,
bool>;
template <AvgPoolingAttr e>
using attr = typename Attributes_::template attr<e>;
@@ -89,11 +100,15 @@ public:
* Defaults to 1 for each dimension.
*/
constexpr AvgPooling_Op(const std::array<DimSize_t, DIM> &kernel_dims,
const std::array<DimSize_t, DIM> &stride_dims = create_array<DimSize_t, DIM>(1))
const std::array<DimSize_t, DIM> &stride_dims = create_array<DimSize_t, DIM>(1),
const std::array<DimSize_t, DIM> &dilations = create_array<DimSize_t, DIM>(1),
bool ceil_mode = false)
: OperatorTensor(Type, {InputCategory::Data}, 1),
mAttributes(std::make_shared<Attributes_>(
attr<AvgPoolingAttr::StrideDims>(stride_dims),
attr<AvgPoolingAttr::KernelDims>(kernel_dims)))
attr<AvgPoolingAttr::KernelDims>(kernel_dims),
attr<AvgPoolingAttr::Dilations>(dilations),
attr<AvgPoolingAttr::CeilMode>(ceil_mode)))
{}
/**
@@ -155,11 +170,23 @@ public:
inline std::array<DimSize_t, DIM>& strideDims() const { return mAttributes->template getAttr<AvgPoolingAttr::StrideDims>(); }
/**
* @brief Accessor for the kernel dimensions.
* @return An array representing the kernel dimensions.
* @brief Accessor for dilations.
* @return An array representing spatial dilations.
*/
inline std::array<DimSize_t, DIM>& dilations() const { return mAttributes->template getAttr<AvgPoolingAttr::Dilations>(); }
/**
* @brief Accessor for kernel dimensions.
* @return An array representing kernel dimensions.
*/
inline std::array<DimSize_t, DIM>& kernelDims() const { return mAttributes->template getAttr<AvgPoolingAttr::KernelDims>(); }
/**
* @brief Accessor for ceil mode flag.
* @return Boolean value indicating whether ceil mode is enabled.
*/
inline bool& ceilMode() const { return mAttributes->template getAttr<AvgPoolingAttr::CeilMode>(); }
/**
* @brief Retrieves the names of the input tensors.
* @return A vector of strings representing the input tensors names.
@@ -180,31 +207,39 @@ public:
/**
* @brief Creates an AvgPooling operator node.
* @tparam DIM Number of dimensions for the pooling operation.
* @param kernel_dims Size of the pooling window for each spatial dimension.
* @param name Name of the operator node. Defaults to an empty string.
* @param stride_dims Step size (stride) for sliding the pooling window across the input dimensions. Defaults to 1 for each dimension.
* @param[in] kernel_dims Size of the pooling window for each spatial dimension.
* @param[in] name Name of the operator node. Defaults to an empty string.
* @param[in] stride_dims Step size (stride) for sliding the pooling window across the input dimensions. Defaults to 1 for each dimension.
* @param[in] dilations Spatial dilations for the pooling operation.
* @param[in] ceil_mode Indicates whether to use ceil mode for output size calculation.
* @return A shared pointer to the created operator node.
*/
template <std::array<DimSize_t, 1>::size_type DIM>
std::shared_ptr<Node> AvgPooling(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, DIM> &stride_dims = create_array<DimSize_t,DIM>(1),
const std::array<DimSize_t, DIM> &dilations = create_array<DimSize_t,DIM>(1),
bool ceil_mode=false);
/**
* @brief Overload of AvgPooling for C-style arrays.
* @tparam DIM Number of dimensions for the pooling operation.
* @param kernel_dims C-style array specifying the kernel dimensions.
* @param name Name of the operator node. Defaults to an empty string.
* @param stride_dims Step size (stride) for sliding the pooling window across the input dimensions. Defaults to 1 for each dimension.
* @param[in] kernel_dims C-style array specifying the kernel dimensions.
* @param[in] name Name of the operator node. Defaults to an empty string.
* @param[in] stride_dims Step size (stride) for sliding the pooling window across the input dimensions. Defaults to 1 for each dimension.
* @param[in] dilations Spatial dilations for the pooling operation.
* @param[in] ceil_mode Indicates whether to use ceil mode for output size calculation.
* @return A shared pointer to the created operator node.
*/
template <DimSize_t DIM>
inline std::shared_ptr<Node> 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)) {
const std::array<DimSize_t, DIM> &stride_dims = create_array<DimSize_t,DIM>(1),
const std::array<DimSize_t, DIM> &dilations = create_array<DimSize_t,DIM>(1),
bool ceil_mode=false) {
static_assert(DIM<=MaxDim,"Too many kernel dimensions required by AvgPooling, not supported");
return AvgPooling(to_array(kernel_dims), name, stride_dims);
return AvgPooling(to_array(kernel_dims), name, stride_dims, dilations, ceil_mode);
}
} // namespace Aidge
@@ -221,10 +256,7 @@ namespace {
* @brief String representation of the AvgPooling attributes.
*/
template <>
const char *const EnumStrings<Aidge::AvgPoolingAttr>::data[] = {
"stride_dims",
"kernel_dims"
};
const char *const EnumStrings<Aidge::AvgPoolingAttr>::data[] = { "stride_dims", "kernel_dims", "dilations", "ceil_mode" };
}
#endif /* AIDGE_CORE_OPERATOR_AVGPOOLING_H_ */
Loading