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

Function GatherToBuffer

tensorflow/compiler/xla/service/hlo_evaluator.cc:808–829  ·  view source on GitHub ↗

Common code used by 1D implementations, which copies data from the input to the contiguous buffer. Returns true if all copied values are zero.

Source from the content-addressed store, hash-verified

806// Common code used by 1D implementations, which copies data from the input to
807// the contiguous buffer. Returns true if all copied values are zero.
808bool GatherToBuffer(absl::Span<complex128> data, int64 length, int64 start,
809 int64 stride, bool expand_input,
810 absl::Span<complex128> buffer) {
811 CHECK_GE(buffer.size(), length);
812 bool input_is_zero = true;
813 const int64 ub = expand_input ? length / 2 + 1 : length;
814 CHECK_GE(data.size(), start + (ub - 1) * stride);
815 for (int64 k = 0; k < ub; k++) {
816 complex128 value = data[start + k * stride];
817 input_is_zero &= value == complex128(0.0, 0.0);
818 buffer[k] = value;
819 if (expand_input) {
820 // Use conjugates of the values at indices [1 ... (ub - 2)] when the
821 // length is even and at indices [1 ... (ub - 1)] when the length is odd
822 // to calculate missing values at indices [(length - 1) ... ub].
823 if (k > 0 && k < (length - ub + 1)) {
824 buffer[length - k] = std::conj(value);
825 }
826 }
827 }
828 return input_is_zero;
829}
830
831// Returns (conjugated, if 'inverse' is true) k-th twiddle for the given length.
832inline complex128 Twiddle(int64 k, int64 length, bool inverse) {

Callers 2

NaiveDft1DFunction · 0.85
Fft1DFunction · 0.85

Calls 2

conjClass · 0.50
sizeMethod · 0.45

Tested by

no test coverage detected