One: [onert] Add Resize Bilinear operation

Created on 27 Jul 2020  路  6Comments  路  Source: Samsung/ONE

Support ResizeBilinear operation on onert, under cpu backend, and for float32 as well as quant8 asymm data types (See parent issue #1715).

help wanted sprintask typdiscussion

All 6 comments

While implementing the cker for ResizeBilinear, I noticed that the IR misses two bool fields, namely align_corners and half_pixel_centers, and also a size tensor. I added them to operation::ResizeBilinear::Param (please refer #3489). However, when I test for the operation, I get the following error message:

[ RUN      ] GeneratedTests.resize_bilinear_2
/home/***/ONE/tests/nnapi/src/TestGenerated.cpp:146: Failure
      Expected: Result::NO_ERROR
      Which is: 4-byte object <00-00 00-00>
To be equal to: execution.setInput(idx, buffer, s)
      Which is: 4-byte object <03-00 00-00>
Google Test trace:
/home/***/ONE/tests/nnapi/src/TestGenerated.cpp:123: 0
/home/***/ONE/tests/nnapi/src/TestGenerated.cpp:235: TestCompilationCaching = 0
/home/***/ONE/tests/nnapi/src/TestGenerated.cpp:153: Failure
      Expected: Result::NO_ERROR
      Which is: 4-byte object <00-00 00-00>
To be equal to: execution.setOutput(idx, buffer, s)
      Which is: 4-byte object <03-00 00-00>
Google Test trace:
/home/***/ONE/tests/nnapi/src/TestGenerated.cpp:123: 0
/home/***/ONE/tests/nnapi/src/TestGenerated.cpp:235: TestCompilationCaching = 0
/home/***/ONE/tests/nnapi/src/TestGenerated.cpp:158: Failure
      Expected: Result::NO_ERROR
      Which is: 4-byte object <00-00 00-00>
To be equal to: r
      Which is: 4-byte object <03-00 00-00>
Google Test trace:
/home/***/ONE/tests/nnapi/src/TestGenerated.cpp:123: 0
/home/***/ONE/tests/nnapi/src/TestGenerated.cpp:235: TestCompilationCaching = 0
[  FAILED  ] GeneratedTests.resize_bilinear_2 (3 ms)

I also noticed that under OperationFactory, init_params.input_count is set to 3, which means I have not accounted for the newly added bool fields and the size tensor. Is this outside the scope of onert backend, or alternatively, is there a way I could access the bool fields as well the size tensor? Please let me know. Thanks in advance.

NNAPI ResizeBilinear spec

  • Don't have size tensor, instead it uses output_width and output_height input scalar
  • Don't have align_corners
  • Don't have half_pixel_centers: it is introduced after 2.2.0

To pass nnapi generated test,

  • For size tensor

    • Use similar implementation with TRANSPOSE operation's perm input tensor

    • Or refer Reshape IR and cpu KernelGenerator: optional input

  • Introduce align_corners and half_pixel_centers to internal IR parameter but set false on NNAPI frontend

@hseok-oh , thanks for your reply.

If I understand correctly, I should do the following:

  1. set align_corners and half_pixel_centers to false in the IR (in OperationFactory.cc as well as base_loader.h)
  2. Pass size as a parameter when writing the testcases, but convert their contents into IR parameters: namely out_height and out_width

Point 2 above means that size will have to be a constant. In fact, base_loader.h has that check in place. I hope that is not a limitation.

  1. set align_corners and half_pixel_centers to false in the IR (in OperationFactory.cc as well as base_loader.h)

base_loader.h may set align_corners and half_pixel_centers by using tflite model file because tflite model file may have those values.

  1. Pass size as a parameter when writing the testcases, but convert their contents into IR parameters: namely out_height and out_width

NNAPI's scalar tensor is always constant, so there may no problem to pass nnapi generation test. For tflite frontend and KernelGenerator, please check Reshape implementation.

I modified the IR as suggested above, and updated the pull request. I now get verification test failure for the resizebilinear operation as shown below:

14:48:19  ok 50 - reshape/reshape2
14:48:19  not ok 51 - resize_bilinear
14:48:19  ok 52 - rsqrt

From the logs, the nnapi_gtest testcases for ResizeBilinear seem to pass. May I have some details on how to troubleshoot verification test failures in general?

I modified the IR as suggested above, and updated the pull request. I now get verification test failure for the resizebilinear operation as shown below:

14:48:19  ok 50 - reshape/reshape2
14:48:19  not ok 51 - resize_bilinear
14:48:19  ok 52 - rsqrt

From the logs, the nnapi_gtest testcases for ResizeBilinear seem to pass. May I have some details on how to troubleshoot verification test failures in general?

Resolved as per recommendations from @hseok-oh in #3489, thank you for your inputs.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

seanshpark picture seanshpark  路  3Comments

jinevening picture jinevening  路  3Comments

mhs4670go picture mhs4670go  路  3Comments

seanshpark picture seanshpark  路  3Comments

hasw7569 picture hasw7569  路  4Comments