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

Function NextIndex

tensorflow/lite/kernels/internal/types.h:324–343  ·  view source on GitHub ↗

Gets next index to iterate through a multidimensional array.

Source from the content-addressed store, hash-verified

322
323// Gets next index to iterate through a multidimensional array.
324inline bool NextIndex(const int num_dims, const int* dims, int* current) {
325 if (num_dims == 0) {
326 return false;
327 }
328 TFLITE_DCHECK(dims != nullptr);
329 TFLITE_DCHECK(current != nullptr);
330 int carry = 1;
331 for (int idx = num_dims - 1; idx >= 0; --idx) {
332 int current_val = current[idx] + carry;
333 TFLITE_DCHECK_GE(dims[idx], current_val);
334 if (dims[idx] == current_val) {
335 current[idx] = 0;
336 } else {
337 current[idx] = current_val;
338 carry = 0;
339 break;
340 }
341 }
342 return (carry == 0);
343}
344
345// Gets offset of index if reducing on axis. When reducing, the flattened offset
346// will not change, if the input index changes on the given axis. For example,

Callers 4

ReduceFunction · 0.85
FindMethod · 0.85
FindOrInsertMethod · 0.85
FreshInsertMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected