Commit graph

329 commits

Author SHA1 Message Date
Miao Wang
9bfecb5591 Fix the order of width and height for NNAPI RESIZE_BILINEAR and
RESIZE_NEAREST_NEIGHBOR

  - The CPU implementation always had the order of {width, height}.
  - In P, the documentation was incorrectly changed to {height, width}.

Bug: 131623949
Bug: 130035110
Test: mm
Change-Id: I6c79459fa73347fb51fc34a76ad78d5ac207f210
Merged-In: I6c79459fa73347fb51fc34a76ad78d5ac207f210
(cherry picked from commit 286339b4c8)
2019-05-08 15:33:55 +01:00
Michael Butler
0a1ad962bb Follow up CL to "Add validation tests for NNAPI Burst serialized format"
Bug: 129779280
Bug: 129157135
Test: mma
Test: atest NeuralNetworksTest_static
Test: atest VtsHalNeuralnetworksV1_0TargetTest (with sample-all)
Test: atest VtsHalNeuralnetworksV1_1TargetTest (with sample-all)
Test: atest VtsHalNeuralnetworksV1_2TargetTest (with sample-all)
Change-Id: I6bd088f01c051a76561c0ecf9bbf878bb21c5754
2019-05-07 15:45:48 -07:00
Michael Butler
557b9a9581 Merge "NNAPI: validate that FmqResultDatum padding is 0 -- VTS" into qt-dev
am: 2cd02a4121

Change-Id: I6bbb1c4247ca7279edb35db1565afdb56b75f114
2019-05-07 12:54:12 -07:00
Michael Butler
ddb770f0e4 NNAPI: validate that FmqResultDatum padding is 0 -- VTS
FmqResultDatum::OperandInformation has padding that may not be
initialized by an NN HAL service instance. This CL adds a validation
check to ensure that services are not leaking uninitialized data through
this padding region.

Bug: 131356202
Test: mma
Test: atest VtsHalNeuralnetworksV1_2TargetTest
      (for ValidationTest with sample-all)
Test: altered sample-driver to randomly set a padding byte to 1;
      the new validation test successfully failed the test

Change-Id: I6661945392b3fc773493d8f2f306f29b39e09bab
2019-05-07 18:42:47 +00:00
Slava Shklyaev
bb840a986a Merge "Document that quantized PAD behavior is undefined before NNAPI 1.2" into qt-dev
am: 7af01ada85

Change-Id: Ie720d5e1010d5dfc40f7b05c212fa1e56a028a96
2019-05-02 03:31:09 -07:00
Michael Butler
852820c4ed Merge "Add validation tests for NNAPI Burst serialized format" into qt-dev
am: ef85db2b65

Change-Id: I8c8cdab2b2ea67322601f7d35146430b555e821a
2019-04-30 14:05:38 -07:00
Slava Shklyaev
b01ce9644e Document that quantized PAD behavior is undefined before NNAPI 1.2
We had no tests for quantized PAD in NNAPI 1.1 and think that vendors might have implemented different behaviors.

Bug: 122243484
Test: N/A
Change-Id: Ibfc0801ab746fc271dc5f8efc764b818c6d49df4
2019-04-30 15:27:53 +01:00
Miao Wang
0221549cfb Merge "Fix the order of width and height for NNAPI RESIZE_BILINEAR and RESIZE_NEAREST_NEIGHBOR" into qt-dev
am: e867be8b40

Change-Id: Ic98819efbddfba1be56fd4202806470aabdc29cf
2019-04-29 23:07:35 -07:00
Xusong Wang
d49c50c270 Merge "Move getSupportedOperations out of saveToCache." into qt-dev
am: 3ca195bf02

Change-Id: I391d730ee0c7d8965fe4066f303e8348d35013f8
2019-04-29 22:37:05 -07:00
Michael Butler
ef85db2b65 Merge "Add validation tests for NNAPI Burst serialized format" into qt-dev 2019-04-30 03:58:12 +00:00
TreeHugger Robot
e867be8b40 Merge "Fix the order of width and height for NNAPI RESIZE_BILINEAR and RESIZE_NEAREST_NEIGHBOR" into qt-dev 2019-04-30 03:23:31 +00:00
Miao Wang
286339b4c8 Fix the order of width and height for NNAPI RESIZE_BILINEAR and
RESIZE_NEAREST_NEIGHBOR

  - The CPU implementation always had the order of {width, height}.
  - In P, the documentation was incorrectly changed to {height, width}.

Bug: 131623949
Bug: 130035110
Test: mm
Change-Id: I6c79459fa73347fb51fc34a76ad78d5ac207f210
2019-04-30 00:06:17 +00:00
Michael Butler
20f28a24e9 Add validation tests for NNAPI Burst serialized format
This CL adds the following two types of validation tests on the NNAPI
Burst serialized format:
(1) it directly modifies the serialized data (invalidating it) to ensure
    that vendor  driver services properly validates the serialized
    request
(2) it ensures that vendor driver services properly fail when the result
    channel is not large enough to return the data

This CL additionally includes miscellaneous cleanups:
(1) having a generic "validateEverything" function
(2) moving the "prepareModel" function that's common across
    validateRequest and validateBurst to a common area

Fixes: 129779280
Bug: 129157135
Test: mma
Test: VtsHalNeuralnetworksV1_2TargetTest (with sample-all)
Change-Id: Ib90fe7f662824de17db5a254a8c501855e45f6bd
2019-04-29 23:56:48 +00:00
Xusong Wang
f8c5987bbd Move getSupportedOperations out of saveToCache.
Before this change, getSupportedOperations_1_2 was invoked in
saveModelToCache prior to prepareModel_1_2, which delayed the model
preparation and cache overwriting always ran faster in
SaveToCache_TOCTOU test.

This change increases the chance that the model is overwritten after it
is saved in SaveToCache_TOCTOU test by moving getSupportedOperations_1_2
out of saveToCache.

Bug: 123433989
Test: VtsHalNeuralnetworksV1_xTargetTest with 1.2 sample driver
Test: VtsHalNeuralnetworksV1_xTargetTest with a test driver that can
      read and write cache entries
Test: TOCTOU tests with a sample driver that is deliberately broken

Change-Id: Ieba6a82252623ac429d5fcb6950b99db949f9886
2019-04-29 11:47:54 -07:00
Xusong Wang
9f4cd602ec Test corrupted data cache in CompilationCachingTests.
am: 83ab17f224

Change-Id: I25a761d0982a8eb4dc5b32d8925feab9f66f61a1
2019-04-26 19:08:43 -07:00
Xusong Wang
98bd9a6884 Test TOCTOU in VTS CompilationCachingTests.
am: a44e130a92

Change-Id: I2e55bfd50ae29981dbc2334b4dbc7dc8e43d02fa
2019-04-26 19:08:33 -07:00
Slava Shklyaev
e5c74550ac Specify ranks supported by MAXIMUM and MINIMUM
am: 6e15578156

Change-Id: I98e4a1d9b83307967f68948c6f9c6f2a2ba14d43
2019-04-26 16:38:54 -07:00
Xusong Wang
83ab17f224 Test corrupted data cache in CompilationCachingTests.
We only expect the driver to not crash.

Bug: 123433989
Test: VtsHalNeuralnetworksV1_xTargetTest with 1.2 sample driver
Test: VtsHalNeuralnetworksV1_xTargetTest with a test driver that can
      read and write cache entries

Change-Id: Ic9bd7ad6e42d77d505955cb9dda597a39e95cdb6
2019-04-26 15:35:03 -07:00
Xusong Wang
a44e130a92 Test TOCTOU in VTS CompilationCachingTests.
Two tests are added into VTS:

1. The TOCTOU test, for a fixed number of iterations.

We try to attack the driver by replacing the model cache with another
cache entry from a similar model while the driver is saving to or
preparing from cache, and see if the driver crashes or falsely prepares
an unexpected model (by checking the execution result). Either of the
following results are acceptable

* Fails -> the driver detects this corruption.
* Succeeds and produces correct execution result -> the corruption
happens before saving to cache or after preparing from cache.

Due to the racy nature, this test is probabilistic and we run it several
times.

2. Similar to the TOCTOU test but replace the content between
compile-to-cache and compile-from-cache (once only).

Additionally, remove tmp cache directory if test succeeds.

Bug: 123433989
Test: VtsHalNeuralnetworksV1_xTargetTest with 1.2 sample driver
Test: VtsHalNeuralnetworksV1_xTargetTest with a test driver that can
      read and write cache entries
Test: Check /data/local/tmp and confirm that
      * dirs are preserved on failure
      * dirs are removed on success

Change-Id: Ie04fa905f465c3775979f0ca74359d185dcacea9
2019-04-26 15:35:03 -07:00
Slava Shklyaev
2331d7588e Specify ranks supported by MAXIMUM and MINIMUM
Note that this change documents existing behavior.

Bug: 131210955
Test: mma
Change-Id: I8d877153e1acc8ca2ad5179d7fd7cdc136838ca3
Merged-In: I8d877153e1acc8ca2ad5179d7fd7cdc136838ca3
(cherry picked from commit 6e15578156)
2019-04-26 15:34:31 +01:00
Slava Shklyaev
6e15578156 Specify ranks supported by MAXIMUM and MINIMUM
Note that this change documents existing behavior.

