History log of /frameworks/ml/nn/runtime/ExecutionBuilder.cpp
Revision Date Author Comments (<<< Hide modified files) (Show modified files >>>)
64031fa26110e6d57896bfdbe1cd58e69cde3dbb 11-Apr-2018 Miao Wang <miaowang@google.com> Remove pointer values from the log and hide certain verbose logging
unless building with NN_DEBUGGABLE.

Bug: 77605132
Test: mm
Test: NeuralNetworksTest_static on walleye-eng with "debug.nn.vlog 1"
All tests pass and complete verbose logging are seen in logcat.
Test: NeuralNetworksTest_static on walleye-user with "debug.nn.vlog 1"
All tests pass and *no* pointers showing in NNAPI verbose logging.
Change-Id: Icc7357cded3ec5c197e9a4418d327b10c2ac7178
/frameworks/ml/nn/runtime/ExecutionBuilder.cpp
1e9666208595bc251a8958155b1e41eca90b69db 12-Apr-2018 Michael Butler <butlermichael@google.com> NNAPI: Add execution preference to prepareModel (runtime)

A model can be compiled in different ways to optimize for different
use-cases. This CL propagates the execution preference across the HAL so
that the NN service can better fit the users needs.

Bug: 77864669
Test: mma
Test: NeuralNetworksTest_static
Test: VtsHalNeuralnetworksV1_1TargetTest
Change-Id: I93079b18224ea10cb0a23bfbdc1ed80e302071a8
/frameworks/ml/nn/runtime/ExecutionBuilder.cpp
07ed4d56a34eb1023c308f40ad7a0a1d07816642 06-Apr-2018 David Gross <dgross@google.com> Map execution failure error status from driver through NN API to client.

Previously, we only ensured that we get ANEURALNETWORKS_NO_ERROR iff
ErrorStatus::NONE -- that is, we knew whether or not we have an error,
but not the kind of error we have.

With this change, we try to do a sensible mapping from driver error
kind to API error kind.

Test: NeuralNetworksTest_static

Bug: 77639748

Change-Id: I2d186c11c3fe01150cd0f66d40882590c2c05e9b
/frameworks/ml/nn/runtime/ExecutionBuilder.cpp
43d018d1a66872031568857fa369024c9640a085 20-Mar-2018 Miao Wang <miaowang@google.com> Enforce validations for ANeuralNetworksExecution_setInput/Output

- Optional output / input must have both nullptr as buffer and 0 as
length.
- If newType is NULL, the operand dimensions must be fully specified.
And ModelArgumentInfo.dimensions will be the same as the operand
dimensions.
- For non-optional input / output, user provided length must match the
operand size.

Bug: 75980924
Test: mm
Test: NeuralNetworksTests
Change-Id: Iaa8f8193c8a6911afd0990fcf0659d0050de833b
/frameworks/ml/nn/runtime/ExecutionBuilder.cpp
75886e77f9ca074173a49283b5c0a8c182d98977 23-Jan-2018 Michael Butler <butlermichael@google.com> Upgrade NeuralNetworks v1.0 to v1.1.

For Android P, the NNAPI is getting new operations. To support this
change, the NN runtime needs to handle both v1.0 and v1.1. This change
brings the NN runtime up to v1.1 and adds a VersionedIDevice class which
manages both v1.0 and v1.1 calls.

Test: mm
Test: cts and vts test binaries
Change-Id: Iaec1dcfe00c1712a0ac89954ae142d4ea126989d
/frameworks/ml/nn/runtime/ExecutionBuilder.cpp
46a54e8a58e39c2fcb3448de04be76d95e744618 19-Jan-2018 Chenjie Luo <cjluo@google.com> Fix dimension not initialized error

updateDimensionInfo crashes when newType is not null since dimension
object is not initialized.

Bug: 72129610
Test: NeuralNetworksOemTest
Change-Id: I97a5868ddc50d17e367f1065524e20cf81d30a02
/frameworks/ml/nn/runtime/ExecutionBuilder.cpp
4cb4fa2fe863a8f404c0448da160dd5bb4187db4 01-Dec-2017 David Gross <dgross@google.com> "Canonicalize" class RunTimePoolInfo.

