research/seq_flow_lite/tflite_ops/layer_norm.cc
// Gets next offset depending on reduction axis. Implementation borrowed from
// tflite reduce mean implementation.
Gets next offset depending on reduction axis. Implementation borrowed from
tflite reduce mean implementation.
Gets next offset depending on reduction axis . Implementation borrowed from tflite reduce mean implementation .
int GetOffset(const int* input_dims, const int input_dims_size,
              const int* curr_pos, const int* axis, const int axis_size) {
  if (input_dims_size == 0) return 0;
  assert(input_dims != nullptr);
  assert(curr_pos != nullptr);
  int offset = 0;
  for (int idx = 0; idx < input_dims_size; ++idx) {
    bool is_axis = false;
    if (axis != nullptr) {
      for (int redux = 0; redux < axis_size; ++redux) {
        if (idx == axis[redux]) {
          is_axis = true;
          break;
        }
      }
    }
    if (!is_axis) offset = offset * input_dims[idx] + curr_pos[idx];
  }
  return offset;
}
int GetOffset ( const int * input_dims , const int input_dims_size , const int * curr_pos , const int * axis , const int axis_size ) { if ( input_dims_size == 0 ) return 0 ; assert ( input_dims != nullptr ) ; assert ( curr_pos != nullptr ) ; int offset = 0 ; for ( int idx = 0 ; idx < input_dims_size ; ++ idx ) { bool is_axis = false ; if ( axis != nullptr ) { for ( int redux = 0 ; redux < axis_size ; ++ redux ) { if ( idx == axis [ redux ] ) { is_axis = true ; break ; } } } if ( ! is_axis ) offset = offset * input_dims [ idx ] + curr_pos [ idx ] ; } return offset ; }
Gets next offset depending on reduction axis.
Gets next offset depending on reduction axis .
// if idx is part of reduction axes, we skip offset calculation.