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

Function FindSparseValue

tensorflow/contrib/tensor_forest/kernels/tree_utils.h:179–205  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

177// to be sorted.
178template <typename T1, typename T2>
179float FindSparseValue(const T1& sparse_input_indices,
180 const T2& sparse_input_values, int32 i, int32 j) {
181 int32 low = 0;
182 int32 high = sparse_input_values.dimension(0);
183 while (low < high) {
184 int32 mid = (low + high) / 2;
185 int64 midi = internal::SubtleMustCopy(sparse_input_indices(mid, 0));
186 int64 midj = internal::SubtleMustCopy(sparse_input_indices(mid, 1));
187 if (midi == i) {
188 if (midj == j) {
189 return sparse_input_values(mid);
190 }
191 if (midj < j) {
192 low = mid + 1;
193 } else {
194 high = mid;
195 }
196 continue;
197 }
198 if (midi < i) {
199 low = mid + 1;
200 } else {
201 high = mid;
202 }
203 }
204 return 0.0;
205}
206
207// Returns the number of sparse values for example input_index.
208// Also returns the index where those features start in sparse_input_start

Callers 2

GetSparseFunctorFunction · 0.85
GetExampleValueMethod · 0.85

Calls 2

SubtleMustCopyFunction · 0.85
dimensionMethod · 0.45

Tested by

no test coverage detected