This class manages an important resource (an mmap() memory) region.
Rather than treating the class as a bundle of state with methods to
explicitly manipulate that resource, give it the full C++ concrete data
type treatment: Constructors, destructor, and move assignment, with all
data private. Now the lifetime of the managed resource matches the
lifetime of the class instance that manages the resource: The resource
is freed when the instance is destroyed or assigned to.

Test: nn/runtime/test

Bug: 69685100
Bug: 69929024
Change-Id: Ib53a4c70d8db496d69a584d501f0aa6f74ddea99
/frameworks/ml/nn/runtime/ExecutionBuilder.cpp
06b5a0a85abe10b618a3a5ed023ac5c74678647e 30-Nov-2017 David Gross <dgross@google.com> Fix RunTimePoolInfo leak of shared memory regions.

SamplePreparedModel and StepExecutor call RunTimePoolInfo::set(), which
calls mmap(), but there is no corresponding call to munmap(). The fix
is to add a new method runTimePoolInfo::release(), and call it from the
appropriate points.

Without this fix, even if we don't run out of virtual address space,
we can still run up against a kernel limit in the number of mapped regions
("/proc/sys/vm/max_map_count").

ALSO: Add a missing check for HIDL transport error (isOk()).

Test: nn/runtime/test

Bug: 69685100
Change-Id: If6ac1396e89cd738738a6ae3397450bd1d80f506
/frameworks/ml/nn/runtime/ExecutionBuilder.cpp
c4c264098a728268ad28084ea6e0263d9c1d7868 16-Nov-2017 David Gross <dgross@google.com> Fix for cases where a model output is a submodel input.

Also:
- Added more error checking.
- Added more logging.
- Fixed some comments.
- Simplified some testing interfaces.
- Fixed some indentation.

Test: nn/runtime/test

Bug: 69166603

Change-Id: I38e33f28ff7885958a8146c650a3c59a2372d803
/frameworks/ml/nn/runtime/ExecutionBuilder.cpp
c2f1c1198c84f5a75fc2305935155f33b8ff5db2 13-Nov-2017 David Gross <dgross@google.com> Add more testing interfaces to CompilationBuilder.

- Ability to override DeviceManager's partitioning setting.
- Ability to compile against a specified list of Devices.
- Ability to retrieve the ExecutionPlan.

Test: nn/runtime/test with debug.nn.partition unset and set to 0
Change-Id: Iae2ae7fdaf13335acd2856cdc93fa259bbe52bba
/frameworks/ml/nn/runtime/ExecutionBuilder.cpp
1da8fed77c5c296afa18f754ec3616e7f02a4cfd 12-Oct-2017 Jean-Luc Brouillet <jeanluc@google.com> Pass large model operand values in shared memory.

Because of a limitation in HIDL, large tensor values (e.g. weights)
need to pass in shared memory rather than as HIDL arguments. This
prevented large models from running on a driver.

Separated the handling of memory pools so that request and model
pools are not comingled.

Also improve logging so we see more details about the models when
logging.

Bug: 67603060
Test: Ran system tests and VTS tests.

Change-Id: I760e31275699f9306c4b21945935dc3a4ca68754
/frameworks/ml/nn/runtime/ExecutionBuilder.cpp
820215d28bed6c90f696cde0f282445d16da432e 05-Oct-2017 Miao Wang <miaowang@google.com> Allow fine grain verbose logging control through system property.

- Existing DEBUG and INFO change to the new mechanism, existing ERROR and
WARNING unchanged.
- By default, all verbose logging are disabled.
- setprop debug.nn.vlog 1 enables all verbose logging.
- setprop debug.nn.vlog "tag1 tag2 ..." only enable the selected tags.
- Available tags:
all: same as 1.
model: enable logging with tag MODEL.
compilation: enable logging with tag COMPILATION.
execution: enable logging with tag EXECUTION.
cpuexe: enable logging with tag CPUEXE.
manager: enable logging with tag MANAGER.
driver: enable logging with tag DRIVER.

