Add portable (no-op) version of StatefulNnApiDelegate

PiperOrigin-RevId: 249683139
This commit is contained in:
A. Unique TensorFlower 2019-05-23 11:32:52 -07:00 committed by TensorFlower Gardener
parent bb8e8b77e9
commit 9a0e7946a7

View File

@ -19,17 +19,21 @@ namespace tflite {
// Return a non-functional NN API Delegate struct.
TfLiteDelegate* NnApiDelegate() {
static TfLiteDelegate delegate = [] {
TfLiteDelegate delegate = TfLiteDelegateCreate();
delegate.Prepare = [](TfLiteContext* context,
TfLiteDelegate* delegate) -> TfLiteStatus {
// Silently succeed without modifying the graph.
return kTfLiteOk;
};
return delegate;
}();
static StatefulNnApiDelegate* delegate = new StatefulNnApiDelegate();
return delegate;
}
return &delegate;
StatefulNnApiDelegate::StatefulNnApiDelegate(Options /* options */)
: StatefulNnApiDelegate() {}
StatefulNnApiDelegate::StatefulNnApiDelegate()
: TfLiteDelegate(TfLiteDelegateCreate()) {
Prepare = DoPrepare;
}
TfLiteStatus StatefulNnApiDelegate::DoPrepare(TfLiteContext* /* context */,
TfLiteDelegate* /* delegate */) {
return kTfLiteOk;
}
} // namespace tflite