Utils.h 655 B

1234567891011121314151617181920212223
  1. #if !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)
  2. #pragma once
  3. #include <ATen/core/Tensor.h>
  4. #include <ATen/miopen/miopen-wrapper.h>
  5. #include <ATen/miopen/Handle.h>
  6. namespace at { namespace native {
  7. // This function makes tensors which have zero stride contiguous, by
  8. // setting the strides to 1.
  9. inline Tensor contiguousIfZeroInStrides(const Tensor& t) {
  10. for (auto s : t.strides()) {
  11. if (s == 0) return t.contiguous();
  12. }
  13. return t;
  14. }
  15. }}
  16. #else
  17. #error "This file should not be included when either TORCH_STABLE_ONLY or TORCH_TARGET_VERSION is defined."
  18. #endif // !defined(TORCH_STABLE_ONLY) && !defined(TORCH_TARGET_VERSION)