Bug: 63905942
Test: mm
Test: NeuralNetworksTests pass
Test: manually set property to allow individual module to logging
verbosely
Test: tested with debug.nn.partition default -> 0 -> 1 to make
sure getProp still works fine

Change-Id: Iaa0ffa62176dabcdc35058748597df720fd6e47e
/frameworks/ml/nn/runtime/ExecutionBuilder.cpp
5e8feed5e8a07bab1ec395e5a01bb8900db00cec 05-Oct-2017 David Gross <dgross@google.com> Add CPU fallback and remove non-plan driver path.

When we do ExecutionPlan-controlled execution, and
there is a failure at some stage of the execution,
fall back to cpu execution for that one stage (if
possible) or for the entire model (otherwise).

When we don't do ExecutionPlan-controlled execution,
we no longer attempt to find a suitable driver for
full-model execution -- instead, we execute the full
model on the cpu. (Rationale: This avoids having
to implement cpu fallback outside ExecutionPlan-
controlled execution.)

Bug: 63905942
Test: mma (userdebug)
ml/nn/runtime/tests (userdebug)
(with debug.nn.partition.test 1,
no new failures; hand-insert
errors in the runtime in a few
places to exercise some of the
fallback paths, and verified that
behavior is as expected)

Change-Id: I9ec8fba632f94e04840a786575d338d06fd2dcd3
/frameworks/ml/nn/runtime/ExecutionBuilder.cpp
8fb14e90ceb360adfbac0f708d27161b7c5b7fc5 05-Oct-2017 David Gross <dgross@google.com> Allocate all inter-partition temporaries to a single Memory object.

Previous behavior was to allocate each inter-partition temporary
to its own Memory object. The Android system limits the number
of shared memory objects, which is what our Memory objects represent;
so as long as all inter-partition temporaries have the same lifetime
(which they do in our present implementation) it is better to put
them all in the same Memory object.

Bug: 63905942
Test: mma (userdebug)
ml/nn/runtime/tests (userdebug)
(with debug.nn.partition.test 1 and 2;
no new failures)

Change-Id: Ia0ccf4e47aa93d40db0ff5f496662523622caf08
/frameworks/ml/nn/runtime/ExecutionBuilder.cpp
e3178825b8686f3300a895572691a2e8c1f0676b 05-Oct-2017 David Gross <dgross@google.com> Asynchronus partitioned execution, plus minor code cleanup.

Partioned execution is now asynchronous end-to-end, although
the individual execution steps are serialized with respect to
one another.

Other changes:
- Minor code cleanup per comments from previous CL
https://googleplex-android-review.git.corp.google.com/#/c/platform/frameworks/ml/+/3000624/
including comments on memory management for
inter-partition temporaries.
- Remove "simulation" form of partitioning, and renumber
values of debug.nn.partition property accordingly.
- Fix android:nn:wrapper::Event -- add missing contructor
and fix comment.

Bug: 63905942
Test: mma (user)
mma (userdebug)
ml/nn/runtime/tests (userdebug)
(and spot check that debug.nn.partition unspecified,
0, and 1 exhibits the correct control over
partitioning behavior)

Change-Id: I5767d2144c4a42258444a6445866529919d4fe8d
/frameworks/ml/nn/runtime/ExecutionBuilder.cpp
4d83c52f52613585f7b86368be762b2857f7460f 04-Oct-2017 David Gross <dgross@google.com> Fix build breakage.

Two conflicting CLs

https://googleplex-android-review.git.corp.google.com/#/c/platform/frameworks/ml/+/2972138/
https://googleplex-android-review.git.corp.google.com/#/c/platform/frameworks/ml/+/3000624/

were tested independently and then checked in.

Bug: 63905942
Test: ExecutionBuilder.cpp compiles without error
Change-Id: I3d103d46b83aafd71f78fe4ed724d0ffaae9cc6b
/frameworks/ml/nn/runtime/ExecutionBuilder.cpp
69d24339cfca4979e4f3af884c455935a9909793 04-Oct-2017 David Gross <dgross@google.com> Merge changes I04c71d70,I58b763bc into oc-mr1-dev

