Caffe2 - C++ API
A deep learning, cross platform ML framework
Exceptions.h
1 #pragma once
2 
3 #include <ATen/miopen/miopen-wrapper.h>
4 #include <string>
5 #include <stdexcept>
6 #include <sstream>
7 
8 struct THCState;
9 
10 namespace at { namespace native {
11 
12 class miopen_exception : public std::runtime_error {
13 public:
14  miopenStatus_t status;
15  miopen_exception(miopenStatus_t status, const char* msg)
16  : std::runtime_error(msg)
17  , status(status) {}
18  miopen_exception(miopenStatus_t status, const std::string& msg)
19  : std::runtime_error(msg)
20  , status(status) {}
21 };
22 
23 inline void MIOPEN_CHECK(miopenStatus_t status)
24 {
25  if (status != miopenStatusSuccess) {
26  if (status == miopenStatusNotImplemented) {
27  throw miopen_exception(status, std::string(miopenGetErrorString(status)) +
28  ". This error may appear if you passed in a non-contiguous input.");
29  }
30  throw miopen_exception(status, miopenGetErrorString(status));
31  }
32 }
33 
34 inline void HIP_CHECK(hipError_t error)
35 {
36  if (error != hipSuccess) {
37  std::string msg("HIP error: ");
38  msg += hipGetErrorString(error);
39  throw std::runtime_error(msg);
40  }
41 }
42 
43 }} // namespace at::native
Flush-To-Zero and Denormals-Are-Zero mode.