Expose the TfLiteDelegateFlags params for simple delegate creation. This allows more flexibility for example users want to implement a delegate takes in custom op.

PiperOrigin-RevId: 341749773
Change-Id: I89ece3af61750fded53c810d3aa63ba0aafb9740
This commit is contained in:
Renjie Liu 2020-11-10 20:00:26 -08:00 committed by TensorFlower Gardener
parent 24d1fba948
commit 696102807d
2 changed files with 7 additions and 3 deletions

View File

@ -113,13 +113,13 @@ TfLiteStatus DelegatePrepare(TfLiteContext* context,
} // namespace
TfLiteDelegate* TfLiteDelegateFactory::CreateSimpleDelegate(
std::unique_ptr<SimpleDelegateInterface> simple_delegate) {
std::unique_ptr<SimpleDelegateInterface> simple_delegate, int64_t flag) {
if (simple_delegate == nullptr) {
return nullptr;
}
auto delegate = new TfLiteDelegate();
delegate->Prepare = &DelegatePrepare;
delegate->flags = kTfLiteDelegateFlagsNone;
delegate->flags = flag;
delegate->CopyFromBufferHandle = nullptr;
delegate->CopyToBufferHandle = nullptr;
delegate->FreeBufferHandle = nullptr;

View File

@ -114,8 +114,12 @@ class TfLiteDelegateFactory {
public:
// Creates TfLiteDelegate from the provided SimpleDelegateInterface.
// The returned TfLiteDelegate should be deleted using DeleteSimpleDelegate.
// A simple usage of the flags bit mask:
// CreateSimpleDelegate(..., kTfLiteDelegateFlagsAllowDynamicTensors |
// kTfLiteDelegateFlagsRequirePropagatedShapes)
static TfLiteDelegate* CreateSimpleDelegate(
std::unique_ptr<SimpleDelegateInterface> simple_delegate);
std::unique_ptr<SimpleDelegateInterface> simple_delegate,
int64_t flags = kTfLiteDelegateFlagsNone);
// Deletes 'delegate' the passed pointer must be the one returned
// from CreateSimpleDelegate.