* changes:
Make partitioning and execution of partitioned plan the default.
Manage inter-partition temporaries.
a3bed7887a65e0662080d2630e228954ca578ca3 04-Oct-2017 TreeHugger Robot <treehugger-gerrit@google.com> Merge "Fix problem passing null optional operands." into oc-mr1-dev
a2a03635c8f215cb75be68ff1939bf4dec285ef8 03-Oct-2017 David Gross <dgross@google.com> Make partitioning and execution of partitioned plan the default.

Also, rename the debug.nn.partition.test property to
debug.nn.partition, and slightly change the interpretation of its
values:
2: the default: partitioned execution, with a fallback to
non-partitioned execution if there is a partitioning failure
3: a new value: partitioned execution, with NO fallback to
non-partitioned execution if there is a partitioning failure

Bug: 63905942
Test: mma (user)
ml/nn/runtime/tests (user)
(no new failures, logcat looks plausible,
debug.nn.partition 0 and 3 have no effect)
mma (userdebug)
ml/nn/runtime/tests (userdebug)
(with debug.nn.partition unspecified, 0, 1, 2, and 3;
no new failures, logcat looks plausible; also tried
manually introducing failures several places in the
partitioning process to ensure that simulation/fallback
behavior works properly for different values of
debug.nn.partition)

Change-Id: I04c71d7009aa0d1c971833a2af5816ff5830ecc9
/frameworks/ml/nn/runtime/ExecutionBuilder.cpp
96811e2b1347889a25bd9686f47ca3cbf061fb1b 02-Oct-2017 David Gross <dgross@google.com> Manage inter-partition temporaries.

This means: Allocate a Memory object for each TEMPORARY in the original
model that is live across partition boundaries; and tell each
StepExecutor about the mapping from a submodel input or output to the
appropriate Memory object.

With these changes, we can now fully execute multiple-partition plans.

Limitations:
- Still under control of debug.nn.partition.test property.
- Cannot handle operands of unknown size, except for model (not
submodel) inputs and outputs.
- Execution is synchronous.

Also: Teach sizeOfData() to work on scalars.

Bug: 63905942
Test: mma (user)
mma (userdebug)
ml/nn/runtime/tests (userdebug)
(with debug.nn.partition.test 0, 1, and 2;
no new failures, logcat looks plausible,
confirmed that GeneratedTests.mobilenet
runs on multiple partitions)

Change-Id: I58b763bc68bf8fe2e0306610c775b854e9292f76
/frameworks/ml/nn/runtime/ExecutionBuilder.cpp
62cc2758c1c2d303861e209f26bddcf4d7564b73 28-Sep-2017 Jean-Luc Brouillet <jeanluc@google.com> Fix problem passing null optional operands.

Allow optional operands to be specified in the model as having no value.
Modify the HAL to allow passing missing operands. Change the validation
of most operations to verify that none of their operands are missing.

Bug: 63905942
Test: Compiled and ran runtime/test.
Change-Id: I378bc51847a8fb30cb2d36c9bf707ebadc79289b
/frameworks/ml/nn/runtime/ExecutionBuilder.cpp
033b8a6ce8ebd2a01ecccc6bae96d0fff8d4964e 23-Sep-2017 Michael Butler <butlermichael@google.com> NNAPI Runtime: Change IEvent to explicit callbacks

IEvent was a synchronization primitive which caused some confusion
in the interface. Originally the event object was paired with an
asynchronous task, and the asynchronous task would signal this event
when the corresponding output was ready to be used.

In the case of IDevice::prepareModel, the function call would return an
IPreparedModel object that was not guaranteed to be prepared until the
runtime had returned from waiting on the corresponding event object.
The event object has been changed to two explicit callbacks--
IPreparedModelCallback and IExecutionCallback. Now,
IDevice::prepareModel no longer returns an unfinished IPreparedModel;
instead, it will pass the IPreparedModel object to the runtime through
IPreparedModelCallback::notify. When the runtime retreives the
IPreparedModel object, the asynchronous task has already finished
preparing the model.

