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_COMMON_VALIDATEHAL_H 18#define ANDROID_ML_NN_COMMON_VALIDATEHAL_H 19 20#include "HalInterfaces.h" 21 22namespace android { 23namespace nn { 24 25// Verifies that the model is valid, i.e. it is consistent, takes 26// only acceptable values, the constants don't extend outside the memory 27// regions they are part of, etc. 28// IMPORTANT: This function cannot validate that OEM operation and operands 29// are correctly defined, as these are specific to each implementation. 30// Each driver should do their own validation of OEM types. 31bool validateModel(const V1_0::Model& model); 32bool validateModel(const V1_1::Model& model); 33 34// Verfies that the request for the given model is valid. 35// IMPORTANT: This function cannot validate that OEM operation and operands 36// are correctly defined, as these are specific to each implementation. 37// Each driver should do their own validation of OEM types. 38bool validateRequest(const Request& request, const V1_0::Model& model); 39bool validateRequest(const Request& request, const V1_1::Model& model); 40 41// Verfies that the execution preference is valid. 42bool validateExecutionPreference(ExecutionPreference preference); 43 44} // namespace nn 45} // namespace android 46 47#endif // ANDROID_ML_NN_COMMON_VALIDATEHAL_H 48