Bug: 131210955
Test: mma
Change-Id: I8d877153e1acc8ca2ad5179d7fd7cdc136838ca3
2019-04-25 10:42:43 +00:00
Lev Proleev
0a9895d9b7 Fix docs: clarify usage of float16 scalars in operations
Update the docs for ops:
- LOG_SOFTMAX
- LOCAL_RESPONSE_NORMALIZATION

The docs mentioned possibility to use float16 as an input type but
didn't specify that other inputs must be float16 as well in that case.

Fix: 123500722
Test: mma
Change-Id: I9028c4a109c80f0b8571fab45555818e9e4bc783
Merged-In: I9028c4a109c80f0b8571fab45555818e9e4bc783
(cherry picked from commit 6d13ba258b)
2019-04-24 13:55:25 +01:00
Slava Shklyaev
16a5cb1947 Clarify NNAPI documentation for MEAN
Bug: 113673389
Test: mma
Change-Id: Icd1ce2fb9054ab9ac6f660dce84823c73563ddb8
Merged-In: Icd1ce2fb9054ab9ac6f660dce84823c73563ddb8
(cherry picked from commit d6e605985b)
2019-04-24 13:55:17 +01:00
Slava Shklyaev
e19c19113d Clarify NNAPI documentation for RESHAPE
Bug: 117176461
Test: mma
Change-Id: I620873536ed99ac79b7eced286a8f2621524290b
Merged-In: I620873536ed99ac79b7eced286a8f2621524290b
(cherry picked from commit 5f5d5f9a54)
2019-04-24 13:55:11 +01:00
Slava Shklyaev
59342bedd4 Merge "Fix docs: clarify usage of float16 scalars in operations" into qt-dev
am: 34e718703d

Change-Id: I62baf5479fa4fb80b7c54de9eb574cd4b99a5f93
2019-04-23 09:22:31 -07:00
Slava Shklyaev
f189a0b2ef Merge changes Icd1ce2fb,I62087353 into qt-dev
am: f22bc9099e

Change-Id: I496e65cd536d3629eb1eb2a773855ddfa6fb7a6f
2019-04-23 09:12:59 -07:00
Slava Shklyaev
34e718703d Merge "Fix docs: clarify usage of float16 scalars in operations" into qt-dev 2019-04-23 14:26:21 +00:00
Slava Shklyaev
f22bc9099e Merge changes Icd1ce2fb,I62087353 into qt-dev
* changes:
  Clarify NNAPI documentation for MEAN
  Clarify NNAPI documentation for RESHAPE
2019-04-23 14:25:54 +00:00
Steven Moreland
6d494b2346 Merge "Update hidl makefiles for bpfmt" am: ff0bd741ca
am: 96f40f7b02

Change-Id: Idbf030e4993067bdb8181321bca2de00c9b6f7ef
2019-04-18 14:34:45 -07:00
Steven Moreland
ff0bd741ca Merge "Update hidl makefiles for bpfmt" 2019-04-18 20:59:48 +00:00
Viet Dang
014dd02f6e Merge "BidirectionalSequenceLSTM op: Fixes VTS test for merge_outputs" into qt-dev 2019-04-18 10:22:13 +00:00
Michael Butler
04878fd29a Fix IBurstCallback.hal typo
am: 248eaba9c1

Change-Id: I560703f4c19db1148411e094370a505c4e4e3d0c
2019-04-17 11:41:10 -07:00
Michael Butler
a1707a6b58 Fix IBurstCallback.hal typo
Test: mma
Bug: N/A
Change-Id: If753c6618c31a11672c4449f798fb57aa4bb7831
Merged-In: If753c6618c31a11672c4449f798fb57aa4bb7831
(cherry picked from commit f1ca6754a8)
(cherry picked from commit 24f9c4aa3f4e85d375da5e7df90b54bdf938b481)
2019-04-17 17:37:30 +00:00
Steven Moreland
1ae4615d9f Update hidl makefiles for bpfmt
hidl-generated makefiles are now generated such that bpfmt(file) == file.

Bug: 67417008
Test: enable bpfmt hook
Change-Id: I1f69d292bc23a7cc293a66110cb02d597e1019ad
2019-04-17 09:38:50 -07:00
Viet Dang
ea551fd12a BidirectionalSequenceLSTM op: Fixes VTS test for merge_outputs
Bug: 123644584

Test: VtsHalNeuralnetworksV1_xTargetTest
Change-Id: I8829fd47094ca4af05e5d60da917499ce61acc5e
Merged-In: I8829fd47094ca4af05e5d60da917499ce61acc5e
(cherry picked from commit a8f33f7dbf)
2019-04-17 15:49:05 +00:00
Michael Butler
248eaba9c1 Fix IBurstCallback.hal typo
Test: mma
Bug: 126892442
Change-Id: If753c6618c31a11672c4449f798fb57aa4bb7831
(cherry picked from commit f1ca6754a8)
2019-04-17 01:23:46 +00:00
Lev Proleev
6d13ba258b Fix docs: clarify usage of float16 scalars in operations
Update the docs for ops:
- LOG_SOFTMAX
- LOCAL_RESPONSE_NORMALIZATION

The docs mentioned possibility to use float16 as an input type but
didn't specify that other inputs must be float16 as well in that case.

Fix: 123500722
Test: mma
Change-Id: I9028c4a109c80f0b8571fab45555818e9e4bc783
2019-04-12 17:49:54 +01:00
Slava Shklyaev
d6e605985b Clarify NNAPI documentation for MEAN
Bug: 113673389
Test: mma
Change-Id: Icd1ce2fb9054ab9ac6f660dce84823c73563ddb8
2019-04-12 17:49:54 +01:00
Slava Shklyaev
5f5d5f9a54 Clarify NNAPI documentation for RESHAPE
Bug: 117176461
Test: mma
Change-Id: I620873536ed99ac79b7eced286a8f2621524290b
2019-04-12 17:49:54 +01:00
Slava Shklyaev
ee4ee60689 Update documentation for MAXIMUM and MINIMUM
Fix: 130029167
Test: mma
Change-Id: Ieb0c3327a85331243af5e20a1f29f1be316267ee
Merged-In: Ieb0c3327a85331243af5e20a1f29f1be316267ee
(cherry picked from commit 901ac77a69)
2019-04-10 16:15:07 +01:00
Slava Shklyaev
846ff982ae Merge "Update documentation for MAXIMUM and MINIMUM" into qt-dev
am: fc192d58ce

Change-Id: I0ca92822b11b8584cba334d59c77b9ce50cc9ce6
2019-04-09 11:13:06 -07:00
Viet Dang
80d016b7b8 Merge "BidirectionalSequenceLSTM op: Fixes VTS test for merge_outputs" am: 77f7fdfb70
am: aea0439a91

Change-Id: I09f5e1be87170b1403f6431d54702d09cd31b891
2019-04-09 08:23:01 -07:00
Treehugger Robot
77f7fdfb70 Merge "BidirectionalSequenceLSTM op: Fixes VTS test for merge_outputs" 2019-04-09 15:00:55 +00:00
Slava Shklyaev
901ac77a69 Update documentation for MAXIMUM and MINIMUM
Bug: 130029167
Test: mma
Change-Id: Ieb0c3327a85331243af5e20a1f29f1be316267ee
2019-04-09 09:34:18 +00:00
Lev Proleev
e465f8e659 LSTM: require input layer norm weights to be omitted in case CIFG is used.
In case of CIFG LSTM, input layer norm weights are not used in the
computation.

Bug: 129126572
Test: mma
Change-Id: I57bc578606132a2c44c71ab63dd7645dcc001302
Merged-In: I57bc578606132a2c44c71ab63dd7645dcc001302
(cherry picked from commit 0480af9aa8)
2019-04-08 14:28:23 +01:00
Viet Dang
723ff2dbfd BidirectionalSequenceLSTM op: Fixes VTS test for merge_outputs
Bug: 123644584

Test: VtsHalNeuralnetworksV1_xTargetTest
Change-Id: I8829fd47094ca4af05e5d60da917499ce61acc5e
Merged-In: I8829fd47094ca4af05e5d60da917499ce61acc5e
(cherry picked from commit a8f33f7dbf)
2019-04-05 17:20:13 +00:00
Michael Butler
51c72186ce Propagate ANNMemory_free to IBurstContext::freeMemory -- VTS update
This CL adapts the VTS code to the corresponding changes made in the NN
utility library.

Bug: 128319484
Test: mma
Test: atest VtsHalNeuralnetworksV1_0Target
Test: atest VtsHalNeuralnetworksV1_1Target
Test: atest VtsHalNeuralnetworksV1_2Target
Change-Id: I470e8228cde2b75620ad851e4fe408f8e8329e7c
Merged-In: I470e8228cde2b75620ad851e4fe408f8e8329e7c
(cherry picked from commit 102e0442d8)
2019-04-03 22:48:35 +00:00
Michael Butler
8a4c1f5e12 Merge "Propagate ANNMemory_free to IBurstContext::freeMemory -- VTS update" 2019-04-02 21:57:35 +00:00
Michael Butler
60a2253bfb NNAPI Burst object cleanup -- VTS update
This CL adapts the VTS code to the corresponding changes made in the NN
utility library.

