47 #if defined(USE_OPENCL) || defined(USE_CUDA)
49 #include "third_party/CLCudaAPI/clpp11.h"
51 #include "third_party/CLCudaAPI/cupp11.h"
57 enum class device_t { NONE, CPU, GPU };
59 inline std::ostream& operator << (std::ostream& os, device_t type) {
61 case device_t::NONE: os <<
"NONE";
break;
62 case device_t::CPU: os <<
"CPU";
break;
63 case device_t::GPU: os <<
"GPU";
break;
65 throw nn_error(
"Not supported ostream enum: " +
66 to_string(
static_cast<int>(type)));
79 inline explicit Device(device_t type);
88 inline explicit Device(device_t type,
89 const int platform_id,
93 device_t type()
const {
return type_; }
96 bool hasCLCudaAPI()
const {
return has_clcuda_api_; }
99 int platformId()
const {
return platform_id_; }
102 int deviceId()
const {
return device_id_; }
104 #if defined(USE_OPENCL) || defined(USE_CUDA)
106 CLCudaAPI::Device device()
const {
return *device_; }
109 CLCudaAPI::Context context()
const {
return *context_; }
112 CLCudaAPI::Queue queue()
const {
return *queue_; }
115 bool operator==(
const Device& d)
const {
116 if (d.type() == this->type() &&
117 d.hasCLCudaAPI() == this->hasCLCudaAPI() &&
118 d.platformId() == this->platformId() &&
119 d.deviceId() == this->deviceId()) {
129 inline void registerOp(
layer& l);
135 bool has_clcuda_api_;
140 #if defined(USE_OPENCL) || defined(USE_CUDA)
142 std::shared_ptr<CLCudaAPI::Device> device_;
144 std::shared_ptr<CLCudaAPI::Context> context_;
146 std::shared_ptr<CLCudaAPI::Queue> queue_;
Definition: device.fwd.h:73
base class of all kind of NN layers
Definition: layer.h:62