Repository navigation
Expand file tree
/
Copy pathErrorCode.cpp
More file actions
47 lines (39 loc) · 1.5 KB
/
Copy pathErrorCode.cpp
File metadata and controls
47 lines (39 loc) · 1.5 KB
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
44
45
46
47
#include "ErrorCode.h"
namespace ds {
namespace {
class ErrorCategory : public std::error_category {
public:
const char *name() const noexcept override {
return "dsinfer";
}
std::string message(int value) const override {
switch (static_cast<ErrorCode>(value)) {
case ErrorCode::NotInitialized:
return "not initialized";
case ErrorCode::AlreadyOpen:
return "already open";
case ErrorCode::DriverMismatch:
return "driver mismatch";
case ErrorCode::DriverLoadFailed:
return "driver load failed";
case ErrorCode::InvalidInput:
return "invalid input";
case ErrorCode::ShapeMismatch:
return "tensor shape mismatch";
case ErrorCode::SessionFailed:
return "session failed";
case ErrorCode::ProcessingFailed:
return "processing failed";
}
return "unknown error";
}
};
}
const std::error_category &error_category() noexcept {
static const ErrorCategory instance;
return instance;
}
std::error_code make_error_code(ErrorCode code) noexcept {
return {static_cast<int>(code), error_category()};
}
}