Make ModifyGraphWithDelegate(TfLiteDelegatePtr) public.
PiperOrigin-RevId: 253180610
This commit is contained in:
parent
1bbc7ef9a8
commit
6b181c748b
@ -227,6 +227,13 @@ TfLiteStatus Interpreter::ModifyGraphWithDelegate(TfLiteDelegate* delegate) {
|
|||||||
return kTfLiteOk;
|
return kTfLiteOk;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TfLiteStatus Interpreter::ModifyGraphWithDelegate(TfLiteDelegatePtr delegate) {
|
||||||
|
// Note that we retain ownership of the delegate even if graph modification
|
||||||
|
// fails, as delegate use will be in an indeterminate state at that point.
|
||||||
|
owned_delegates_.push_back(std::move(delegate));
|
||||||
|
return ModifyGraphWithDelegate(owned_delegates_.back().get());
|
||||||
|
}
|
||||||
|
|
||||||
TfLiteStatus Interpreter::SetBufferHandle(int tensor_index,
|
TfLiteStatus Interpreter::SetBufferHandle(int tensor_index,
|
||||||
TfLiteBufferHandle buffer_handle,
|
TfLiteBufferHandle buffer_handle,
|
||||||
TfLiteDelegate* delegate) {
|
TfLiteDelegate* delegate) {
|
||||||
|
@ -373,16 +373,22 @@ class Interpreter {
|
|||||||
/// WARNING: This is an experimental API and subject to change.
|
/// WARNING: This is an experimental API and subject to change.
|
||||||
void SetCancellationFunction(void* data, bool (*check_cancelled_func)(void*));
|
void SetCancellationFunction(void* data, bool (*check_cancelled_func)(void*));
|
||||||
|
|
||||||
// Owning handle to a TfLiteDelegate instance.
|
|
||||||
using TfLiteDelegatePtr =
|
|
||||||
std::unique_ptr<TfLiteDelegate, void (*)(TfLiteDelegate*)>;
|
|
||||||
|
|
||||||
/// Allow a delegate to look at the graph and modify the graph to handle
|
/// Allow a delegate to look at the graph and modify the graph to handle
|
||||||
/// parts of the graph themselves. After this is called, the graph may
|
/// parts of the graph themselves. After this is called, the graph may
|
||||||
/// contain new nodes that replace 1 more nodes.
|
/// contain new nodes that replace 1 more nodes.
|
||||||
/// WARNING: This is an experimental API and subject to change.
|
/// WARNING: This is an experimental API and subject to change.
|
||||||
TfLiteStatus ModifyGraphWithDelegate(TfLiteDelegate* delegate);
|
TfLiteStatus ModifyGraphWithDelegate(TfLiteDelegate* delegate);
|
||||||
|
|
||||||
|
// Owning handle to a TfLiteDelegate instance.
|
||||||
|
using TfLiteDelegatePtr =
|
||||||
|
std::unique_ptr<TfLiteDelegate, void (*)(TfLiteDelegate*)>;
|
||||||
|
|
||||||
|
/// Same as ModifyGraphWithDelegate except this interpreter takes
|
||||||
|
/// ownership of the provided delegate. Be sure to construct the unique_ptr
|
||||||
|
/// with a suitable destruction function.
|
||||||
|
/// WARNING: This is an experimental API and subject to change.
|
||||||
|
TfLiteStatus ModifyGraphWithDelegate(TfLiteDelegatePtr delegate);
|
||||||
|
|
||||||
/// Ensure the data in `tensor.data` is readable. In case delegate is used,
|
/// Ensure the data in `tensor.data` is readable. In case delegate is used,
|
||||||
/// it might require to copy the data from delegate buffer to raw memory.
|
/// it might require to copy the data from delegate buffer to raw memory.
|
||||||
/// WARNING: This is an experimental API and subject to change.
|
/// WARNING: This is an experimental API and subject to change.
|
||||||
@ -499,16 +505,6 @@ class Interpreter {
|
|||||||
TfLiteExternalContextType type,
|
TfLiteExternalContextType type,
|
||||||
TfLiteExternalContext* ctx);
|
TfLiteExternalContext* ctx);
|
||||||
|
|
||||||
/// Variant of the public ModifyGraphWithDelegate method that additionally
|
|
||||||
/// Assumes ownership of the provided delegate.
|
|
||||||
/// WARNING: This is an experimental API and subject to change.
|
|
||||||
TfLiteStatus ModifyGraphWithDelegate(TfLiteDelegatePtr delegate) {
|
|
||||||
// Note that we retain ownership of the delegate even if graph modification
|
|
||||||
// fails, as delegate use will be in an indeterminate state at that point.
|
|
||||||
owned_delegates_.push_back(std::move(delegate));
|
|
||||||
return ModifyGraphWithDelegate(owned_delegates_.back().get());
|
|
||||||
}
|
|
||||||
|
|
||||||
// A pure C data structure used to communicate with the pure C plugin
|
// A pure C data structure used to communicate with the pure C plugin
|
||||||
// interface. To avoid copying tensor metadata, this is also the definitive
|
// interface. To avoid copying tensor metadata, this is also the definitive
|
||||||
// structure to store tensors.
|
// structure to store tensors.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user