| 177 | // to be sorted. |
| 178 | template <typename T1, typename T2> |
| 179 | float 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 |
no test coverage detected