| 411 | } |
| 412 | |
| 413 | Status CreateTensorBHWC(const CLContext& context, const HWC& shape, |
| 414 | DataType data_type, void* data, Tensor* result) { |
| 415 | const size_t data_size = shape.w * shape.h * shape.c * SizeOf(data_type); |
| 416 | cl_int error_code; |
| 417 | int flags = |
| 418 | data ? (CL_MEM_READ_WRITE | CL_MEM_COPY_HOST_PTR) : CL_MEM_READ_WRITE; |
| 419 | cl_mem memory = |
| 420 | clCreateBuffer(context.context(), flags, data_size, data, &error_code); |
| 421 | if (!memory) { |
| 422 | return UnknownError( |
| 423 | absl::StrCat("Failed to allocate device memory with clCreateBuffer", |
| 424 | CLErrorCodeToString(error_code))); |
| 425 | } |
| 426 | |
| 427 | *result = TensorBHWC(memory, shape.w, shape.h, shape.c, data_type, |
| 428 | TensorStorageType::BUFFER); |
| 429 | return OkStatus(); |
| 430 | } |
| 431 | |
| 432 | Status CreateTensorBHWCFromOpenGlObject(const CLContext& context, |
| 433 | cl_int ssbo_id, const HWC& shape, |
nothing calls this directly
no test coverage detected