• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /* Copyright 2017 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 
16 #ifndef TENSORFLOW_LITE_TOOLS_VERIFIER_H_
17 #define TENSORFLOW_LITE_TOOLS_VERIFIER_H_
18 
19 #include <stdio.h>
20 
21 #include "tensorflow/lite/core/api/error_reporter.h"
22 #include "tensorflow/lite/core/api/op_resolver.h"
23 #include "tensorflow/lite/error_reporter.h"  // Legacy.
24 #include "tensorflow/lite/model.h"           // Legacy.
25 
26 namespace tflite {
27 
28 class AlwaysTrueResolver : public OpResolver {
29  public:
AlwaysTrueResolver()30   AlwaysTrueResolver() {}
FindOp(tflite::BuiltinOperator op,int version)31   const TfLiteRegistration* FindOp(tflite::BuiltinOperator op,
32                                    int version) const override {
33     static TfLiteRegistration null_registration = {nullptr, nullptr, nullptr,
34                                                    nullptr};
35     return &null_registration;
36   }
FindOp(const char * op,int version)37   const TfLiteRegistration* FindOp(const char* op, int version) const override {
38     static TfLiteRegistration null_registration = {nullptr, nullptr, nullptr,
39                                                    nullptr};
40     return &null_registration;
41   }
42 };
43 
44 // Verifies the integrity of a Tensorflow Lite flatbuffer model file.
45 // Currently, it verifies:
46 // * The file is following a legit flatbuffer schema.
47 // * The model is in supported version.
48 // * All ops used in the model are supported by OpResolver.
49 bool Verify(const void* buf, size_t len, const OpResolver& resolver,
50             ErrorReporter* error_reporter);
51 
52 }  // namespace tflite
53 
54 #endif  // TENSORFLOW_LITE_TOOLS_VERIFIER_H_
55