Fill vector with constructor instead of fill_n (#1113)

This commit is contained in:
Cheng 2024-05-14 21:28:55 +08:00 committed by GitHub
parent 5be5daa6ef
commit 1a7ed5dcb6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -2854,7 +2854,7 @@ void init_ops(nb::module_& m) {
if (strides) {
a_strides = *strides;
} else {
std::fill_n(std::back_inserter(a_strides), a_shape.size(), 1);
a_strides = std::vector<size_t>(a_shape.size(), 1);
for (int i = a_shape.size() - 1; i > 0; i--) {
a_strides[i - 1] = a_shape[i] * a_strides[i];
}