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

Method Slice3D

tensorflow/compiler/xla/reference_util.h:357–385  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

355
356 template <typename T>
357 static std::unique_ptr<Array3D<T>> Slice3D(const Array3D<T>& input,
358 std::array<int64, 3> starts,
359 std::array<int64, 3> limits,
360 std::array<int64, 3> strides) {
361 CHECK_LE(starts[0], input.n1());
362 CHECK_LE(starts[1], input.n2());
363 CHECK_LE(starts[2], input.n3());
364 CHECK_LE(limits[0], input.n1());
365 CHECK_LE(limits[1], input.n2());
366 CHECK_LE(limits[2], input.n3());
367 CHECK_GE(strides[0], 1);
368 CHECK_GE(strides[1], 1);
369 CHECK_GE(strides[2], 1);
370 auto result = absl::make_unique<Array3D<T>>(
371 CeilOfRatio(limits[0] - starts[0], strides[0]),
372 CeilOfRatio(limits[1] - starts[1], strides[1]),
373 CeilOfRatio(limits[2] - starts[2], strides[2]));
374
375 for (int64 i0 = 0; i0 < result->n1(); ++i0) {
376 for (int64 i1 = 0; i1 < result->n2(); ++i1) {
377 for (int64 i2 = 0; i2 < result->n3(); ++i2) {
378 (*result)(i0, i1, i2) =
379 input(starts[0] + i0 * strides[0], starts[1] + i1 * strides[1],
380 starts[2] + i2 * strides[2]);
381 }
382 }
383 }
384 return result;
385 }
386
387 template <typename T>
388 static std::unique_ptr<Array4D<T>> Slice4D(const Array4D<T>& input,

Callers

nothing calls this directly

Calls 4

CeilOfRatioFunction · 0.70
n1Method · 0.45
n2Method · 0.45
n3Method · 0.45

Tested by

no test coverage detected