Bug: 119570067
Test: mma
Test: atest VtsHalNeuralnetworksV1_0Target
Test: atest VtsHalNeuralnetworksV1_1Target
Test: atest VtsHalNeuralnetworksV1_2Target
Change-Id: I7cbc1d7025c0352aa1ed29d71dc84c2fcfc20a4f
Merged-In: I7cbc1d7025c0352aa1ed29d71dc84c2fcfc20a4f
(cherry picked from commit e68668f65b)
2019-04-02 20:17:31 +00:00
Lev Proleev
778accda64 Merge "LSTM: require input layer norm weights to be omitted in case CIFG is used." 2019-04-01 10:36:19 +00:00
Michael Butler
102e0442d8 Propagate ANNMemory_free to IBurstContext::freeMemory -- VTS update
This CL adapts the VTS code to the corresponding changes made in the NN
utility library.

Bug: 128319484
Test: mma
Test: atest VtsHalNeuralnetworksV1_0Target
Test: atest VtsHalNeuralnetworksV1_1Target
Test: atest VtsHalNeuralnetworksV1_2Target
Change-Id: I470e8228cde2b75620ad851e4fe408f8e8329e7c
2019-03-29 13:25:53 -07:00
Michael Butler
e68668f65b NNAPI Burst object cleanup -- VTS update
This CL adapts the VTS code to the corresponding changes made in the NN
utility library.

Bug: 119570067
Test: mma
Test: atest VtsHalNeuralnetworksV1_0Target
Test: atest VtsHalNeuralnetworksV1_1Target
Test: atest VtsHalNeuralnetworksV1_2Target
Change-Id: I7cbc1d7025c0352aa1ed29d71dc84c2fcfc20a4f
2019-03-28 13:41:14 -07:00
Lev Proleev
0480af9aa8 LSTM: require input layer norm weights to be omitted in case CIFG is used.
In case of CIFG LSTM, input layer norm weights are not used in the
computation.

Bug: 129126572
Test: mma
Change-Id: I57bc578606132a2c44c71ab63dd7645dcc001302
2019-03-28 15:56:33 +00:00
Xusong Wang
7b277acbd0 Sync operation docs between NeuralNetworks.h and HAL file am: 66baf74114 am: e265b746b9
am: 094a06c28e

Change-Id: I34c9eba2b4fa207486416a2b0a04c569aac76a69
2019-03-22 17:37:30 -07:00
Xusong Wang
66baf74114 Sync operation docs between NeuralNetworks.h and HAL file
Test: mma
Change-Id: I0fb44d734216e2f40a9a2d4efc3640acd923f932
2019-03-22 13:11:25 -07:00
Xusong Wang
ed0822bc78 Fix caching interface according to vendor feedback.
- Instead of isCachingSupport returning a single boolean, switch to
  getNumberOfCacheFilesNeeded returning the number of cache files. This
  is to support use cases when driver needs more than one cache file for
  each type, or when driver does not need data cache.

- Instead of a separate saveToCache, pass cache info along with
  prepareModel_1_2 to save into cache as well as perform compilation.
  This is to avoid a potential additional copy of cache files.

Bug: 123780248
Test: VtsHalNeuralnetworksV1_xTargetTest with 1.2 sample driver
Test: VtsHalNeuralnetworksV1_xTargetTest with a test driver that can
      read and write cache entries
Change-Id: I921b7b8ccc3c66af19f6589f7213c6870d6f07bf
Merged-In: I921b7b8ccc3c66af19f6589f7213c6870d6f07bf
(cherry picked from commit b61ba1ed0b)
2019-03-22 13:10:54 -07:00
Viet Dang
ed5c004915 BidirectionalSequenceLSTM op: Adds layer norm support.
Also updates documentation for this op and UnidirectionalSequenceLSTM
op.

Bug: 123644584

Test: in ag/6758764

Change-Id: I72d029fef6d890eb1771c21814b028b09af280c7
Merged-In: I72d029fef6d890eb1771c21814b028b09af280c7
(cherry picked from commit f404a1e894)
2019-03-22 13:10:17 -07:00
David Gross
2d47c80c8e Add @V1_2::Capabilities to support all non extension operand types.
Performance information in Capabilities is used by the runtime when
it selects the appropriate processor to distribute work to.  Prior to
this CL, Capabilities can only distinguish between float and non-float
data types -- so, for example, float16 and float32 performance is
considered to be the same, and performance for all non-float data types is
considered to be the same.

Bug: 124041010

Test: NeuralNetworksTest_static
Test: VtsHalNeuralnetworksV1_2TargetTest --hal_service_instance=android.hardware.neuralnetworks@1.2::IDevice/sample-all

Change-Id: I83fb5920c1c75afbd7750d793a0b8f3e72a0552c
Merged-In: I83fb5920c1c75afbd7750d793a0b8f3e72a0552c
(cherry picked from commit 632b4bd9b0)
2019-03-22 10:43:47 -07:00
David Gross
632b4bd9b0 Add @V1_2::Capabilities to support all non extension operand types.
Performance information in Capabilities is used by the runtime when
it selects the appropriate processor to distribute work to.  Prior to
this CL, Capabilities can only distinguish between float and non-float
data types -- so, for example, float16 and float32 performance is
considered to be the same, and performance for all non-float data types is
considered to be the same.

Bug: 124041010

Test: NeuralNetworksTest_static
Test: VtsHalNeuralnetworksV1_2TargetTest --hal_service_instance=android.hardware.neuralnetworks@1.2::IDevice/sample-all

Change-Id: I83fb5920c1c75afbd7750d793a0b8f3e72a0552c
2019-03-21 19:37:36 -07:00
Xusong Wang
b61ba1ed0b Fix caching interface according to vendor feedback.
- Instead of isCachingSupport returning a single boolean, switch to
  getNumberOfCacheFilesNeeded returning the number of cache files. This
  is to support use cases when driver needs more than one cache file for
  each type, or when driver does not need data cache.

- Instead of a separate saveToCache, pass cache info along with
  prepareModel_1_2 to save into cache as well as perform compilation.
  This is to avoid a potential additional copy of cache files.

Bug: 123780248
Test: VtsHalNeuralnetworksV1_xTargetTest with 1.2 sample driver
Test: VtsHalNeuralnetworksV1_xTargetTest with a test driver that can
      read and write cache entries
Change-Id: I921b7b8ccc3c66af19f6589f7213c6870d6f07bf
2019-03-21 14:17:08 -07:00
Viet Dang
f404a1e894 BidirectionalSequenceLSTM op: Adds layer norm support.
Also updates documentation for this op and UnidirectionalSequenceLSTM
op.

Bug: 123644584

Test: in ag/6758764

Change-Id: I72d029fef6d890eb1771c21814b028b09af280c7
2019-03-21 18:23:30 +00:00
Lev Proleev
0b074a9ba5 Update scale restrictions in NN API ops docs am: c8b3d162c2 am: 28c60ff868
am: 1c94eb7c5d

Change-Id: Ie6e9cbe78a4182dc23d8916dcd220c5c51064b0a
2019-03-21 07:11:00 -07:00
Lev Proleev
c8b3d162c2 Update scale restrictions in NN API ops docs
NN API relaxed scale restrictions to improve compatibility with TF Lite.

Updated ops:
- CONV_2D
- DEPTHWISE_CONV_2D
- TRANSPOSE_CONV_2D
- GROUPED_CONV_2D
- FULLY_CONNECTED

Test: mma
Bug: 127427474
Change-Id: I9dabd27b21679b99d638c364464d815e1c199787
2019-03-21 10:26:26 +00:00
Xusong Wang
f80e3e7826 Fix condition in mutateOperationOperandTypeSkip for conv ops.
The filter tensor is not always operand 1 if there are multiple
operations in the model.

Test: 1.2 VTS tests with sample driver
Change-Id: I8925dfd18072ae5579657e8aa13128e7d9f58324
Merged-In: I8925dfd18072ae5579657e8aa13128e7d9f58324
(cherry picked from commit 8804423ca1)
2019-03-20 13:02:48 -07:00
Xusong Wang
8804423ca1 Fix condition in mutateOperationOperandTypeSkip for conv ops.
The filter tensor is not always operand 1 if there are multiple
operations in the model.

Test: 1.2 VTS tests with sample driver
Change-Id: I8925dfd18072ae5579657e8aa13128e7d9f58324
2019-03-13 16:27:05 -07:00
Miao Wang
8e501a7d31 Fix the documentation about paddings for SPACE_TO_BATCH_ND am: 9c9fea329e am: f29553e3e1
am: e9100c8b88

Change-Id: Iec682b2ea2dcbc5435d6d6f0ad3894f36f5f0ed8
2019-03-13 12:32:27 -07:00
Miao Wang
9c9fea329e Fix the documentation about paddings for SPACE_TO_BATCH_ND
Bug: 123929388
Test: mm
Change-Id: I3acbfc7b1205774d9852ce8dd8c3144f250c793c
2019-03-12 15:08:08 -07:00
Elliott Hughes
9e53c0ddd6 Fix "tranpose" typo. am: 7b303e1670 am: 1d58b00848
am: 988ff70cd8

