Home | History | Annotate | Download | only in libnnbenchmark
      1 /**
      2  * Copyright 2017 The Android Open Source Project
      3  *
      4  * Licensed under the Apache License, Version 2.0 (the "License");
      5  * you may not use this file except in compliance with the License.
      6  * You may obtain a copy of the License at
      7  *
      8  *      http://www.apache.org/licenses/LICENSE-2.0
      9  *
     10  * Unless required by applicable law or agreed to in writing, software
     11  * distributed under the License is distributed on an "AS IS" BASIS,
     12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     13  * See the License for the specific language governing permissions and
     14  * limitations under the License.
     15  */
     16 
     17 #ifndef COM_EXAMPLE_ANDROID_NN_BENCHMARK_RUN_TFLITE_H
     18 #define COM_EXAMPLE_ANDROID_NN_BENCHMARK_RUN_TFLITE_H
     19 
     20 #include "tensorflow/contrib/lite/interpreter.h"
     21 #include "tensorflow/contrib/lite/model.h"
     22 
     23 #include <unistd.h>
     24 #include <vector>
     25 
     26 class BenchmarkModel {
     27 public:
     28     explicit BenchmarkModel(const char* modelfile);
     29     ~BenchmarkModel();
     30 
     31     bool resizeInputTensors(std::vector<int> shape);
     32     bool setInput(const uint8_t* dataPtr, size_t length);
     33     bool runBenchmark(int num_inferences,
     34                       bool use_nnapi);
     35 
     36 private:
     37     std::unique_ptr<tflite::FlatBufferModel> mTfliteModel;
     38     std::unique_ptr<tflite::Interpreter> mTfliteInterpreter;
     39 };
     40 
     41 
     42 #endif  // COM_EXAMPLE_ANDROID_NN_BENCHMARK_RUN_TFLITE_H