arm_compute::TensorShape fromNNShape(const android::nn::Shape& shape)
{
- // NOTE order may be not correct
- // TODO check and fix order if incorrect
- uint32_t c = android::nn::getSizeOfDimension(shape, 0);
+ // NNAPI assumes the following ordering:
+ //
+ // dim(0) -> N
+ // dim(1) -> H
+ // dim(2) -> W
+ // dim(3) -> C
+ //
+ uint32_t c = android::nn::getSizeOfDimension(shape, 3);
uint32_t h = android::nn::getSizeOfDimension(shape, 1);
uint32_t w = android::nn::getSizeOfDimension(shape, 2);
- uint32_t n = android::nn::getSizeOfDimension(shape, 3);
+ uint32_t n = android::nn::getSizeOfDimension(shape, 0);
return arm_compute::TensorShape(w, h, c, n);
}