MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / DataToBHWC

Method DataToBHWC

tensorflow/lite/delegates/gpu/cl/tensor.cc:366–387  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

364
365template <typename T>
366void 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
389template void Tensor::DataToBHWC<float>(absl::Span<const float> src,
390 absl::Span<float> dst) const;

Callers

nothing calls this directly

Calls 1

LinearIndexMethod · 0.45

Tested by

no test coverage detected