Program Listing for File pooling.h¶
↰ Return to documentation for file (torch/csrc/api/include/torch/nn/options/pooling.h
)
#pragma once
#include <torch/arg.h>
#include <torch/csrc/Export.h>
#include <torch/expanding_array.h>
#include <torch/types.h>
namespace torch {
namespace nn {
template <size_t D>
struct AvgPoolOptions {
AvgPoolOptions(ExpandingArray<D> kernel_size)
: kernel_size_(kernel_size), stride_(kernel_size) {}
TORCH_ARG(ExpandingArray<D>, kernel_size);
TORCH_ARG(ExpandingArray<D>, stride);
TORCH_ARG(ExpandingArray<D>, padding) = 0;
TORCH_ARG(bool, ceil_mode) = false;
TORCH_ARG(bool, count_include_pad) = true;
TORCH_ARG(std::optional<int64_t>, divisor_override) = std::nullopt;
};
using AvgPool1dOptions = AvgPoolOptions<1>;
using AvgPool2dOptions = AvgPoolOptions<2>;
using AvgPool3dOptions = AvgPoolOptions<3>;
namespace functional {
using AvgPool1dFuncOptions = AvgPool1dOptions;
} // namespace functional
namespace functional {
using AvgPool2dFuncOptions = AvgPool2dOptions;
} // namespace functional
namespace functional {
using AvgPool3dFuncOptions = AvgPool3dOptions;
} // namespace functional
// ============================================================================
template <size_t D>
struct MaxPoolOptions {
MaxPoolOptions(ExpandingArray<D> kernel_size)
: kernel_size_(kernel_size), stride_(kernel_size) {}
TORCH_ARG(ExpandingArray<D>, kernel_size);
TORCH_ARG(ExpandingArray<D>, stride);
TORCH_ARG(ExpandingArray<D>, padding) = 0;
TORCH_ARG(ExpandingArray<D>, dilation) = 1;
TORCH_ARG(bool, ceil_mode) = false;
};
using MaxPool1dOptions = MaxPoolOptions<1>;
using MaxPool2dOptions = MaxPoolOptions<2>;
using MaxPool3dOptions = MaxPoolOptions<3>;
namespace functional {
using MaxPool1dFuncOptions = MaxPool1dOptions;
} // namespace functional
namespace functional {
using MaxPool2dFuncOptions = MaxPool2dOptions;
} // namespace functional
namespace functional {
using MaxPool3dFuncOptions = MaxPool3dOptions;
} // namespace functional
// ============================================================================
template <typename output_size_t>
struct AdaptiveMaxPoolOptions {
AdaptiveMaxPoolOptions(output_size_t output_size)
: output_size_(output_size) {}
TORCH_ARG(output_size_t, output_size);
};
using AdaptiveMaxPool1dOptions = AdaptiveMaxPoolOptions<ExpandingArray<1>>;
using AdaptiveMaxPool2dOptions =
AdaptiveMaxPoolOptions<ExpandingArrayWithOptionalElem<2>>;
using AdaptiveMaxPool3dOptions =
AdaptiveMaxPoolOptions<ExpandingArrayWithOptionalElem<3>>;
namespace functional {
using AdaptiveMaxPool1dFuncOptions = AdaptiveMaxPool1dOptions;
} // namespace functional
namespace functional {
using AdaptiveMaxPool2dFuncOptions = AdaptiveMaxPool2dOptions;
} // namespace functional
namespace functional {
using AdaptiveMaxPool3dFuncOptions = AdaptiveMaxPool3dOptions;
} // namespace functional
// ============================================================================
template <typename output_size_t>
struct AdaptiveAvgPoolOptions {
AdaptiveAvgPoolOptions(output_size_t output_size)
: output_size_(output_size) {}
TORCH_ARG(output_size_t, output_size);
};
using AdaptiveAvgPool1dOptions = AdaptiveAvgPoolOptions<ExpandingArray<1>>;
using AdaptiveAvgPool2dOptions =
AdaptiveAvgPoolOptions<ExpandingArrayWithOptionalElem<2>>;
using AdaptiveAvgPool3dOptions =
AdaptiveAvgPoolOptions<ExpandingArrayWithOptionalElem<3>>;
namespace functional {
using AdaptiveAvgPool1dFuncOptions = AdaptiveAvgPool1dOptions;
} // namespace functional
namespace functional {
using AdaptiveAvgPool2dFuncOptions = AdaptiveAvgPool2dOptions;
} // namespace functional
namespace functional {
using AdaptiveAvgPool3dFuncOptions = AdaptiveAvgPool3dOptions;
} // namespace functional
// ============================================================================
template <size_t D>
struct MaxUnpoolOptions {
MaxUnpoolOptions(ExpandingArray<D> kernel_size)
: kernel_size_(kernel_size), stride_(kernel_size) {}
TORCH_ARG(ExpandingArray<D>, kernel_size);
TORCH_ARG(ExpandingArray<D>, stride);
TORCH_ARG(ExpandingArray<D>, padding) = 0;
};
using MaxUnpool1dOptions = MaxUnpoolOptions<1>;
using MaxUnpool2dOptions = MaxUnpoolOptions<2>;
using MaxUnpool3dOptions = MaxUnpoolOptions<3>;
// ============================================================================
namespace functional {
template <size_t D>
struct MaxUnpoolFuncOptions {
MaxUnpoolFuncOptions(ExpandingArray<D> kernel_size)
: kernel_size_(kernel_size), stride_(kernel_size) {}
TORCH_ARG(ExpandingArray<D>, kernel_size);
TORCH_ARG(ExpandingArray<D>, stride);
TORCH_ARG(ExpandingArray<D>, padding) = 0;
TORCH_ARG(std::optional<std::vector<int64_t>>, output_size) = std::nullopt;
};
using MaxUnpool1dFuncOptions = MaxUnpoolFuncOptions<1>;
using MaxUnpool2dFuncOptions = MaxUnpoolFuncOptions<2>;
using MaxUnpool3dFuncOptions = MaxUnpoolFuncOptions<3>;
} // namespace functional
// ============================================================================
template <size_t D>
struct FractionalMaxPoolOptions {
FractionalMaxPoolOptions(ExpandingArray<D> kernel_size)
: kernel_size_(kernel_size) {}
TORCH_ARG(ExpandingArray<D>, kernel_size);
TORCH_ARG(std::optional<ExpandingArray<D>>, output_size) = std::nullopt;
using ExpandingArrayDouble = torch::ExpandingArray<D, double>;
TORCH_ARG(std::optional<ExpandingArrayDouble>, output_ratio) = std::nullopt;
TORCH_ARG(torch::Tensor, _random_samples) = Tensor();
};
using FractionalMaxPool2dOptions = FractionalMaxPoolOptions<2>;
using FractionalMaxPool3dOptions = FractionalMaxPoolOptions<3>;
namespace functional {
using FractionalMaxPool2dFuncOptions = FractionalMaxPool2dOptions;
} // namespace functional
namespace functional {
using FractionalMaxPool3dFuncOptions = FractionalMaxPool3dOptions;
} // namespace functional
// ============================================================================
template <size_t D>
struct LPPoolOptions {
LPPoolOptions(double norm_type, ExpandingArray<D> kernel_size)
: norm_type_(norm_type),
kernel_size_(kernel_size),
stride_(kernel_size) {}
TORCH_ARG(double, norm_type);
// the size of the window to take an average over
TORCH_ARG(ExpandingArray<D>, kernel_size);
// the stride of the window. Default value is `kernel_size`
TORCH_ARG(ExpandingArray<D>, stride);
// when True, will use `ceil` instead of `floor` to compute the output shape
TORCH_ARG(bool, ceil_mode) = false;
};
using LPPool1dOptions = LPPoolOptions<1>;
using LPPool2dOptions = LPPoolOptions<2>;
using LPPool3dOptions = LPPoolOptions<3>;
namespace functional {
using LPPool1dFuncOptions = LPPool1dOptions;
} // namespace functional
namespace functional {
using LPPool2dFuncOptions = LPPool2dOptions;
} // namespace functional
namespace functional {
using LPPool3dFuncOptions = LPPool3dOptions;
} // namespace functional
} // namespace nn
} // namespace torch