Skip to content
Snippets Groups Projects

fix failed onnx tests

Merged Houssem ROUIS requested to merge fix_operators into dev
1 unresolved thread
5 files
+ 280
30
Compare changes
  • Side-by-side
  • Inline
Files
5
@@ -55,11 +55,30 @@ enum class AvgPoolingAttr {
*
* The AvgPooling operation computes the average value within sliding windows of specified size
* (kernel dimensions) over the input tensor. The stride dimensions determine how the window
* moves across the input. This operation is commonly used in neural networks to reduce the spatial
* dimensions while preserving features.
* moves across the input. The dilation parameter allows spacing between kernel elements, and
* `ceil_mode` determines whether to use ceiling instead of floor when computing the output shape.
* This operation is commonly used in neural networks to reduce spatial dimensions while preserving features.
*
* @tparam DIM Number of dimensions for the pooling operation.
*
* ### Output Shape Calculation
* - If `ceil_mode` is false:
* `output_size = floor((input_size - dilation * (kernel_size - 1) - 1) / stride + 1)`
* - If `ceil_mode` is true:
* `output_size = ceil((input_size - dilation * (kernel_size - 1) - 1) / stride + 1)`
*
* @example Example usage:
* - Input shape: (1, 3, 32, 32) // Batch size 1, 3 channels, 32x32 spatial dimensions
* - KernelDims: (2, 2)
* - StrideDims: (2, 2)
* - Dilation: (1, 1)
* - CeilMode: false
* - Output shape: (1, 3, 16, 16)
*
* @see OperatorTensor
* @see Registrable
*/
template <DimIdx_t DIM>
class AvgPooling_Op : public OperatorTensor,
public Registrable<AvgPooling_Op<DIM>, std::string, std::function<std::shared_ptr<OperatorImpl>(const AvgPooling_Op<DIM> &)>> {
@@ -95,9 +114,11 @@ public:
/**
* @brief Constructs an AvgPooling operation with specified kernel and stride dimensions.
* @param kernel_dims Size of the pooling window for each spatial dimension.
* @param stride_dims Step size (stride) for sliding the pooling window across the input dimensions.
* @param[in] kernel_dims Size of the pooling window for each spatial dimension.
* @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.
*/
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),
@@ -113,7 +134,7 @@ public:
/**
* @brief Copy-constructor.
* @param op AvgPooling_Op to copy.
* @param[in] op AvgPooling_Op to copy.
* @details Copies the operator attributes and its output tensor(s), but not
* its input tensors. The new operator has no associated input.
*/
@@ -127,16 +148,16 @@ public:
/**
* @brief Calculates the output dimensions based on the input dimensions and operator attributes.
* @param allowDataDependency If true, considers data-dependent operations. Defaults to false.
* @param[in] allowDataDependency If true, considers data-dependent operations. Defaults to false.
* @return True if the dimensions are successfully calculated.
*/
bool forwardDims(bool /*allowDataDependency*/ = false) override final;
/**
* @brief Computes the receptive field of the operator.
* @param firstEltDims Dimensions of the first element.
* @param outputDims Dimensions of the output tensor.
* @param outputIdx Index of the output tensor. Defaults to 0.
* @param[in] firstEltDims Dimensions of the first element.
* @param[in] outputDims Dimensions of the output tensor.
* @param[in] outputIdx Index of the output tensor. Defaults to 0.
* @return A vector of pairs representing the receptive fields.
*/
std::vector<std::pair<std::vector<DimSize_t>, std::vector<DimSize_t>>>
@@ -146,8 +167,8 @@ public:
/**
* @brief Sets the backend for the operation.
* @param name Name of the backend.
* @param device Device index. Defaults to 0.
* @param[in] name Name of the backend.
* @param[in] device Device index. Defaults to 0.
*/
void setBackend(const std::string &name, DeviceIdx_t device = 0) override final;
Loading