Caffe2 - C++ API
A deep learning, cross platform ML framework
Utils.h
1 #pragma once
2 
3 #include <ATen/ATen.h>
4 #include <THH/THH.h>
5 #include <ATen/miopen/miopen-wrapper.h>
6 #include <ATen/miopen/Handle.h>
7 
8 namespace at { namespace native {
9 
10 inline void setMIOpenStreamToCurrent() {
11  // NB: Due to in-place HIPify, getCurrentCUDAStream actually means
12  // getCurrentHIPStream
13  MIOPEN_CHECK(miopenSetStream(getMiopenHandle(), at::hip::getCurrentHIPStream()));
14 }
15 
16 // This function makes tensors which have zero stride contiguous, by
17 // setting the strides to 1.
18 inline Tensor contiguousIfZeroInStrides(const Tensor& t) {
19  for (auto s : t.strides()) {
20  if (s == 0) return t.contiguous();
21  }
22  return t;
23 }
24 
25 }}
Flush-To-Zero and Denormals-Are-Zero mode.