normal_fill Class — pytorch Architecture
Architecture documentation for the normal_fill class in DistributionTemplates.h from the pytorch codebase.
Entity Profile
Source Code
aten/src/ATen/native/cpu/DistributionTemplates.h lines 206–228
template <typename scalar_t, typename RNG>
void normal_fill(const TensorBase &self, const scalar_t mean, const scalar_t std, RNG generator) {
scalar_t *data = self.data_ptr<scalar_t>();
auto size = self.numel();
std::lock_guard<std::mutex> lock(generator->mutex_);
for (const auto i : c10::irange(size)) {
at::uniform_real_distribution<scalar_t> uniform(0, 1);
data[i] = uniform(generator);
}
for (int64_t i = 0; i < size - 15; i += 16) {
normal_fill_16<scalar_t>(data + i, mean, std);
}
if (size % 16 != 0) {
// Recompute the last 16 values.
data = data + size - 16;
for (const auto i : c10::irange(16)) {
at::uniform_real_distribution<scalar_t> uniform(0, 1);
data[i] = uniform(generator);
}
normal_fill_16<scalar_t>(data, mean, std);
}
}
Source
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free