Change-Id: Ic7c3fbe9a9b6afbb4182c479be8d41df942e3988
2019-03-08 16:22:11 -08:00
Slava Shklyaev
b45f700b34 Specify NNAPI extension name format am: 1d2cd43476 am: f6bdc6a983
am: 1d3588a789

Change-Id: Ib97cd492c51a3ce463f17fb3a14905d8c2092e57
2019-03-08 12:35:26 -08:00
Elliott Hughes
7b303e1670 Fix "tranpose" typo.
Test: N/A
Change-Id: I5c02f66b1fdf4ee77564809b5610ba53d93273af
2019-03-08 12:15:39 -08:00
Slava Shklyaev
1d2cd43476 Specify NNAPI extension name format
Fix: 125376611
Test: mma
Change-Id: I7d7fcb5d23b4c998c4cd6cd8c9b14ec932876a17
2019-03-08 11:19:40 +00:00
Lev Proleev
b4e306782c Fix operations docs am: fdf3c0363a am: 0775d27fe6
am: efc791ed73

Change-Id: Ib59ed39d256fe446df3ae820a122cdd01e98166e
2019-03-05 04:27:01 -08:00
Lev Proleev
fdf3c0363a Fix operations docs
* Add missing float16-related docs
* Fix weights' shapes in QUANTIZED_16BIT_LSTM

Bug: 126872052
Bug: 126870779
Test: mma
Change-Id: Iba0b208b101db676b03b04e03e43c7378877843c
2019-03-05 11:07:39 +00:00
Steven Moreland
7f4e21adda Merge "Update makefies: no 'types'" am: 4ee5ec1469 am: bab622f6a6
am: 7224bc9bcf

Change-Id: I434939e0770afa436c532a945542fce30a71ef7d
2019-03-04 16:05:59 -08:00
Steven Moreland
a878aee9ab Update makefies: no 'types'
Bug: 123976090
Test: N/A
Change-Id: I30fb04c81889b62775e1b764b965fdb0f893de17
2019-03-04 11:27:17 -08:00
Michael Butler
80ad3f8449 Merge "Add presubmit tests to NNAPI -- hardware/interfaces/neuralnetworks" 2019-02-20 18:23:40 +00:00
Michael Butler
58caa831bd Add presubmit tests to NNAPI -- hardware/interfaces/neuralnetworks
This CL creates a new suite of tests to enable presubmit tests:
* PresubmitHalNeuralnetworksV1_0TargetTest
* PresubmitHalNeuralnetworksV1_1TargetTest
* PresubmitHalNeuralnetworksV1_2TargetTest

These tests are the same as the VTS tests, with the exception that they
will skip running all tests (but still pass) if the service cannot be
found and its name starts with "service-".

This change does not affect the existing NNAPI VTS tests.

Test: mma
Test: atest
Bug: 124040554
Change-Id: I36a38b66b21fd51d0ca381bb4e05a39266dd353f
(cherry picked from commit ed68233697)
2019-02-19 12:04:24 -08:00
Michael Butler
669fe0b1f9 Merge "Add presubmit tests to NNAPI -- hardware/interfaces/neuralnetworks" 2019-02-19 17:32:56 +00:00
Lev Proleev
fd1134a6f3 Update TRANSPOSE_CONV_2D docs
* Add info about per-channel quantization
* Update current.txt

Test: mma
Change-Id: I197d984c8b65b4c46bf526eb137f212ad8844926
Merged-In: I197d984c8b65b4c46bf526eb137f212ad8844926
(cherry picked from commit 44015c090a)
2019-02-18 09:00:19 +00:00
Michael Butler
857142085f Pretty-print ErrorStatus and DeviceStatus test failure logs
Argument-dependent lookup will only work for operator>> if the operator
is in one of the argument's namespaces. This caused the enumerations to
pretty-print for V1_0, but not for V1_1 or V1_2. This change ensures the
V1_0 namespace is used.

Test: mma
Test: atest VtsHalNeuralnetworksV1_0TargetTest (verified the test output "OFFLINE" for DeviceStatus and "DEVICE_UNAVAILABLE" for ErrorStatus instead of raw byte value representation)
Test: atest VtsHalNeuralnetworksV1_1TargetTest (verified the test output "OFFLINE" for DeviceStatus and "DEVICE_UNAVAILABLE" for ErrorStatus instead of raw byte value representation)
Test: atest VtsHalNeuralnetworksV1_2TargetTest (verified ran and passed tests)
Fixes: 124316129
Change-Id: I764a46e2d87615b1f3da0ab0e6edb134bb533887
(cherry picked from commit 42a35bee10)
2019-02-15 13:34:50 -08:00
Michael Butler
ed68233697 Add presubmit tests to NNAPI -- hardware/interfaces/neuralnetworks
This CL creates a new suite of tests to enable presubmit tests:
* PresubmitHalNeuralnetworksV1_0TargetTest
* PresubmitHalNeuralnetworksV1_1TargetTest
* PresubmitHalNeuralnetworksV1_2TargetTest

These tests are the same as the VTS tests, with the exception that they
will skip running all tests (but still pass) if the service cannot be
found and its name starts with "service-".

This change does not affect the existing NNAPI VTS tests.

Test: mma
Test: atest
Bug: 124040554
Change-Id: I36a38b66b21fd51d0ca381bb4e05a39266dd353f
2019-02-15 11:47:00 -08:00
Lev Proleev
44015c090a Update TRANSPOSE_CONV_2D docs
* Add info about per-channel quantization
* Update current.txt

Test: mma
Change-Id: I197d984c8b65b4c46bf526eb137f212ad8844926
2019-02-15 16:01:49 +00:00
Xusong Wang
3ee1f4a333 Modify several 1.2 nn operation specs.
- Add TENSOR_QUANT8_ASYMM to RESIZE_BILINEAR
- Change the spec of batch_split in
  * GENERATE_PROPOSALS
  * ROI_ALIGN
  * ROI_POOLING
  * AXIS_ALIGNED_BBOX_TRANSFORM
  * BOX_WITH_NMS_LIMIT
- Add new op RESIZE_NEAREST_NEIGHBOR
- Fix minor specification error in
  * AXIS_ALIGNED_BBOX_TRANSFORM
  * GENERATE_PROPOSALS

Bug: 124060811
Bug: 124061329
Bug: 124061327
Test: 1.2 VTS tests with sample driver
Change-Id: If8b8cabd249f17247d8a5278b8360685c97c68e6
Merged-In: If8b8cabd249f17247d8a5278b8360685c97c68e6
(cherry picked from commit b9319bd3bf)
2019-02-14 18:13:35 -08:00
Michael Butler
9e3f898921 Merge "Pretty-print ErrorStatus and DeviceStatus test failure logs" 2019-02-14 20:49:00 +00:00
Michael Butler
42a35bee10 Pretty-print ErrorStatus and DeviceStatus test failure logs
Argument-dependent lookup will only work for operator>> if the operator
is in one of the argument's namespaces. This caused the enumerations to
pretty-print for V1_0, but not for V1_1 or V1_2. This change ensures the
V1_0 namespace is used.

Test: mma
Test: atest VtsHalNeuralnetworksV1_0TargetTest (verified the test output "OFFLINE" for DeviceStatus and "DEVICE_UNAVAILABLE" for ErrorStatus instead of raw byte value representation)
Test: atest VtsHalNeuralnetworksV1_1TargetTest (verified the test output "OFFLINE" for DeviceStatus and "DEVICE_UNAVAILABLE" for ErrorStatus instead of raw byte value representation)
Test: atest VtsHalNeuralnetworksV1_2TargetTest (verified ran and passed tests)
Fixes: 124316129
Change-Id: I764a46e2d87615b1f3da0ab0e6edb134bb533887
2019-02-14 20:48:40 +00:00
Xusong Wang
6824cc1e64 Remove tmp directory after CompilationCachingTest if cache not supported.
The tmp directory is only removed when the driver reports caching not
supported, otherwise it is kept for debugging purpose.

Test: 1.2 VTS tests with sample driver
Change-Id: I5969beb1ec365c992765f40d7693630606f16e18
Merged-In: I5969beb1ec365c992765f40d7693630606f16e18
(cherry picked from commit 350d91b1df)
2019-02-14 10:16:41 -08:00
Hervé Guihot
ac7ac525b2 Added missing ASSERT_NE.
Test was failing with segmentation fault (and crashing whole VTS) when
device was not available.

Change-Id: Id0f28d061dc5858fa00ef1bac5f7aa467d860864
Merged-In: Id0f28d061dc5858fa00ef1bac5f7aa467d860864
(cherry picked from commit 70d25b813e)
2019-02-14 10:15:27 -08:00
Xusong Wang
e50086a29d Merge "Remove tmp directory after CompilationCachingTest if cache not supported." 2019-02-14 18:10:18 +00:00
Xusong Wang
b9319bd3bf Modify several 1.2 nn operation specs.
- Add TENSOR_QUANT8_ASYMM to RESIZE_BILINEAR
- Change the spec of batch_split in
  * GENERATE_PROPOSALS
  * ROI_ALIGN
  * ROI_POOLING
  * AXIS_ALIGNED_BBOX_TRANSFORM
  * BOX_WITH_NMS_LIMIT
