5 #if defined(__WIN32) || defined(_WIN32) || defined(WIN32) || defined(__CYGWIN__) 6 # define DLPRIM_WINDOWS 7 # if defined(DLL_EXPORT) 8 # if defined(DLPRIM_SOURCE) 9 # define DLPRIM_API __declspec(dllexport) 11 # define DLPRIM_API __declspec(dllimport) 17 # define DLPRIM_API __attribute__((visibility("default"))) 30 class Error :
public std::runtime_error {
32 Error(std::string
const &v) : std::runtime_error(v) {}
56 BuildError(std::string
const &msg,std::string
const &log) :
Error(msg), log_(log) {}
58 std::string
const &
log()
const 66 #define DLPRIM_CHECK(x) \ 67 do { if(!(x)) throw ValidationError(std::string("Failed " #x " at " __FILE__ ":") + std::to_string(__LINE__) ); } while(0) 71 double_data = 4 + (0 << 3),
72 int64_data = 4 + (2 << 3),
73 uint64_data = 4 + (3 << 3),
75 float_data = 3 + (0 << 3),
76 int32_data = 3 + (2 << 3),
77 uint32_data = 3 + (3 << 3),
79 half_data = 2 + (0 << 3),
80 bfloat16_data = 2 + (1 << 3),
81 int16_data = 2 + (2 << 3),
82 uint16_data = 2 + (3 << 3),
84 int8_data = 1 + (2 << 3),
85 uint8_data = 1 + (3 << 3),
129 inline DataType string_to_data_type(std::string
const &s)
131 if(s ==
"float" || s==
"float32")
133 else if(s ==
"float16" || s==
"half")
135 else if(s ==
"bfloat16")
136 return bfloat16_data;
137 else if(s ==
"int32" || s ==
"int")
141 else if(s ==
"uint8")
143 else if(s ==
"int16")
145 else if(s ==
"uint16")
147 else if(s ==
"int64")
149 else if(s ==
"uint64")
153 inline std::string data_type_to_string(
DataType dt)
156 case double_data:
return "double";
157 case int64_data:
return "int64";
158 case uint64_data:
return "uint64";
160 case float_data:
return "float";
161 case int32_data:
return "int32";
162 case uint32_data:
return "uint32";
164 case half_data:
return "half";
165 case bfloat16_data:
return "bfloat16";
166 case int16_data:
return "int16";
167 case uint16_data:
return "uint16";
169 case int8_data:
return "int8";
170 case uint8_data:
return "uint8";
181 inline std::string data_type_to_opencl_numeric_limit(
DataType dt,DataTypeLimit lmt)
190 case double_data : prefix=
"DBL";
break;
191 case half_data: prefix=
"HALF";
break;
196 case dt_min_val:
return "(-" + prefix +
"_MAX)";
197 case dt_max_val:
return prefix +
"_MAX";
201 bool unsig = (dt & (3 << 3)) == (3<<3);
204 case int64_data:
return "LONG";
205 case uint64_data:
return "ULONG";
207 case int32_data:
return "INT";
208 case uint32_data:
return "UINT";
210 case int16_data:
return "SHRT";
211 case uint16_data:
return "USHRT";
213 case int8_data:
return "CHAR";
214 case uint8_data:
return "UCHAR";
219 case dt_min_val:
return unsig ?
"0" : prefix +
"_MIN";
220 case dt_max_val:
return prefix +
"_MAX";
225 inline std::string data_type_to_opencl_type(
DataType dt,
bool io_type=
false)
228 case double_data:
return "double";
229 case int64_data:
return "long";
230 case uint64_data:
return "ulong";
232 case float_data:
return "float";
233 case int32_data:
return "int";
234 case uint32_data:
return "uint";
236 case half_data:
return "half";
237 case bfloat16_data:
return (io_type ?
"ushort" :
"float" );
238 case int16_data:
return "short";
239 case uint16_data:
return "ushort";
241 case int8_data:
return "char";
242 case uint8_data:
return "uchar";
248 constexpr
int size_of_data_type(
DataType d)
250 return 1 << ((d & 0x7) - 1);
277 std::string activation_backward_equation(
StandardActivations act,std::string
const &dy,std::string
const &y);
302 int channels_in = -1;
303 int channels_out = -1;
304 int kernel[2] = {1,1};
305 int stride[2] = {1,1};
306 int dilate[2] = {1,1};
constexpr int backward_data
internal flag
Definition: definitions.hpp:259
Thrown if OpenCL kernel compilation failed.
Definition: definitions.hpp:54
CalculationsMode
Operation mode of layers - inference of training.
Definition: definitions.hpp:283
Convolution settings.
Definition: definitions.hpp:301
Base dlprim excetion.
Definition: definitions.hpp:30
static constexpr int max_tensor_dim
Maximal number of dimensions in tensor.
Definition: definitions.hpp:254
DataType
type definition
Definition: definitions.hpp:70
This class is central representation of json objects.
Definition: json.hpp:652
Definition: definitions.hpp:95
Thrown in case of invalid parameters.
Definition: definitions.hpp:46
Mane namespace.
Definition: context.hpp:9
bool is_floating_point_data_type(DataType d)
returns true of data is double, float, half or bfloat16 type
Definition: definitions.hpp:89
GemmOpMode
internal GEMM mode
Definition: definitions.hpp:292
StandardActivations
Parameterless Activations that can be embedded to general kernels like inner product or convolution...
Definition: definitions.hpp:266
Thrown if some stuff is not implemented yet.
Definition: definitions.hpp:38
constexpr int backward_param
internal flag
Definition: definitions.hpp:261
constexpr int forward_data
internal flag
Definition: definitions.hpp:257
std::string const & log() const
get full build log
Definition: definitions.hpp:58