message: Adding Transpose to optimized_ops.
diff: @@ -4547,6 +4547,35 @@ void ArgMax(const T3* axis, const T1* input_data, const Dims<4>& input_dims,
  }
  }
  +template <typename T>
  +void Transpose(const T* input, const Dims<4>& input_dims, T* output,
  + const Dims<4>& output_dims, const int* permuted_axes) {
  + int out_sizes[4];
  + // Compute the inverse permutation array so we can do an output centered
  + // transpose. Also, check to make sure output_dims is matching input_dims.
  + for (int k = 0; k < 4; k++) {
  + out_sizes[k] =
  + MatchingArraySize(input_dims, permuted_axes[k], output_dims, k);
  + }
  +
  + // Naive transpose loop (iterate on output index and compute input index).
  + int o[4]; // loop index (on output).
  + int i[4];
  + for (o[3] = 0; o[3] < out_sizes[3]; o[3]++) {
  + i[permuted_axes[3]] = o[3];
  + for (o[2] = 0; o[2] < out_sizes[2]; o[2]++) {
  + i[permuted_axes[2]] = o[2];
  + for (o[1] = 0; o[1] < out_sizes[1]; o[1]++) {
  + i[permuted_axes[1]] = o[1];
  + for (o[0] = 0; o[0] < out_sizes[0]; o[0]++) {
  + i[permuted_axes[0]] = o[0];
  + output[Offset(output_dims, o)] = input[Offset(input_dims, i)];
  + }
  + }
  + }
  + }
  +}
  +
  } // namespace optimized_ops
  } // namespace tflite
  