kSpatialDim Class — pytorch Architecture
Architecture documentation for the kSpatialDim class in utils.h from the pytorch codebase.
Entity Profile
Source Code
aten/src/ATen/native/quantized/cudnn/utils.h lines 81–192
template <int kSpatialDim = 2>
struct PackedConvWeightCudnn : public ConvPackedParamsBase<kSpatialDim> {
PackedConvWeightCudnn(
at::Tensor orig_weight,
std::optional<at::Tensor> bias,
torch::List<int64_t> stride,
torch::List<int64_t> padding,
torch::List<int64_t> output_padding,
torch::List<int64_t> dilation,
int64_t groups,
bool transpose,
c10::QScheme q_scheme,
int64_t output_channels)
: maybe_padded_weight_(std::move(orig_weight)),
bias_(std::move(bias)),
stride_(stride),
padding_(padding),
output_padding_(output_padding),
dilation_(dilation),
groups_(groups),
transpose_(transpose),
q_scheme_(q_scheme),
num_unpadded_output_channels_(output_channels) {} // output channels needs to be stored when we have to pad this dimension
at::Tensor apply(
const at::Tensor& input,
double output_scale,
int64_t output_zero_point) override;
at::Tensor apply_relu(
const at::Tensor& input,
double output_scale,
int64_t output_zero_point) override;
at::Tensor apply_dynamic(
const at::Tensor& input,
bool reduce_range) override {
TORCH_CHECK(false, "apply_dynamic is currently not reported");
}
at::Tensor apply_dynamic_relu(
const at::Tensor& input,
bool reduce_range) {
TORCH_CHECK(false, "apply_dynamic_relu is currently not reported");
}
std::tuple<at::Tensor, std::optional<at::Tensor>> unpack() override;
static c10::intrusive_ptr<ConvPackedParamsBase<kSpatialDim>> prepack(
at::Tensor weight,
std::optional<at::Tensor> bias,
torch::List<int64_t> stride,
torch::List<int64_t> padding,
torch::List<int64_t> output_padding,
torch::List<int64_t> dilation,
int64_t groups,
bool transpose);
const float* GetBiasData(at::Tensor* bias);
torch::List<int64_t> stride() const override {
return stride_;
}
torch::List<int64_t> padding() const override {
return padding_;
}
torch::List<int64_t> output_padding() const override {
return output_padding_;
}
torch::List<int64_t> dilation() const override {
return dilation_;
}
int64_t groups() const override {
return groups_;
}
bool transpose() const override {
return transpose_;
}
private:
// cudnn v8.4.0 expects conv2d's int8 weight tensor's input and output channels to be a multiple of 4. if it is not
// we need to explicitly pad it to a multiple of 4 ourselves as cudnn does not currently support padding, hence the naming
// convention "maybe"_padded_weight.
// TODO: when and if cudnn enables padding in their operators, we can remove padding on our end and rename this to orig_weight_
at::Tensor maybe_padded_weight_;
std::optional<at::Tensor> bias_;
torch::List<int64_t> stride_;
torch::List<int64_t> padding_;
torch::List<int64_t> output_padding_;
torch::List<int64_t> dilation_;
int64_t groups_;
bool transpose_;
c10::QScheme q_scheme_;
int64_t num_unpadded_output_channels_;
template <bool ReluFused>
at::Tensor apply_impl(
const at::Tensor& input,
double output_scale,
int64_t output_zero_point);
template <bool ReluFused>
void apply_impl_helper(
const at::Tensor& quantized_output,
const at::Tensor& input,
double output_scale);
};
Source
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free