forked from pytorch/pytorch
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathExceptions.h
43 lines (36 loc) · 1.07 KB
/
Exceptions.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#pragma once
#include <ATen/miopen/miopen-wrapper.h>
#include <string>
#include <stdexcept>
#include <sstream>
struct THCState;
namespace at { namespace native {
class miopen_exception : public std::runtime_error {
public:
miopenStatus_t status;
miopen_exception(miopenStatus_t status, const char* msg)
: std::runtime_error(msg)
, status(status) {}
miopen_exception(miopenStatus_t status, const std::string& msg)
: std::runtime_error(msg)
, status(status) {}
};
inline void MIOPEN_CHECK(miopenStatus_t status)
{
if (status != miopenStatusSuccess) {
if (status == miopenStatusNotImplemented) {
throw miopen_exception(status, std::string(miopenGetErrorString(status)) +
". This error may appear if you passed in a non-contiguous input.");
}
throw miopen_exception(status, miopenGetErrorString(status));
}
}
inline void HIP_CHECK(hipError_t error)
{
if (error != hipSuccess) {
std::string msg("HIP error: ");
msg += hipGetErrorString(error);
throw std::runtime_error(msg);
}
}
}} // namespace at::native