| 251 | */ |
| 252 | template <typename T> |
| 253 | void fill_planar_tensor(T &tensor, bool bgr = false) |
| 254 | { |
| 255 | ARM_COMPUTE_ERROR_ON(!is_open()); |
| 256 | ARM_COMPUTE_ERROR_ON_DATA_TYPE_CHANNEL_NOT_IN(&tensor, 1, DataType::U8, DataType::QASYMM8, DataType::F32, |
| 257 | DataType::F16); |
| 258 | |
| 259 | const DataLayout data_layout = tensor.info()->data_layout(); |
| 260 | const TensorShape tensor_shape = tensor.info()->tensor_shape(); |
| 261 | |
| 262 | ARM_COMPUTE_UNUSED(tensor_shape); |
| 263 | ARM_COMPUTE_ERROR_ON(tensor_shape[get_data_layout_dimension_index(data_layout, DataLayoutDimension::WIDTH)] != |
| 264 | _width); |
| 265 | ARM_COMPUTE_ERROR_ON(tensor_shape[get_data_layout_dimension_index(data_layout, DataLayoutDimension::HEIGHT)] != |
| 266 | _height); |
| 267 | ARM_COMPUTE_ERROR_ON(tensor_shape[get_data_layout_dimension_index(data_layout, DataLayoutDimension::CHANNEL)] != |
| 268 | 3); |
| 269 | |
| 270 | ARM_COMPUTE_ERROR_ON(_feeder.get() == nullptr); |
| 271 | |
| 272 | try |
| 273 | { |
| 274 | // Map buffer if creating a CLTensor |
| 275 | map(tensor, true); |
| 276 | |
| 277 | // Validate feeding data |
| 278 | validate_info(tensor.info()); |
| 279 | |
| 280 | // Stride across channels |
| 281 | size_t stride_z = 0; |
| 282 | |
| 283 | // Iterate through every pixel of the image |
| 284 | Window window; |
| 285 | if (data_layout == DataLayout::NCHW) |
| 286 | { |
| 287 | window.set(Window::DimX, Window::Dimension(0, _width, 1)); |
| 288 | window.set(Window::DimY, Window::Dimension(0, _height, 1)); |
| 289 | window.set(Window::DimZ, Window::Dimension(0, 1, 1)); |
| 290 | stride_z = tensor.info()->strides_in_bytes()[2]; |
| 291 | } |
| 292 | else |
| 293 | { |
| 294 | window.set(Window::DimX, Window::Dimension(0, 1, 1)); |
| 295 | window.set(Window::DimY, Window::Dimension(0, _width, 1)); |
| 296 | window.set(Window::DimZ, Window::Dimension(0, _height, 1)); |
| 297 | stride_z = tensor.info()->strides_in_bytes()[0]; |
| 298 | } |
| 299 | |
| 300 | Iterator out(&tensor, window); |
| 301 | |
| 302 | unsigned char red = 0; |
| 303 | unsigned char green = 0; |
| 304 | unsigned char blue = 0; |
| 305 | |
| 306 | execute_window_loop( |
| 307 | window, |
| 308 | [&](const Coordinates &) |
| 309 | { |
| 310 | red = _feeder->get(); |