Small changes to SimpleDelegate APIs:
1. change name() to Name(). 2. change Invoke to Eval(). PiperOrigin-RevId: 314287361 Change-Id: I7c5324a1ee7c4ea5f06987da2f55c245e2d6153e
This commit is contained in:
parent
e9781e9b16
commit
958990b470
@ -72,7 +72,7 @@ TfLiteStatus FlexDelegate::Initialize(TfLiteContext* context) {
|
||||
return kTfLiteOk;
|
||||
}
|
||||
|
||||
const char* FlexDelegate::name() const {
|
||||
const char* FlexDelegate::Name() const {
|
||||
static constexpr char kName[] = "TfLiteFlexDelegate";
|
||||
return kName;
|
||||
}
|
||||
|
@ -69,7 +69,7 @@ class FlexDelegate : public SimpleDelegateInterface {
|
||||
|
||||
FlexDelegate() {}
|
||||
|
||||
const char* name() const override;
|
||||
const char* Name() const override;
|
||||
|
||||
bool IsNodeSupportedByDelegate(const TfLiteRegistration* registration,
|
||||
const TfLiteNode* node,
|
||||
|
@ -485,7 +485,7 @@ TfLiteStatus DelegateKernel::Prepare(TfLiteContext* context, TfLiteNode* node) {
|
||||
return kTfLiteOk;
|
||||
}
|
||||
|
||||
TfLiteStatus DelegateKernel::Invoke(TfLiteContext* context, TfLiteNode* node) {
|
||||
TfLiteStatus DelegateKernel::Eval(TfLiteContext* context, TfLiteNode* node) {
|
||||
BufferMap* buffer_map = op_data_->buffer_map;
|
||||
|
||||
// Insert a tensor in the buffer map for all inputs that are not constant.
|
||||
|
@ -32,7 +32,7 @@ class DelegateKernel : public SimpleDelegateKernelInterface {
|
||||
TfLiteStatus Init(TfLiteContext* context,
|
||||
const TfLiteDelegateParams* params) override;
|
||||
TfLiteStatus Prepare(TfLiteContext* context, TfLiteNode* node) override;
|
||||
TfLiteStatus Invoke(TfLiteContext* context, TfLiteNode* node) override;
|
||||
TfLiteStatus Eval(TfLiteContext* context, TfLiteNode* node) override;
|
||||
|
||||
private:
|
||||
std::unique_ptr<OpData> op_data_;
|
||||
|
@ -31,7 +31,7 @@ TfLiteRegistration GetDelegateKernelRegistration(
|
||||
TfLiteRegistration kernel_registration;
|
||||
kernel_registration.profiling_string = nullptr;
|
||||
kernel_registration.builtin_code = kTfLiteBuiltinDelegate;
|
||||
kernel_registration.custom_name = delegate->name();
|
||||
kernel_registration.custom_name = delegate->Name();
|
||||
kernel_registration.version = 1;
|
||||
kernel_registration.free = [](TfLiteContext* context, void* buffer) -> void {
|
||||
delete reinterpret_cast<SimpleDelegateKernelInterface*>(buffer);
|
||||
@ -68,7 +68,7 @@ TfLiteRegistration GetDelegateKernelRegistration(
|
||||
SimpleDelegateKernelInterface* delegate_kernel =
|
||||
reinterpret_cast<SimpleDelegateKernelInterface*>(node->user_data);
|
||||
TFLITE_DCHECK(delegate_kernel != nullptr);
|
||||
return delegate_kernel->Invoke(context, node);
|
||||
return delegate_kernel->Eval(context, node);
|
||||
};
|
||||
|
||||
return kernel_registration;
|
||||
@ -94,7 +94,7 @@ TfLiteStatus DelegatePrepare(TfLiteContext* context,
|
||||
TFLITE_LOG_PROD(tflite::TFLITE_LOG_INFO,
|
||||
"%s delegate: %d nodes delegated out of %d nodes with "
|
||||
"%d partitions.\n",
|
||||
delegate->name(), supported_nodes.size(),
|
||||
delegate->Name(), supported_nodes.size(),
|
||||
helper.num_total_nodes(), helper.num_partitions());
|
||||
TfLiteRegistration delegate_kernel_registration =
|
||||
GetDelegateKernelRegistration(delegate);
|
||||
|
@ -56,8 +56,7 @@ class SimpleDelegateKernelInterface {
|
||||
|
||||
// Actual subgraph inference should happen on this call.
|
||||
// Returns status, and signalling any errors.
|
||||
// TODO(b/157882025): change this to Eval to be consistent w/ a TFLite kernel.
|
||||
virtual TfLiteStatus Invoke(TfLiteContext* context, TfLiteNode* node) = 0;
|
||||
virtual TfLiteStatus Eval(TfLiteContext* context, TfLiteNode* node) = 0;
|
||||
};
|
||||
|
||||
// Pure Interface that clients should implement.
|
||||
@ -87,8 +86,7 @@ class SimpleDelegateInterface {
|
||||
|
||||
// Returns a name that identifies the delegate.
|
||||
// This name is used for debugging/logging/profiling.
|
||||
// TODO(b/157882025): change this to Name()
|
||||
virtual const char* name() const = 0;
|
||||
virtual const char* Name() const = 0;
|
||||
|
||||
// Returns instance of an object that implements the interface
|
||||
// SimpleDelegateKernelInterface.
|
||||
|
@ -52,7 +52,7 @@ class TestSimpleDelegateKernel : public SimpleDelegateKernelInterface {
|
||||
return !options_.error_during_prepare ? kTfLiteOk : kTfLiteError;
|
||||
}
|
||||
|
||||
TfLiteStatus Invoke(TfLiteContext* context, TfLiteNode* node) override {
|
||||
TfLiteStatus Eval(TfLiteContext* context, TfLiteNode* node) override {
|
||||
return !options_.error_during_invoke ? kTfLiteOk : kTfLiteError;
|
||||
}
|
||||
|
||||
@ -74,7 +74,7 @@ class TestSimpleDelegate : public SimpleDelegateInterface {
|
||||
|
||||
TfLiteStatus Initialize(TfLiteContext* context) override { return kTfLiteOk; }
|
||||
|
||||
const char* name() const override {
|
||||
const char* Name() const override {
|
||||
static constexpr char kName[] = "TestSimpleDelegate";
|
||||
return kName;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user