ReLUFused Class — pytorch Architecture
Architecture documentation for the ReLUFused class in TensorShape.cpp from the pytorch codebase.
Entity Profile
Source Code
aten/src/ATen/native/quantized/cpu/TensorShape.cpp lines 77–114
template <bool ReLUFused>
Tensor quantized_cat_impl(
const MaterializedITensorListRef& qxs,
int64_t dim,
double scale,
int64_t zero_point) {
if (is_cat_nhwc_fast_path(qxs, dim)) {
if (ReLUFused) {
return qcat_relu_nhwc_stub(at::kCPU, qxs, dim, scale, zero_point);
} else {
return qcat_nhwc_stub(at::kCPU, qxs, dim, scale, zero_point);
}
}
const auto x_dtype = qxs[0].get().scalar_type();
const auto x_qscheme = qxs[0].get().qscheme();
std::vector<Tensor> xs;
xs.reserve(qxs.size());
// NOLINTNEXTLINE(performance-implicit-conversion-in-loop)
for (const at::Tensor& qx : qxs) {
TORCH_CHECK(x_dtype == qx.scalar_type(), "All dtypes must be the same.");
TORCH_CHECK(
x_qscheme == qx.qscheme(), "Quantization schemes must be the same.");
xs.push_back(qx.dequantize());
}
const Tensor y = at::cat(xs, dim);
Tensor qy;
AT_DISPATCH_QINT_TYPES(x_dtype, "qcat", [&]() {
qy = at::quantize_per_tensor(y, scale, zero_point, SCALAR_TYPE);
if (ReLUFused) {
auto iter = TensorIterator::unary_op(qy, qy);
cpu_kernel(iter, [&](scalar_t value) -> scalar_t {
return scalar_t(std::max<underlying_t>(value.val_, zero_point));
});
}
});
return qy;
}
Source
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free