- Add new op RESIZE_NEAREST_NEIGHBOR
- Fix minor specification error in
  * AXIS_ALIGNED_BBOX_TRANSFORM
  * GENERATE_PROPOSALS

Bug: 124060811
Bug: 124061329
Bug: 124061327
Test: 1.2 VTS tests with sample driver
Change-Id: If8b8cabd249f17247d8a5278b8360685c97c68e6
2019-02-13 13:09:38 -08:00
Xusong Wang
350d91b1df Remove tmp directory after CompilationCachingTest if cache not supported.
The tmp directory is only removed when the driver reports caching not
supported, otherwise it is kept for debugging purpose.

Test: 1.2 VTS tests with sample driver
Change-Id: I5969beb1ec365c992765f40d7693630606f16e18
2019-02-13 11:53:19 -08:00
Lev Proleev
dce38f1364 Fix VTS tests.
* Adds a specification of invalid scale and zero point for TENSOR_BOOL8.
This fixes vts failures for comparison ops.
* Removes (FUNDAMENTAL_MIN - 1) from invalid OperationTypes.
FUNDAMENTAL_MIN is equal to 0 and resulting -1 was statically casted to
uint32_t and passed 4294967295 as an invalid OperationType. However, our
validateOperation function interpreted this ID as an extension ID and
didn't fail.
* Adds mutateOperationOperandTypeSkip for QUANTIZE and DEQUANTIZE.
* Adds removeOperandSkip for BIDIRECTIONAL_SEQUENCE_RNN.

Fix: 121130841
Fix: 123247345
Test: VtsHalNeuralnetworksV1_2TargetTest --hal_service_instance=android.hardware.neuralnetworks@1.2::IDevice/sample-all
Change-Id: Iefb502c6b9301d5470eb4cdaa46d398f1a0e512a
Merged-In: Iefb502c6b9301d5470eb4cdaa46d398f1a0e512a
(cherry picked from commit 923b8c5842)
2019-02-13 13:16:28 +00:00
Steven Moreland
e694cb2dad neuralnetworks: Update makefiles.
Bug: N/A
Test: N/A
Change-Id: I83a920c646cf03dcc161a6fbc928a6dc09b2d7f1
Merged-In: I5fb6c126a090a3fe0fa4829ea9224564133dc1ae
2019-02-12 17:10:15 -08:00
Hervé Guihot
70d25b813e Added missing ASSERT_NE.
Test was failing with segmentation fault (and crashing whole VTS) when
device was not available.

Change-Id: Id0f28d061dc5858fa00ef1bac5f7aa467d860864
2019-02-12 16:22:44 -08:00
Lev Proleev
2756283e30 Sync docs between NeuralNetworks.h and HAL file
Test: VtsHalNeuralnetworksV1_2TargetTest
Bug: 116445845
Fixes: 124246635
(cherry picked from commit 5d2ec0f5f0)
Merged-In: I4287a947faa260f69ba50c746bd40a0981548e50
Change-Id: I4287a947faa260f69ba50c746bd40a0981548e50
2019-02-12 13:49:56 -08:00
Slava Shklyaev
e94dc72150 Update NNAPI Extensions documentation
This is a follow-up to change Ia9b99015eec7a48bbf969cbe503862271f09adca

Bug: 118605927
Test: mma
Change-Id: I7ddafca04bce6fd37a9c0877270cee325111d833
Merged-In: I7ddafca04bce6fd37a9c0877270cee325111d833
(cherry picked from commit 1ffe69a8e9)
2019-02-12 10:09:51 +00:00
Steven Moreland
f8a47b7f01 Update makefiles.
Bug: 123976090
Test: N/A
Change-Id: I5fb6c126a090a3fe0fa4829ea9224564133dc1ae
2019-02-11 21:14:16 -08:00
Hervé Guihot
86a9fa0900 Added TENSOR_QUANT8_SYMM type.
Test: none
Change-Id: I02fc8698b3f80e1ae2a318e5cde593c6d7222bac
Merged-In: I02fc8698b3f80e1ae2a318e5cde593c6d7222bac
(cherry picked from commit bae91697b5)
2019-02-08 10:35:43 -08:00
Xusong Wang
cf6a9111cc Add new OperandType TENSOR_QUANT16_ASYMM.
Test: NeuralNetworksTest_static
Test: VtsHalNeuralnetworksV1_2TargetTest
Change-Id: I8fcd6b30c32f8fbc181d2b43f9ac0b94fdc57e2f
Merged-In: I8fcd6b30c32f8fbc181d2b43f9ac0b94fdc57e2f
(cherry picked from commit d49f665c42)
2019-02-08 10:17:17 -08:00
Xusong Wang
96e68dc8e0 Add VTS tests for NNAPI compilation caching.
Add the following tests for compilation caching:
- validation tests
  - Test isCachingSupported
  - Test prepareModelFromCache with invalid numFd and invalid access mode
  - Test saveToCache with invalid numFd, invalid access mode,
    invalid file size, and invalid fd offset
- execution test
  - Save a mobilenet model to cache and then retrieve and run accuracy
    evaluation.
  - The same test but the file offsets for prepareModelFromCache is not at zero.
- security test
  - CompilationCachingSecurityTest.CorruptedSecuritySensitiveCache
    Randomly flip one bit of security-sensitive cache.
  - CompilationCachingSecurityTest.WrongLengthSecuritySensitiveCache
    Randomly append bytes to security-sensitive cache.
  - CompilationCachingSecurityTest.WrongToken
    Randomly flip one bit of cache token.

Bug: 119616526
Test: VtsHalNeuralnetworksV1_xTargetTest with 1.2 sample driver
Test: VtsHalNeuralnetworksV1_xTargetTest with a test driver that can
      read and write cache entries
Change-Id: Iae9211cb28ce972b29572dfedd45d1ade4dfdaf5
Merged-In: Iae9211cb28ce972b29572dfedd45d1ade4dfdaf5
(cherry picked from commit 3405878e5e)
2019-02-08 10:17:17 -08:00
Slava Shklyaev
c9ff099c01 Add getSupportedExtensions to NNAPI IDevice
Bug: 118603011
Test: mma
Change-Id: I5bd1cf2dfd8c4700819d52a87931df2959ef6929
Merged-In: I5bd1cf2dfd8c4700819d52a87931df2959ef6929
(cherry picked from commit 6148d0f446)
2019-02-08 10:17:17 -08:00
Slava Shklyaev
bbcdc42abb Define NNAPI Extensions types
Machine Learning is a fast moving domain: new operations and data types
are introduced at a staggering speed. The Android API, on the other
hand, evolves on a yearly cycle. Many application developers, OEMs, and
SoC vendors would like to be able to define new operations at a faster
cycle.

In OC-MR1, NNAPI provided a simple mechanism to mitigate this problem:
two OEM data types and an OEM operation. The downside of this mechanism is that
it is simplistic: There’s no guarantee of consistency between vendors.

Examples of features that are required by the first parties' use cases
that we would like to be able to define outside of the normal Android
release cycle:
- New data types:
  - Sparse tensor (used by some speech generation models).
  - 16 bit int tensor (needed by OCR).
  - 16 bit float tensor.
- New operations:
  - 16 bit quantized LSTM (needed by OCR).
  - Basic primitives like sqrt and floor.
  - Logical operations.
  - Complex neural network layers.
  - Control flow.
- Enhancement to existing operations:
  - Concatenate supporting different scales/zeroPoints for arguments.
  - High-dimensional tensors.
  - Ordering of dimensions.

We are going to provide support for two types of extensions:
- NNAPI Platform extension. This is functionality that will become part of
  future releases of NNAPI. These extensions provide generic,
  non-vendor-specific functionality. Only the Android team can define new
  platform extensions. These extensions will be defined in the master
  branch of AOSP. Each extension comes with:
  - Documentation defining the extension,
  - A header file for the new constants,
  - A parameter validation library to be used by drivers, and
  - Validation tests akin to the CTS and VTS tests.
- Vendor extension. A vendor-specific extension is an alternative to OEM
  operation and data types. Its usage will be limited only to first party apps
  preinstalled on the /vendor or /odm partition.
  Each vendor will be identified by a specific value to
  prevent collisions between multiple IPs found on the same SoC. This
  effectively creates a vendor-specific namespace. These identifiers are
  assigned by Google.

This change only defines the new interface. The implementation follows
in changes Ie4e2530e4c81fabe4eb59b7a6ba4a3b4bb483bd1,
I02aa12f4a8444012ddf3b20c2bfbba6a21ce9ce9, and
Icf59ed04e602aa7a730eb1eb45e5f6b1204fafb3.

