1 /* Copyright 2018 The TensorFlow Authors. All Rights Reserved. 2 3 Licensed under the Apache License, Version 2.0 (the "License"); 4 you may not use this file except in compliance with the License. 5 You may obtain a copy of the License at 6 7 http://www.apache.org/licenses/LICENSE-2.0 8 9 Unless required by applicable law or agreed to in writing, software 10 distributed under the License is distributed on an "AS IS" BASIS, 11 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 See the License for the specific language governing permissions and 13 limitations under the License. 14 ==============================================================================*/ 15 #ifndef TENSORFLOW_LITE_DELEGATES_FLEX_KERNEL_H_ 16 #define TENSORFLOW_LITE_DELEGATES_FLEX_KERNEL_H_ 17 18 #include <memory> 19 20 #include "tensorflow/lite/c/common.h" 21 #include "tensorflow/lite/delegates/utils/simple_delegate.h" 22 23 namespace tflite { 24 namespace flex { 25 26 struct OpData; 27 class DelegateKernel : public SimpleDelegateKernelInterface { 28 public: 29 DelegateKernel(); 30 ~DelegateKernel() override; 31 32 TfLiteStatus Init(TfLiteContext* context, 33 const TfLiteDelegateParams* params) override; 34 TfLiteStatus Prepare(TfLiteContext* context, TfLiteNode* node) override; 35 TfLiteStatus Eval(TfLiteContext* context, TfLiteNode* node) override; 36 37 private: 38 // Validate that the computed output tensor shape for the Flex node matches 39 // the existing output shape assigned to the output tensor. 40 TfLiteStatus ValidateOutputTensorShapeConsistency( 41 TfLiteContext* context) const; 42 43 std::unique_ptr<OpData> op_data_; 44 }; 45 46 } // namespace flex 47 } // namespace tflite 48 49 #endif // TENSORFLOW_LITE_DELEGATES_FLEX_KERNEL_H_ 50