pytorch
6c6a9c73 - [7/N] Nnapi backend delegation preprocess: compile_spec sanity check (#62213)

Commit
3 years ago
[7/N] Nnapi backend delegation preprocess: compile_spec sanity check (#62213) Summary: Pull Request resolved: https://github.com/pytorch/pytorch/pull/62213 Added sanity checks in preprocess function for Android NNAPI delegate. `preprocess()` requires some input metadata passed through its `method_compile_spec` function argument. `preprocess()` now throws specific error messages, if it cannot find the correct input arguments. Example error message: ``` RuntimeError: method_compile_spec does not contain the "forward" key. method_compile_spec should contain a Tensor or Tensor List which bundles input parameters: shape, dtype, quantization, and dimorder. For input shapes, use 0 for run/load time flexible input. method_compile_spec must use the following format: {"forward": {"inputs": at::Tensor}} OR {"forward": {"inputs": c10::List<at::Tensor>}} ``` nnapi_backend_preprocess.cpp: contains sanity check implementation test_backend_nnapi.py: sanity check unit tests Test: Ran `python test/test_jit.py TestNnapiBackend` in OSS successfully. TODO: Using Tensors to pass input parameters is a temporary hack. When a dedicated object is implemented, update the sanity check error message. ghstack-source-id: 134339282 Test Plan: Ran `python test/test_jit.py TestNnapiBackend` in OSS successfully. Reviewed By: raziel, iseeyuan Differential Revision: D29917004 fbshipit-source-id: 0d5c6b35889c556cda905ffc29c25c5422ae9ee4
Author
Parents
Loading