Home | History | Annotate | Download | only in include
      1 /*
      2  * Copyright (C) 2019 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_NEURAL_NETWORKS_EXTENSIONS_H
     18 #define ANDROID_ML_NN_RUNTIME_NEURAL_NETWORKS_EXTENSIONS_H
     19 
     20 #include "NeuralNetworks.h"
     21 
     22 /******************************************************************
     23  *
     24  * IMPORTANT NOTICE:
     25  *
     26  *   This file is not intended for use by general developers -- only
     27  *   by OEM applications.
     28  *
     29  *   Extensions source AND binary code relies on the definitions
     30  *   here to be FROZEN ON ALL UPCOMING PLATFORM RELEASES.
     31  *
     32  *   - DO NOT MODIFY ENUMS (EXCEPT IF YOU ADD NEW 32-BIT VALUES)
     33  *   - DO NOT MODIFY CONSTANTS OR FUNCTIONAL MACROS
     34  *   - DO NOT CHANGE THE SIGNATURE OF FUNCTIONS IN ANY WAY
     35  *   - DO NOT CHANGE THE LAYOUT OR SIZE OF STRUCTURES
     36  */
     37 
     38 __BEGIN_DECLS
     39 
     40 #if __ANDROID_API__ >= __ANDROID_API_Q__
     41 
     42 /**
     43  * Queries whether an extension is supported by the driver implementation of the specified device.
     44  *
     45  * @param device The representation of the specified device.
     46  * @param extension The extension name.
     47  * @param isExtensionSupported The boolean value indicating whether the extension is supported.
     48  *
     49  * @return ANEURALNETWORKS_NO_ERROR if successful.
     50  *
     51  * Available since API level 29.
     52  */
     53 int ANeuralNetworksDevice_getExtensionSupport(const ANeuralNetworksDevice* device,
     54                                               const char* extensionName, bool* isExtensionSupported)
     55         __INTRODUCED_IN(29);
     56 
     57 /**
     58  * Creates an operand type from an extension name and an extension operand code.
     59  *
     60  * See {@link ANeuralNetworksModel} for information on multithreaded usage.
     61  *
     62  * Available since API level 29.
     63  *
     64  * @param model The model to contain the operand.
     65  * @param extensionName The extension name.
     66  * @param operandCodeWithinExtension The extension operand code.
     67  * @param type The operand type.
     68  *
     69  * @return ANEURALNETWORKS_NO_ERROR if successful.
     70  */
     71 int ANeuralNetworksModel_getExtensionOperandType(ANeuralNetworksModel* model,
     72                                                  const char* extensionName,
     73                                                  uint16_t operandCodeWithinExtension, int32_t* type)
     74         __INTRODUCED_IN(29);
     75 
     76 /**
     77  * Creates an operation type from an extension name and an extension operation code.
     78  *
     79  * See {@link ANeuralNetworksModel} for information on multithreaded usage.
     80  *
     81  * Available since API level 29.
     82  *
     83  * @param model The model to contain the operation.
     84  * @param extensionName The extension name.
     85  * @param operationCodeWithinExtension The extension operation code.
     86  * @param type The operation type.
     87  *
     88  * @return ANEURALNETWORKS_NO_ERROR if successful.
     89  */
     90 int ANeuralNetworksModel_getExtensionOperationType(ANeuralNetworksModel* model,
     91                                                    const char* extensionName,
     92                                                    uint16_t operationCodeWithinExtension,
     93                                                    ANeuralNetworksOperationType* type)
     94         __INTRODUCED_IN(29);
     95 
     96 /**
     97  * Sets extension operand parameters.
     98  *
     99  * Available since API level 29.
    100  *
    101  * @param model The model to be modified.
    102  * @param index The index of the model operand we're setting.
    103  * @param data A pointer to the extension operand data.
    104  *             The data does not have to outlive the call to this function.
    105  * @param length The size in bytes of the data value.
    106  *
    107  * @return ANEURALNETWORKS_NO_ERROR if successful.
    108  */
    109 int ANeuralNetworksModel_setOperandExtensionData(ANeuralNetworksModel* model, int32_t index,
    110                                                  const void* data, size_t length)
    111         __INTRODUCED_IN(29);
    112 
    113 #endif  // __ANDROID_API__ >= __ANDROID_API_Q__
    114 
    115 __END_DECLS
    116 
    117 #endif  // ANDROID_ML_NN_RUNTIME_NEURAL_NETWORKS_EXTENSIONS_H
    118