| 330 | |
| 331 | template <typename T> |
| 332 | void Tensor::DataFromBHWC(absl::Span<const float> src, |
| 333 | absl::Span<T> dst) const { |
| 334 | int channels = |
| 335 | storage_type_ == TensorStorageType::SINGLE_TEXTURE_2D ? channels_ : 4; |
| 336 | BHWC src_shape; |
| 337 | src_shape.b = 1; |
| 338 | src_shape.h = height_; |
| 339 | src_shape.w = width_; |
| 340 | src_shape.c = channels_; |
| 341 | for (int d = 0; d < Depth(); ++d) { |
| 342 | for (int y = 0; y < height_; ++y) { |
| 343 | for (int x = 0; x < width_; ++x) { |
| 344 | for (int c = 0; c < channels; ++c) { |
| 345 | float value; |
| 346 | if (d * 4 + c < channels_) { |
| 347 | const int cpu_index = src_shape.LinearIndex({0, y, x, d * 4 + c}); |
| 348 | value = src[cpu_index]; |
| 349 | } else { |
| 350 | value = 0.0f; |
| 351 | } |
| 352 | const int gpu_index = GetLinearIndex(x, y, d, c); |
| 353 | dst[gpu_index] = value; |
| 354 | } |
| 355 | } |
| 356 | } |
| 357 | } |
| 358 | } |
| 359 | |
| 360 | template void Tensor::DataFromBHWC<float>(absl::Span<const float> src, |
| 361 | absl::Span<float> dst) const; |
nothing calls this directly
no test coverage detected