The two callbacks are used for different purposes. Each has its own
version of notify to pass the data back to the runtime:
* IPreparedModelCallback::notify(ErrorStatus, IPreparedModel)
* IExecutionCallback::notify(ErrorStatus)

Bug: 63905942
Test: mm, vts, ml/nn/runtime/tests
Change-Id: I5cd2734a9fc1377546d55a12955445b6ccdd47b3
/frameworks/ml/nn/runtime/ExecutionBuilder.cpp
891b10f7048c62a37a74c4b570be220089dfd55e 02-Oct-2017 David Gross <dgross@google.com> Add ExecutionPlan::Controller support for Compound plans.

This includes proper handling of ExecutionBuilder inputs
and outputs, but not of inter-partition temporaries that
need to become inputs and outputs.

When debug.nn.partitioning.test > 0, always use Controller,
instead of the prior behavior of only using it when
debug.nn.partitioning.test > 1 and the plan is "in scope"
for execution.

If a combination of the partitioning property value and
the plan's shouldBeExecutable() say the plan shouldn't
be given control, then we do simulated execution under
control of the plan before real execution without using
the plan. This allows us to test StepExecutors.

("Simulated execution" means iterating through the
StepExecutors without using them to perform any computation.)

Bug: 63905942
Test: mma (user)
mma (userdebug)
ml/nn/runtime/tests (userdebug)
(with debug.nn.partition.test 0, 1, and 2;
no new failures, logcat looks plausible)

Change-Id: I3a05f5479e906eb13f65e27b17e7129bfcceac0d
/frameworks/ml/nn/runtime/ExecutionBuilder.cpp
b26049114bc4c64e6bea3a5d5d129fcaec8e69b6 02-Oct-2017 David Gross <dgross@google.com> Use ExecutionPlan to control (possibly multiple step) execution.

- Split StepExecutor out from ExecutionBuilder. ExecutionBuilder
represents the description of an execution passed in through the
NNAPI; StepExecutor is used to perform a single "step" of that
execution on a single device (or CPU).

- Introduce ExecutionPlan::Controller class. This is a token used
to allow ExecutionBuilder::startCompute() to iterate over a sequence
of steps provided by ExecutionPlan, obtaining a StepExecutor for each
one.

There should be no change from previous behavior; this is code
reorganization in preparation for supporting execution of partitioned
models. While ExecutionPlan is still only used when the property
debug.nn.partition.test is set to 0, and it still controls the
execution only when that property is set to 2, we do use the new
StepExecutor always.

Bug: 63905942
Test: mma (user)
mma (userdebug)
ml/nn/runtime/tests (userdebug)
(with debug.nn.partition.test 0, 1, and 2;
no new failures, logcat looks plausible)

Change-Id: I17473210bcc5de40603d439ec49374030d1b8f36
/frameworks/ml/nn/runtime/ExecutionBuilder.cpp
0798f3e98982252fb9115ec3369b40b78db87747 30-Sep-2017 David Gross <dgross@google.com> Merge "Minor code cleanup." into oc-mr1-dev
e413eef7e5f790acdb8e5d07cacfee9afab6f7be 29-Sep-2017 David Gross <dgross@google.com> Minor code cleanup.

