| 104 | }; |
| 105 | |
| 106 | class TensorBHWC : public Tensor { |
| 107 | public: |
| 108 | TensorBHWC() = default; |
| 109 | TensorBHWC(cl_mem memory, int width, int height, int channels, |
| 110 | enum DataType data_type, TensorStorageType storage_type) |
| 111 | : Tensor(memory, width, height, channels, data_type, storage_type) {} |
| 112 | |
| 113 | // Move only |
| 114 | TensorBHWC(TensorBHWC&& tensor); |
| 115 | TensorBHWC& operator=(TensorBHWC&& tensor); |
| 116 | TensorBHWC(const TensorBHWC&) = delete; |
| 117 | TensorBHWC& operator=(const TensorBHWC&) = delete; |
| 118 | |
| 119 | Status WriteData(CLCommandQueue* queue, void* data_ptr) const { |
| 120 | const size_t data_size = |
| 121 | Width() * Height() * Channels() * SizeOf(DataType()); |
| 122 | RETURN_IF_ERROR( |
| 123 | queue->EnqueueWriteBuffer(GetMemoryPtr(), data_size, data_ptr)); |
| 124 | return OkStatus(); |
| 125 | } |
| 126 | |
| 127 | Status ReadData(CLCommandQueue* queue, void* data_ptr) const { |
| 128 | const size_t data_size = |
| 129 | Width() * Height() * Channels() * SizeOf(DataType()); |
| 130 | RETURN_IF_ERROR( |
| 131 | queue->EnqueueReadBuffer(GetMemoryPtr(), data_size, data_ptr)); |
| 132 | return OkStatus(); |
| 133 | } |
| 134 | |
| 135 | ~TensorBHWC() override { ReleaseBHWC(); } |
| 136 | |
| 137 | private: |
| 138 | friend Status CreateTensorBHWCFromOpenGlObject(const CLContext& context, |
| 139 | cl_int ssbo_id, |
| 140 | const HWC& shape, |
| 141 | bool is_readonly, |
| 142 | TensorBHWC* tensor); |
| 143 | |
| 144 | void ReleaseBHWC(); |
| 145 | |
| 146 | // When object created from GL object it isn't owner |
| 147 | bool owner_ = true; |
| 148 | }; |
| 149 | |
| 150 | using TensorPtr = std::shared_ptr<Tensor>; |
| 151 |
no outgoing calls
no test coverage detected