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

Method ReduceWindow1DGeneric

tensorflow/compiler/xla/reference_util.cc:143–173  ·  view source on GitHub ↗

static */

Source from the content-addressed store, hash-verified

141}
142
143/* static */ std::unique_ptr<std::vector<float>>
144ReferenceUtil::ReduceWindow1DGeneric(
145 absl::Span<const float> operand, float init,
146 const std::function<float(float, float)>& reduce_func,
147 absl::Span<const int64> window, absl::Span<const int64> stride,
148 absl::Span<const std::pair<int64, int64>> padding) {
149 CHECK_EQ(window.size(), 1);
150 CHECK_EQ(stride.size(), 1);
151 CHECK_EQ(padding.size(), 1);
152
153 int64 padded_width = padding[0].first + operand.size() + padding[0].second;
154 int64 stride_amount = stride[0];
155 int64 window_size = window[0];
156 int64 result_size =
157 window_util::StridedBound(padded_width, window_size, stride_amount);
158 int64 pad_low = padding[0].first;
159 auto result = absl::make_unique<std::vector<float>>(result_size);
160
161 // Do a full 1D reduce window.
162 for (int64 i0 = 0; i0 < result_size; ++i0) {
163 int64 i0_base = i0 * stride_amount - pad_low;
164 float val = init;
165 for (int64 i0_win = 0; i0_win < window_size; ++i0_win) {
166 if (i0_base + i0_win >= 0 && i0_base + i0_win < operand.size()) {
167 val = reduce_func(val, operand[i0_base + i0_win]);
168 }
169 }
170 (*result)[i0] = val;
171 }
172 return result;
173}
174
175/* static */ std::unique_ptr<std::vector<float>>
176ReferenceUtil::ReduceWindow1DAdd(absl::Span<const float> operand, float init,

Callers

nothing calls this directly

Calls 2

StridedBoundFunction · 0.85
sizeMethod · 0.45

Tested by

no test coverage detected