Bug: 118605927
Test: mma
Change-Id: Ia9b99015eec7a48bbf969cbe503862271f09adca
Merged-In: Ia9b99015eec7a48bbf969cbe503862271f09adca
(cherry picked from commit 9212018558)
2019-02-08 10:17:17 -08:00
Steven Moreland
94755be332 Merge "Update makefiles." am: b35c23e70c am: b37145e08e
am: d78f1f0d8e

Change-Id: If698913e654c92897db703d865e900e49fe6231d
2019-02-06 12:06:14 -08:00
Lev Proleev
312f58e1a0 Merge "Sync docs between NeuralNetworks.h and HAL file" 2019-02-06 12:47:18 +00:00
Steven Moreland
941f105b60 Update makefiles.
Some of these are out of date.

Bug: N/A
Test: N/A
Change-Id: Ibf87fad9981d4e430a0bf797feadbb0bede232fc
2019-02-05 13:14:26 -08:00
TreeHugger Robot
b7a562e4f3 Merge "Update NNAPI Extensions documentation" 2019-02-01 13:15:29 +00:00
Lev Proleev
5d2ec0f5f0 Sync docs between NeuralNetworks.h and HAL file
Test: VtsHalNeuralnetworksV1_2TargetTest
Fix: 116445845
Change-Id: I4287a947faa260f69ba50c746bd40a0981548e50
2019-01-31 22:23:06 +00:00
Lev Proleev
923b8c5842 Fix VTS tests.
* Adds a specification of invalid scale and zero point for TENSOR_BOOL8.
This fixes vts failures for comparison ops.
* Removes (FUNDAMENTAL_MIN - 1) from invalid OperationTypes.
FUNDAMENTAL_MIN is equal to 0 and resulting -1 was statically casted to
uint32_t and passed 4294967295 as an invalid OperationType. However, our
validateOperation function interpreted this ID as an extension ID and
didn't fail.
* Adds mutateOperationOperandTypeSkip for QUANTIZE and DEQUANTIZE.
* Adds removeOperandSkip for BIDIRECTIONAL_SEQUENCE_RNN.

Fix: 121130841
Fix: 123247345
Test: VtsHalNeuralnetworksV1_2TargetTest --hal_service_instance=android.hardware.neuralnetworks@1.2::IDevice/sample-all
Change-Id: Iefb502c6b9301d5470eb4cdaa46d398f1a0e512a
2019-01-31 14:00:31 +00:00
Slava Shklyaev
2739b2ef57 Shorten NNAPI enum range names
Test: mma
Change-Id: I5138589acc127336e8c0e72ca7d6b49532a4eeb9
Merged-In: I5138589acc127336e8c0e72ca7d6b49532a4eeb9
(cherry picked from commit 794703db84)
2019-01-30 10:49:49 -08:00
Xusong Wang
fc67805f4a Implement NN HAL for compilation caching.
Add three methods
- IDevice::isCachingSupported
- IDevice::prepareModelFromCache
- IPreparedModel::saveToCache

Bug: 119616526
Test: NeuralNetworksTest_static
Test: VtsHalNeuralnetworksV1_xTargetTest with 1.2 sample driver
Change-Id: If28ffe0be48bcb9f4715293fc1201c8d2dbeb946
Merged-In: If28ffe0be48bcb9f4715293fc1201c8d2dbeb946
(cherry picked from commit 89dfafb42f)
2019-01-29 15:00:49 -08:00
TreeHugger Robot
9a42155ffb Merge "Added TENSOR_QUANT8_SYMM type." 2019-01-29 22:31:16 +00:00
Hervé Guihot
bae91697b5 Added TENSOR_QUANT8_SYMM type.
Test: none
Change-Id: I02fc8698b3f80e1ae2a318e5cde593c6d7222bac
2019-01-29 11:45:17 -08:00
Michael Butler
29471a8935 NNAPI Burst -- HAL VTS tests
FastMessageQueue is a Treble-compliant data structure that enables fast
communication between two processes. The FMQ object itself is an atomic
circular buffer that is optionally synchronized with a futex. However,
FMQ has no notion of ownership or lifetime across processes, so it must
be paired with higher-level constructs to manage the lifetime and
ownership.

The NNAPI is introducing the notion of an "Execution Burst" object (or
more simply a "Burst" object), which is similar to an
ANeuralNetworksExecution, but is intended to be reused across multiple
executions and has lower IPC overheads. It achieves this low IPC
overhead by replacing HIDL HwBinder calls with FMQ messages.
Specifically, it replaces IPreparedModel::executeSynchronously's call
from the client into the service with fmq_sync<FmqRequestDatum> (an FMQ
channel used to pass a serialized Request object) and it replaces
the return from the service into the client with
fmq_sync<FmqResultDatum> (an FMQ channel used to return serialized
result status and OutputShapes information).

Each channel is a unidirectional flow of information with exactly one
producer and exactly one consumer. The channels are created by the NN
runtime and passed to the service via
IPreparedModel::configureExecutionBurst.

This CL tests the Burst in both the execution path and validation path
in the Vendor Test Suite (VTS) in neuralnetworks/1.*/vts/functional/.

The VTS binary--VtsHalNeuralnetworksV1_2TargetTest--can be built and run
as any previous version could.

Bug: 119570067
Test: mma
Test: VtsHalNeuralnetworksV1_2TargetTest
Change-Id: I3a36484eff9565c2d028c07c099804a0289f294a
Merged-In: I3a36484eff9565c2d028c07c099804a0289f294a
(cherry picked from commit 814d8372f3)
2019-01-29 18:34:34 +00:00
Slava Shklyaev
1ffe69a8e9 Update NNAPI Extensions documentation
This is a follow-up to change Ia9b99015eec7a48bbf969cbe503862271f09adca

Bug: 118605927
Test: mma
Change-Id: I7ddafca04bce6fd37a9c0877270cee325111d833
2019-01-29 17:49:38 +00:00
Xusong Wang
3405878e5e Add VTS tests for NNAPI compilation caching.
Add the following tests for compilation caching:
- validation tests
  - Test isCachingSupported
  - Test prepareModelFromCache with invalid numFd and invalid access mode
  - Test saveToCache with invalid numFd, invalid access mode,
    invalid file size, and invalid fd offset
- execution test
  - Save a mobilenet model to cache and then retrieve and run accuracy
    evaluation.
  - The same test but the file offsets for prepareModelFromCache is not at zero.
- security test
  - CompilationCachingSecurityTest.CorruptedSecuritySensitiveCache
    Randomly flip one bit of security-sensitive cache.
  - CompilationCachingSecurityTest.WrongLengthSecuritySensitiveCache
    Randomly append bytes to security-sensitive cache.
  - CompilationCachingSecurityTest.WrongToken
    Randomly flip one bit of cache token.

Bug: 119616526
Test: VtsHalNeuralnetworksV1_xTargetTest with 1.2 sample driver
Test: VtsHalNeuralnetworksV1_xTargetTest with a test driver that can
      read and write cache entries
Change-Id: Iae9211cb28ce972b29572dfedd45d1ade4dfdaf5
2019-01-29 08:59:06 -08:00
Slava Shklyaev
6148d0f446 Add getSupportedExtensions to NNAPI IDevice
Bug: 118603011
Test: mma
Change-Id: I5bd1cf2dfd8c4700819d52a87931df2959ef6929
2019-01-28 21:56:18 +00:00
Slava Shklyaev
9212018558 Define NNAPI Extensions types
Machine Learning is a fast moving domain: new operations and data types
are introduced at a staggering speed. The Android API, on the other
hand, evolves on a yearly cycle. Many application developers, OEMs, and
SoC vendors would like to be able to define new operations at a faster
cycle.

In OC-MR1, NNAPI provided a simple mechanism to mitigate this problem:
two OEM data types and an OEM operation. The downside of this mechanism is that
it is simplistic: There’s no guarantee of consistency between vendors.

Examples of features that are required by the first parties' use cases
that we would like to be able to define outside of the normal Android
release cycle:
- New data types:
  - Sparse tensor (used by some speech generation models).
  - 16 bit int tensor (needed by OCR).
  - 16 bit float tensor.
- New operations:
  - 16 bit quantized LSTM (needed by OCR).
  - Basic primitives like sqrt and floor.
  - Logical operations.
  - Complex neural network layers.
  - Control flow.
- Enhancement to existing operations:
  - Concatenate supporting different scales/zeroPoints for arguments.
  - High-dimensional tensors.
  - Ordering of dimensions.

We are going to provide support for two types of extensions:
- NNAPI Platform extension. This is functionality that will become part of
  future releases of NNAPI. These extensions provide generic,
  non-vendor-specific functionality. Only the Android team can define new
  platform extensions. These extensions will be defined in the master
  branch of AOSP. Each extension comes with:
  - Documentation defining the extension,
  - A header file for the new constants,
  - A parameter validation library to be used by drivers, and
  - Validation tests akin to the CTS and VTS tests.
- Vendor extension. A vendor-specific extension is an alternative to OEM
  operation and data types. Its usage will be limited only to first party apps
  preinstalled on the /vendor or /odm partition.
  Each vendor will be identified by a specific value to
  prevent collisions between multiple IPs found on the same SoC. This
  effectively creates a vendor-specific namespace. These identifiers are
  assigned by Google.

