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_FRAMEWORKS_ML_NN_RUNTIME_NEURAL_NETWORKS_EXTENSIONS_H 18 #define ANDROID_FRAMEWORKS_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 /** 41 * Queries whether an extension is supported by the driver implementation of the specified device. 42 * 43 * @param device The representation of the specified device. 44 * @param extension The extension name. 45 * @param isExtensionSupported The boolean value indicating whether the extension is supported. 46 * 47 * @return ANEURALNETWORKS_NO_ERROR if successful. 48 * 49 * Available since API level 29. 50 */ 51 int ANeuralNetworksDevice_getExtensionSupport(const ANeuralNetworksDevice* device, 52 const char* extensionName, bool* isExtensionSupported) 53 __INTRODUCED_IN(29); 54 55 /** 56 * Creates an operand type from an extension name and an extension operand code. 57 * 58 * See {@link ANeuralNetworksModel} for information on multithreaded usage. 59 * 60 * Available since API level 29. 61 * 62 * @param model The model to contain the operand. 63 * @param extensionName The extension name. 64 * @param operandCodeWithinExtension The extension operand code. 65 * @param type The operand type. 66 * 67 * @return ANEURALNETWORKS_NO_ERROR if successful. 68 */ 69 int ANeuralNetworksModel_getExtensionOperandType(ANeuralNetworksModel* model, 70 const char* extensionName, 71 uint16_t operandCodeWithinExtension, int32_t* type) 72 __INTRODUCED_IN(29); 73 74 /** 75 * Creates an operation type from an extension name and an extension operation code. 76 * 77 * See {@link ANeuralNetworksModel} for information on multithreaded usage. 78 * 79 * Available since API level 29. 80 * 81 * @param model The model to contain the operation. 82 * @param extensionName The extension name. 83 * @param operationCodeWithinExtension The extension operation code. 84 * @param type The operation type. 85 * 86 * @return ANEURALNETWORKS_NO_ERROR if successful. 87 */ 88 int ANeuralNetworksModel_getExtensionOperationType(ANeuralNetworksModel* model, 89 const char* extensionName, 90 uint16_t operationCodeWithinExtension, 91 ANeuralNetworksOperationType* type) 92 __INTRODUCED_IN(29); 93 94 /** 95 * Sets extension operand parameters. 96 * 97 * Available since API level 29. 98 * 99 * @param model The model to be modified. 100 * @param index The index of the model operand we're setting. 101 * @param data A pointer to the extension operand data. 102 * The data does not have to outlive the call to this function. 103 * @param length The size in bytes of the data value. 104 * 105 * @return ANEURALNETWORKS_NO_ERROR if successful. 106 */ 107 int ANeuralNetworksModel_setOperandExtensionData(ANeuralNetworksModel* model, int32_t index, 108 const void* data, size_t length) 109 __INTRODUCED_IN(29); 110 111 __END_DECLS 112 113 #endif // ANDROID_FRAMEWORKS_ML_NN_RUNTIME_NEURAL_NETWORKS_EXTENSIONS_H 114