research/seq_flow_lite/tflite_ops/layer_norm.cc
// Given current position in the input array, the api computes the next valid
// index.
Given current position in the input array, the api computes the next valid
index.
Given current position in the input array the api computes the next valid index .
bool ValidIndex(const int* input_dims, const int input_dims_size,
                int* curr_pos) {
  if (input_dims_size == 0) {
    return false;
  }
  assert(input_dims != nullptr);
  assert(curr_pos != nullptr);
  for (int idx = input_dims_size - 1; idx >= 0; --idx) {
    int current_val = curr_pos[idx] + 1;
    assert(input_dims[idx] >= current_val);
    if (input_dims[idx] == current_val) {
      curr_pos[idx] = 0;
    } else {
      curr_pos[idx] = current_val;
      return true;
    }
  }
  return false;
}
bool ValidIndex ( const int * input_dims , const int input_dims_size , int * curr_pos ) { if ( input_dims_size == 0 ) { return false ; } assert ( input_dims != nullptr ) ; assert ( curr_pos != nullptr ) ; for ( int idx = input_dims_size - 1 ; idx >= 0 ; -- idx ) { int current_val = curr_pos [ idx ] + 1 ; assert ( input_dims [ idx ] >= current_val ) ; if ( input_dims [ idx ] == current_val ) { curr_pos [ idx ] = 0 ; } else { curr_pos [ idx ] = current_val ; return true ; } } return false ; }
Given current position in the input array, the api computes the next valid
index.
Given current position in the input array the api computes the next valid index .