This change only defines the new interface. The implementation follows
in changes Ie4e2530e4c81fabe4eb59b7a6ba4a3b4bb483bd1,
I02aa12f4a8444012ddf3b20c2bfbba6a21ce9ce9, and
Icf59ed04e602aa7a730eb1eb45e5f6b1204fafb3.

Bug: 118605927
Test: mma
Change-Id: Ia9b99015eec7a48bbf969cbe503862271f09adca
2019-01-28 21:56:18 +00:00
Slava Shklyaev
794703db84 Shorten NNAPI enum range names
Test: mma
Change-Id: I5138589acc127336e8c0e72ca7d6b49532a4eeb9
2019-01-28 21:30:40 +00:00
Xusong Wang
14393d0e24 Merge "Implement NN HAL for compilation caching." 2019-01-26 16:59:51 +00:00
Michael Butler
814d8372f3 NNAPI Burst -- HAL VTS tests
FastMessageQueue is a Treble-compliant data structure that enables fast
communication between two processes. The FMQ object itself is an atomic
circular buffer that is optionally synchronized with a futex. However,
FMQ has no notion of ownership or lifetime across processes, so it must
be paired with higher-level constructs to manage the lifetime and
ownership.

The NNAPI is introducing the notion of an "Execution Burst" object (or
more simply a "Burst" object), which is similar to an
ANeuralNetworksExecution, but is intended to be reused across multiple
executions and has lower IPC overheads. It achieves this low IPC
overhead by replacing HIDL HwBinder calls with FMQ messages.
Specifically, it replaces IPreparedModel::executeSynchronously's call
from the client into the service with fmq_sync<FmqRequestDatum> (an FMQ
channel used to pass a serialized Request object) and it replaces
the return from the service into the client with
fmq_sync<FmqResultDatum> (an FMQ channel used to return serialized
result status and OutputShapes information).

Each channel is a unidirectional flow of information with exactly one
producer and exactly one consumer. The channels are created by the NN
runtime and passed to the service via
IPreparedModel::configureExecutionBurst.

This CL tests the Burst in both the execution path and validation path
in the Vendor Test Suite (VTS) in neuralnetworks/1.*/vts/functional/.

The VTS binary--VtsHalNeuralnetworksV1_2TargetTest--can be built and run
as any previous version could.

Bug: 119570067
Test: mma
Test: VtsHalNeuralnetworksV1_2TargetTest
Change-Id: I3a36484eff9565c2d028c07c099804a0289f294a
2019-01-25 14:28:51 -08:00
Xusong Wang
89dfafb42f Implement NN HAL for compilation caching.
Add three methods
- IDevice::isCachingSupported
- IDevice::prepareModelFromCache
- IPreparedModel::saveToCache

Bug: 119616526
Test: NeuralNetworksTest_static
Test: VtsHalNeuralnetworksV1_xTargetTest with 1.2 sample driver
Change-Id: If28ffe0be48bcb9f4715293fc1201c8d2dbeb946
2019-01-25 11:21:03 -08:00
Xusong Wang
d22c5232f3 Test dynamic output shape in GeneratedTests.
Enable VTS unit test for dynamic output shape deduction.

Only test dynamic output shape for V1_2::IDevice with V1_2::Model.

Bug: 73506513
Test: VtsHalNeuralnetworksV1_xTargetTest with 1.2 sample driver
Change-Id: I4134e1ec54a15554eb8533134897279651b57da3
Merged-In: I4134e1ec54a15554eb8533134897279651b57da3
(cherry picked from commit a316581b21)
2019-01-24 19:11:36 -08:00
David Gross
55a3d328b7 Update neuralnetworks HAL to allow collecting execution duration.
Test: VtsHalNeuralnetworksV1_0TargetTest --hal_service_instance=android.hardware.neuralnetworks@1.0::IDevice/sample-all
Test: VtsHalNeuralnetworksV1_1TargetTest --hal_service_instance=android.hardware.neuralnetworks@1.1::IDevice/sample-all
Test: VtsHalNeuralnetworksV1_2TargetTest --hal_service_instance=android.hardware.neuralnetworks@1.2::IDevice/sample-all

Bug: 115390094

Change-Id: If67a5ffe39cfdd78498e01f26251734fdc8e66c7
Merged-In: If67a5ffe39cfdd78498e01f26251734fdc8e66c7
(cherry picked from commit e301349b05)
2019-01-24 16:07:03 -08:00
Xusong Wang
5d67a0bf05 Clean and reorder operation enums.
Four operation enums are removed:
- DETECTION_OUTPUT
- PRIOR_BOX
- SPARSE_TO_DENSE
- EMBEDDING_LOOKUP_SPARSE

Operation enums are reorder into alphabetic order.

Bug: 123253865
Bug: 122744669
Test: NeuralNetworksTest_static
Change-Id: Ie5d2bff6fac061bdca0a99e5b8c8ac05733fac4b
Merged-In: Ie5d2bff6fac061bdca0a99e5b8c8ac05733fac4b
(cherry picked from commit 28a33a9cb1)
2019-01-24 16:05:33 -08:00
Lev Proleev
2d98264026 mutateOperationOperandTypeSkip for new TRANSPOSE_CONV_2D variant
Bug: 119255406
Test: Vts NNAPI tests.
Change-Id: I63f7fc67cedcc2a9db8c359ff96be3c9403b9a20
Merged-In: I63f7fc67cedcc2a9db8c359ff96be3c9403b9a20
(cherry picked from commit 1509a2664c)
2019-01-24 16:05:08 -08:00
Xusong Wang
b50bc313d7 Add 1.2 NN HAL interface for dynamic output shape.
Let notify_1_2() notify output shapes.

Document unspecified dimensions and rank.

Bug: 73506513
Bug: 77234888
Test: NeuralNetworksTest_static
Test: VtsHalNeuralnetworksV1_xTargetTest with 1.2 sample driver
Change-Id: I01108913212d9f4aa47daf2f293ea19259925865
Merged-In: I01108913212d9f4aa47daf2f293ea19259925865
(cherry picked from commit 187c59715c)
2019-01-24 14:19:00 -08:00
Michael Butler
a06e261af9 NNAPI Burst -- HAL interface
FastMessageQueue is a Treble-compliant data structure that enables fast
communication between two processes. The FMQ object itself is an atomic
circular buffer that is optionally synchronized with a futex. However,
FMQ has no notion of ownership or lifetime across processes, so it must
be paired with higher-level constructs to manage the lifetime and
ownership.

The NNAPI is introducing the notion of an "Execution Burst" object (or
more simply a "Burst" object), which is similar to an
ANeuralNetworksExecution, but is intended to be reused across multiple
executions and has lower IPC overheads. It achieves this low IPC
overhead by replacing HIDL HwBinder calls with FMQ messages.
Specifically, it replaces IPreparedModel::executeSynchronously's call
from the client into the service with fmq_sync<FmqRequestDatum> (an FMQ
channel used to pass a serialized Request object) and it replaces
the return from the service into the client with
fmq_sync<FmqResultDatum> (an FMQ channel used to return serialized
result status and OutputShapes information).

Each channel is a unidirectional flow of information with exactly one
producer and exactly one consumer. The channels are created by the NN
runtime and passed to the service via
IPreparedModel::configureExecutionBurst.

This CL defines the FmqRequestDatum and FmqResultDatum types in
types.hal. IBurstContext.hal defines IBurstContext, a HIDL object used
by the service to manage the resources of a Burst. IBurstCallback.hal
defines IBurstCallback, a HIDL callback object that can be used to
retrieve the handle to a resource the service has either not yet seen or
has evicted from its cache. Finally, IPreparedModel.hal is extended with
IPreparedModel::configureExecutionBurst to create the burst object.

Bug: 119570067
Test: mma
Change-Id: I333da70201531b1396efc714d096c277e8e1d47b
Merged-In: I333da70201531b1396efc714d096c277e8e1d47b
(cherry picked from commit 7e91e24fe1)
2019-01-24 14:04:35 -08:00
Lev Proleev
b35eb1eabc mutateOperationOperandTypeSkip for new GROUPED_CONV_2D variant
Bug: 119255406
Test: Vts NNAPI tests.
Change-Id: I234727f5abba546c1392f7096b7d411d36566bbf
Merged-In: I234727f5abba546c1392f7096b7d411d36566bbf
(cherry picked from commit b0762ccb2f)
2019-01-24 14:04:01 -08:00
Miao Wang
7176fe7a63 Add HAL entry to allow querying the device type
Bug: 111425781
Bug: 112661050
Test: mm
Test: NeuralNetworksTest_static
Change-Id: Iced35c24eb2905c10fbf86d55319fdb5c7488703
Merged-In: Iced35c24eb2905c10fbf86d55319fdb5c7488703
(cherry picked from commit e3b93534c0)
2019-01-24 14:03:59 -08:00
David Gross
95c821918e Merge "Update neuralnetworks HAL to allow collecting execution duration." 2019-01-24 20:51:50 +00:00
TreeHugger Robot
ed85890b79 Merge "Clean and reorder operation enums." 2019-01-24 09:07:49 +00:00
David Gross
e301349b05 Update neuralnetworks HAL to allow collecting execution duration.
Test: VtsHalNeuralnetworksV1_0TargetTest --hal_service_instance=android.hardware.neuralnetworks@1.0::IDevice/sample-all
Test: VtsHalNeuralnetworksV1_1TargetTest --hal_service_instance=android.hardware.neuralnetworks@1.1::IDevice/sample-all
Test: VtsHalNeuralnetworksV1_2TargetTest --hal_service_instance=android.hardware.neuralnetworks@1.2::IDevice/sample-all

