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