1 /* 2 * Copyright (C) 2020 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 package android.hardware.neuralnetworks; 18 19 import android.hardware.neuralnetworks.ErrorStatus; 20 import android.hardware.neuralnetworks.Timing; 21 22 /** 23 * IFencedExecutionCallback can be used to query the error status result and duration information 24 * from an IPreparedModel::executeFenced call. 25 */ 26 @VintfStability 27 interface IFencedExecutionCallback { 28 /** 29 * The getExecutionInfo method is used by the clients to query error status result and duration 30 * information. The method must only be called after the actual evaluation has finished or 31 * resulted in an runtime error, as indicated by the status of the sync fence returned by the 32 * IPreparedModel::executeFenced call, otherwise GENERAL_FAILURE must be returned. 33 * 34 * @param out timingLaunched The duration starts when executeFenced is called and ends when 35 * executeFenced signals the returned syncFence. Unless measureTiming 36 * was set to true when launching the execution and status is NONE, 37 * all times must be reported as -1. A driver may choose to report any 38 * time as -1, indicating that particular measurement is not 39 * available. 40 * @param out timingFenced The duration starts when all waitFor sync fences have been signaled 41 * and ends when executeFenced signals the returned syncFence. Unless 42 * measureTiming was set to true when launching the execution and status 43 * is NONE, all times must be reported as -1. A driver may choose to 44 * report any time as -1, indicating that particular measurement is not 45 * available. 46 * @return Error status returned from the asynchronously dispatched execution must be: 47 * - NONE if the asynchronous execution was successful 48 * - DEVICE_UNAVAILABLE if driver is offline or busy 49 * - GENERAL_FAILURE if the asynchronous task resulted in an unspecified error 50 * - MISSED_DEADLINE_* if the execution is aborted because it cannot be completed by the 51 * deadline 52 * - RESOURCE_EXHAUSTED_* if the task was aborted by the driver 53 */ getExecutionInfo(out Timing timingLaunched, out Timing timingFenced)54 ErrorStatus getExecutionInfo(out Timing timingLaunched, out Timing timingFenced); 55 } 56