summaryrefslogtreecommitdiff
path: root/nn/runtime/ExecutionPlan.h
diff options
context:
space:
mode:
authorXusong Wang <xusongw@google.com>2018-10-25 18:49:54 -0700
committerXusong Wang <xusongw@google.com>2018-12-14 10:57:59 -0800
commit8e0bbbd6b982156823be0ce336f8af2090b47bed (patch)
tree2f182f71a24ae2b28dc09531fc9fb5d1ed6a74db /nn/runtime/ExecutionPlan.h
parent6984a7b7007e427015f6ee3303d7acb039788a1c (diff)
downloadml-8e0bbbd6b982156823be0ce336f8af2090b47bed.tar.gz
Wrap the CpuExecutor as a device during compilation step.
Make Device a common interface for abstraction of CPU fallback as well as the actual driver devices. Modify the compilation steps, mainly the partitioner, to accommodate the change. Make all possible compilation outcomes plan-based, even for the CPU fallback, which is a SIMPLE body running on CPU only. Add validation for invalid empty model and create validation test. Add validation for empty device list passed to introspection and control API and create tests. Bug: 72506261 Test: NeuralNetworksTest_static Change-Id: Ic63036716afb8a0156c77e0cf43456e490783deb
Diffstat (limited to 'nn/runtime/ExecutionPlan.h')
-rw-r--r--nn/runtime/ExecutionPlan.h19
1 files changed, 10 insertions, 9 deletions
diff --git a/nn/runtime/ExecutionPlan.h b/nn/runtime/ExecutionPlan.h
index 518ec2925..78ba59f54 100644
--- a/nn/runtime/ExecutionPlan.h
+++ b/nn/runtime/ExecutionPlan.h
@@ -45,9 +45,7 @@ public:
enum OperandKind { INPUT, OUTPUT };
- ExecutionStep(ExecutionPlan* plan,
- uint32_t stepIndex,
- std::shared_ptr<Device> device);
+ ExecutionStep(ExecutionPlan* plan, uint32_t stepIndex, std::shared_ptr<Device> device);
int addOperation(int operationIndex, const ModelBuilder& fromModel);
int addOperand(uint32_t fromOperandIndex, uint32_t* toOperandIndex,
const ModelBuilder& fromModel, OperandKind kind);
@@ -107,7 +105,7 @@ private:
ExecutionPlan* mPlan;
uint32_t mIndex; // index of step within plan
ModelBuilder mSubModel;
- std::shared_ptr<Device> mDevice; // nullptr signifies CPU
+ std::shared_ptr<Device> mDevice;
std::shared_ptr<VersionedIPreparedModel> mPreparedSubModel; // not used for CPU
// Inputs of original model that are also inputs of this submodel:
@@ -204,8 +202,7 @@ public:
std::shared_ptr<ExecutionStep> createNewStep(const std::shared_ptr<Device> device);
- void becomeSingleStep(const std::shared_ptr<Device> device,
- const ModelBuilder* model);
+ void becomeSingleStep(const std::shared_ptr<Device> device, const ModelBuilder* model);
int finish(const ModelBuilder* fromModel, int32_t executionPreference);
@@ -217,6 +214,10 @@ public:
void dump() const;
+ void reset();
+
+ bool isValid() const { return mState != EMPTY && mBody != nullptr && mBody->mSuccessfulFinish; }
+
// These functions are solely intended for use by unit tests of
// the partitioning algorithm.
enum class Kind { ERROR, EMPTY, SIMPLE, COMPOUND };
@@ -237,14 +238,14 @@ private:
};
struct SimpleBody : Body {
- SimpleBody(std::shared_ptr<Device> device, const ModelBuilder* model) :
- mDevice(device), mModel(model) {}
+ SimpleBody(std::shared_ptr<Device> device, const ModelBuilder* model)
+ : mDevice(device), mModel(model) {}
void dump() const override;
int finish(const ModelBuilder* fromModel, int32_t executionPreference) override;
virtual bool hasSubModelOutputsOfUnknownSize() const override { return false; }
- std::shared_ptr<Device> mDevice; // nullptr signifies CPU
+ std::shared_ptr<Device> mDevice;
const ModelBuilder* mModel;
std::shared_ptr<VersionedIPreparedModel> mPreparedModel; // not used for CPU
};