xref: /aosp_15_r20/external/pytorch/aten/src/ATen/miopen/Utils.h (revision da0073e96a02ea20f0ac840b70461e3646d07c45)
1 #pragma once
2 
3 #include <ATen/core/Tensor.h>
4 #include <ATen/miopen/miopen-wrapper.h>
5 #include <ATen/miopen/Handle.h>
6 
7 namespace at { namespace native {
8 
9 // This function makes tensors which have zero stride contiguous, by
10 // setting the strides to 1.
contiguousIfZeroInStrides(const Tensor & t)11 inline Tensor contiguousIfZeroInStrides(const Tensor& t) {
12   for (auto s : t.strides()) {
13     if (s == 0) return t.contiguous();
14   }
15   return t;
16 }
17 
18 }}
19