1/* 2 * Copyright (C) 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 ANDROID_ML_NN_RUNTIME_COMPILATION_BUILDER_H 18#define ANDROID_ML_NN_RUNTIME_COMPILATION_BUILDER_H 19 20#include "ExecutionPlan.h" 21#include "NeuralNetworks.h" 22 23namespace android { 24namespace nn { 25 26class ExecutionBuilder; 27class ModelBuilder; 28 29class CompilationBuilder { 30public: 31 friend class ExecutionBuilder; // TODO remove this 32 33 CompilationBuilder(const ModelBuilder* model); 34 35 int setPreference(int32_t preference); 36 37 int finish(); 38 39 int createExecution(ExecutionBuilder** execution); 40 41private: 42 const ModelBuilder* mModel; 43 44 ExecutionPlan mPlan; 45 46 // Whether the application prefers to go fast or use low power for this execution. 47 int32_t mPreference = ANEURALNETWORKS_PREFER_FAST_SINGLE_ANSWER; 48 49 // Once the compilation has been finished, we should not allow further 50 // modifications to the compilation. 51 bool mFinished = false; 52}; 53 54} // namespace nn 55} // namespace android 56 57#endif // ANDROID_ML_NN_RUNTIME_COMPILATION_BUILDER_H 58