| 364 | |
| 365 | template <typename T> |
| 366 | void Tensor::DataToBHWC(absl::Span<const T> src, absl::Span<float> dst) const { |
| 367 | int channels = |
| 368 | storage_type_ == TensorStorageType::SINGLE_TEXTURE_2D ? channels_ : 4; |
| 369 | BHWC dst_shape; |
| 370 | dst_shape.b = 1; |
| 371 | dst_shape.h = height_; |
| 372 | dst_shape.w = width_; |
| 373 | dst_shape.c = channels_; |
| 374 | for (int d = 0; d < Depth(); ++d) { |
| 375 | for (int y = 0; y < height_; ++y) { |
| 376 | for (int x = 0; x < width_; ++x) { |
| 377 | for (int c = 0; c < channels; ++c) { |
| 378 | if (d * 4 + c >= channels_) continue; |
| 379 | |
| 380 | const int cpu_index = dst_shape.LinearIndex({0, y, x, d * 4 + c}); |
| 381 | const int gpu_index = GetLinearIndex(x, y, d, c); |
| 382 | dst[cpu_index] = src[gpu_index]; |
| 383 | } |
| 384 | } |
| 385 | } |
| 386 | } |
| 387 | } |
| 388 | |
| 389 | template void Tensor::DataToBHWC<float>(absl::Span<const float> src, |
| 390 | absl::Span<float> dst) const; |
nothing calls this directly
no test coverage detected