- Add comments on allocateSharedMemory() usage.
- Move some data from ExecutionBuilder to startComputeOnDevice()
- Simplify initialization of ModelArgumentInfo.
- Remove declaration of undefined function ExecutionBuilder::updateDimensionInfo().
- Fix code idiom.
(See https://googleplex-android-review.git.corp.google.com/#/c/platform/frameworks/ml/+/2970560/3/nn/runtime/ExecutionPlan.cpp@283)

Bug: 63905942
Test: ml/nn/runtime/tests (no new failures)

Change-Id: I5fa7096e425ba9b391a1f64c6f0ad625c36515b5
/frameworks/ml/nn/runtime/ExecutionBuilder.cpp
47522fce0416bfae1cd26f676f251763cd22c172 29-Sep-2017 David Gross <dgross@google.com> Merge "Finish implementing single-partition graphs." into oc-mr1-dev
1f4381539b7e89c42336ee7cd1addb9a4c317b34 28-Sep-2017 David Gross <dgross@google.com> Finish implementing single-partition graphs.

This includes wiring up the partitioning algorithm
to the NN API compilation and execution phases under
debug.nn.partition.test=2: When we have a single-
partition graph, we rely on the device selection and
compilation performed by the partitioning algorithm,
rather than doing it at execution time as we were
before.

Bug: 63905942
Test: mma (user)
mma (userdebug)
ml/nn/runtime/tests (userdebug)
(with debug.nn.partition.test 0, 1, and 2;
no new failures, logcat looks plausible,
compilation happens at the expected times)

Change-Id: I6cd8b53625588d5aca81c87cc8600735e384b8e0
/frameworks/ml/nn/runtime/ExecutionBuilder.cpp
e127e49e67b53c96eb79f6a9c58f956ad4761227 28-Sep-2017 Jean-Luc Brouillet <jeanluc@google.com> Moved validation to the specific classes.

It's hard to keep track of what's validated when the validations
are found in two files (NeuralNetworks.cpp + one of the other).
Move all the validations except for the initial nullptr check
to the specific file.

Moved some code from Memory.h into the .cpp file.

Adjusted some type size for setInput/Output/*

Adding new validations will be in the future CLs to make
review easier.

Bug: 63905942
Test: Ran local and VTS tests.
Change-Id: I2c448c9b0d3f2e878278f24eafce5720590403f3
/frameworks/ml/nn/runtime/ExecutionBuilder.cpp
ef22aa5727b96e9a0863ef71cfbe3dbdac339408 16-Sep-2017 Jean-Luc Brouillet <jeanluc@google.com> Create mutiple sample test drivers

Create multiple sample test drivers to better test partitioning.

Bug: 63905942
Test: Compiled, ran runtimte/tests and VTS tests.

Change-Id: I037aeb82a849592f3a931bcdc558f32010aa1146
/frameworks/ml/nn/runtime/ExecutionBuilder.cpp
0b9453e41a544f9c780eaa15ad65136ad4662ccb 23-Sep-2017 David Gross <dgross@google.com> More debugging tools for graph partitioning.

1) Under property debug.nn.partition.test, run partitioning
algorithm fropm CompilationBuilder::finish(). We don't
use the results -- this is to produce log output and to
verify that we don't crash.
2) Add a little more LOG(DEBUG) output.

Bug: 63905942
Test: mm (userdebug and user)

Change-Id: I8f0f4477cb9a564dcd55536677687c7914a9b86e
/frameworks/ml/nn/runtime/ExecutionBuilder.cpp
425b2594c76e934dfdbc93209253e3c189571149 14-Sep-2017 David Gross <dgross@google.com> Bring back Event, and wait on Event rather than on Execution.

This is at the recommendation of the API council.

This undoes change I50b8e155d9589210e14920237878a4f295e7755f

Bug: 63905942
Test: nn/runtime/test

Change-Id: I5922f13ae7070f7ec0af035557a9921c88ca9221
/frameworks/ml/nn/runtime/ExecutionBuilder.cpp
d2d0c031c43e8e5aafc75e8a652d79bcc2aaca99 12-Sep-2017 Jean-Luc Brouillet <jeanluc@google.com> Update documentation. Remove IntList.

As NDK council request, updated some documentation and removed
IntList. Other issues will be addressed in other CLs.

Bug: 63905942
Test: Compiled and ran the unit tests.

Change-Id: Iff6898737696daa6bbf41643b07d0a4508af4c0d
/frameworks/ml/nn/runtime/ExecutionBuilder.cpp
3ced3cfd5b8f22b632c35f24e585c4847383b195 13-Sep-2017 David Gross <dgross@google.com> Rename Request to Execution at the API level.

There's a separate notion of Request at the HIDL level;
this is not renamed.

Bug: 63905942
Test: nn/runtime/tests

Change-Id: I671e3b387d735a9091dc5a2d14afbea6b45f444c
/frameworks/ml/nn/runtime/ExecutionBuilder.cpp