Bug: 115390094

Change-Id: If67a5ffe39cfdd78498e01f26251734fdc8e66c7
2019-01-23 14:01:52 -08:00
Xusong Wang
28a33a9cb1 Clean and reorder operation enums.
Four operation enums are removed:
- DETECTION_OUTPUT
- PRIOR_BOX
- SPARSE_TO_DENSE
- EMBEDDING_LOOKUP_SPARSE

Operation enums are reorder into alphabetic order.

Bug: 123253865
Bug: 122744669
Test: NeuralNetworksTest_static
Change-Id: Ie5d2bff6fac061bdca0a99e5b8c8ac05733fac4b
2019-01-23 11:47:54 -08:00
Michael Butler
f96dc6ed8f Merge "NNAPI Burst -- HAL interface" 2019-01-23 19:17:06 +00:00
Michael Butler
7e91e24fe1 NNAPI Burst -- HAL interface
FastMessageQueue is a Treble-compliant data structure that enables fast
communication between two processes. The FMQ object itself is an atomic
circular buffer that is optionally synchronized with a futex. However,
FMQ has no notion of ownership or lifetime across processes, so it must
be paired with higher-level constructs to manage the lifetime and
ownership.

The NNAPI is introducing the notion of an "Execution Burst" object (or
more simply a "Burst" object), which is similar to an
ANeuralNetworksExecution, but is intended to be reused across multiple
executions and has lower IPC overheads. It achieves this low IPC
overhead by replacing HIDL HwBinder calls with FMQ messages.
Specifically, it replaces IPreparedModel::executeSynchronously's call
from the client into the service with fmq_sync<FmqRequestDatum> (an FMQ
channel used to pass a serialized Request object) and it replaces
the return from the service into the client with
fmq_sync<FmqResultDatum> (an FMQ channel used to return serialized
result status and OutputShapes information).

Each channel is a unidirectional flow of information with exactly one
producer and exactly one consumer. The channels are created by the NN
runtime and passed to the service via
IPreparedModel::configureExecutionBurst.

This CL defines the FmqRequestDatum and FmqResultDatum types in
types.hal. IBurstContext.hal defines IBurstContext, a HIDL object used
by the service to manage the resources of a Burst. IBurstCallback.hal
defines IBurstCallback, a HIDL callback object that can be used to
retrieve the handle to a resource the service has either not yet seen or
has evicted from its cache. Finally, IPreparedModel.hal is extended with
IPreparedModel::configureExecutionBurst to create the burst object.

Bug: 119570067
Test: mma
Change-Id: I333da70201531b1396efc714d096c277e8e1d47b
2019-01-22 20:23:08 -08:00
Lev Proleev
1509a2664c mutateOperationOperandTypeSkip for new TRANSPOSE_CONV_2D variant
Bug: 119255406
Test: Vts NNAPI tests.
Change-Id: I63f7fc67cedcc2a9db8c359ff96be3c9403b9a20
2019-01-22 15:20:13 +00:00
Lev Proleev
b0762ccb2f mutateOperationOperandTypeSkip for new GROUPED_CONV_2D variant
Bug: 119255406
Test: Vts NNAPI tests.
Change-Id: I234727f5abba546c1392f7096b7d411d36566bbf
2019-01-21 11:37:28 +00:00
Xusong Wang
f637f04a36 Merge "Add new OperandType TENSOR_QUANT16_ASYMM." 2019-01-19 03:37:04 +00:00
Xusong Wang
02838e4b0d Merge "Test dynamic output shape in GeneratedTests." 2019-01-19 00:20:30 +00:00
Xusong Wang
d49f665c42 Add new OperandType TENSOR_QUANT16_ASYMM.
Test: NeuralNetworksTest_static
Test: VtsHalNeuralnetworksV1_2TargetTest
Change-Id: I8fcd6b30c32f8fbc181d2b43f9ac0b94fdc57e2f
2019-01-18 14:50:17 -08:00
Xusong Wang
a316581b21 Test dynamic output shape in GeneratedTests.
Enable VTS unit test for dynamic output shape deduction.

Only test dynamic output shape for V1_2::IDevice with V1_2::Model.

Bug: 73506513
Test: VtsHalNeuralnetworksV1_xTargetTest with 1.2 sample driver
Change-Id: I4134e1ec54a15554eb8533134897279651b57da3
2019-01-17 18:39:08 -08:00
Miao Wang
e3b93534c0 Add HAL entry to allow querying the device type
Bug: 111425781
Bug: 112661050
Test: mm
Test: NeuralNetworksTest_static
Change-Id: Iced35c24eb2905c10fbf86d55319fdb5c7488703
2019-01-17 17:23:38 -08:00
Xusong Wang
0ba24d97b6 Merge "Add 1.2 NN HAL interface for dynamic output shape." 2019-01-11 04:42:42 +00:00
Xusong Wang
187c59715c Add 1.2 NN HAL interface for dynamic output shape.
Let notify_1_2() notify output shapes.

Document unspecified dimensions and rank.

Bug: 73506513
Bug: 77234888
Test: NeuralNetworksTest_static
Test: VtsHalNeuralnetworksV1_xTargetTest with 1.2 sample driver
Change-Id: I01108913212d9f4aa47daf2f293ea19259925865
2019-01-10 15:52:51 -08:00
Xusong Wang
1f59bc3b24 Modify operation enum.
Remove ROTATED_BBOX_TRANSFORM since it is no longer needed.
Add DETECTION_POSTPROCESS for SSD NMS postprocessing op.

Bug: 120983926
Test: NeuralNetworksTest_static
Change-Id: Id6b1021c8707734499feddddf0aac24a3fff90f8
2019-01-10 12:20:34 -08:00
Przemyslaw Szczepaniak
725f68487a mutateOperationOperandTypeSkip for new DEPTHWISE_CONV_2D variant.
Bug: 119255406
Test: Vts NNAPI tests.
Change-Id: Iaeb1ef1095dde51e9324f526a2126ed5d0491586
Merged-In: Iaeb1ef1095dde51e9324f526a2126ed5d0491586
(cherry picked from commit 47b9141609)
2019-01-10 18:12:28 +00:00
Xusong Wang
c3ea0775ba Add INSTANCE_NORMALIZATION to operation enum.
Bug: 120064464
Test: NeuralNetworksTest_static
Change-Id: Ia81c8e4a79e65275e4a85b93e3bc18a02ac2cbb0
Merged-In: Ia81c8e4a79e65275e4a85b93e3bc18a02ac2cbb0
(cherry picked from commit 897c0afbdf)
2019-01-10 18:08:27 +00:00
Przemyslaw Szczepaniak
2fadc84792 mutateOperationOperandTypeSkip for new CONV_2D variant.
Bug: 119255406
Test: Vts NNAPI tests.
Change-Id: I265ae4968f5fe3589d79e5846a7d640a735a012f
Merged-In: I265ae4968f5fe3589d79e5846a7d640a735a012f
(cherry picked from commit f54f12634c)
2019-01-10 08:16:56 +00:00
Michael K. Sanders
41e6732a66 Adds float16 support for RANDOM_MULTINOMIAL.
Bug: 118607845
Test: VtsHalNeuralnetworksV1_2TargetTest --hal_service_instance=android.hardware.neuralnetworks@1.2::IDevice/sample-all
Change-Id: Iac8c0c23a8219702697a7a126e5e2e43ef0461f4
Merged-In: Iac8c0c23a8219702697a7a126e5e2e43ef0461f4
(cherry picked from commit 5b2615be21)
2019-01-10 08:16:38 +00:00
Przemyslaw Szczepaniak
4766f8b1a1 Add TENSOR_QUANT8_SYMM_PER_CHANNEL to operand types
Added ExtraParams union for extra Operand parameters.
It's a more sensible approach than adding more fields
to the Operand struct.

Bug: 119249581
Test: NeuralNetworksTest_static
Test: VtsHalNeuralnetworksV1_0TargetTest
Test: VtsHalNeuralnetworksV1_1TargetTest
Test: VtsHalNeuralnetworksV1_2TargetTest
Change-Id: I59731134cf0ea34cf9e10342686d331da9e9c3b3
Merged-In: I59731134cf0ea34cf9e10342686d331da9e9c3b3
(cherry picked from commit faa59b8a2c)
2019-01-10 08:15:58 +00:00
Slava Shklyaev
edf67ee8e7 Add REDUCE_* operations
Bug: 113564646
Test: mma
Change-Id: I6088e270c0167bcf8fc6c4002ed7f4e939b6d435
Merged-In: I6088e270c0167bcf8fc6c4002ed7f4e939b6d435
(cherry picked from commit 4fdb8b5727)
2019-01-09 09:45:33 +00:00