|
7 | 7 | #include <math.h>
|
8 | 8 |
|
9 | 9 | #include "onnx/onnxifi.h"
|
| 10 | +#include "onnx/onnxifi_ext.h" |
| 11 | + |
| 12 | +/* |
| 13 | + * ONNXIFI Functions |
| 14 | + */ |
10 | 15 |
|
11 | 16 | ONNXIFI_PUBLIC ONNXIFI_CHECK_RESULT onnxStatus ONNXIFI_ABI
|
12 | 17 | onnxGetBackendIDs(onnxBackendID* backendIDs, size_t* numBackends) {
|
@@ -136,3 +141,56 @@ ONNXIFI_PUBLIC ONNXIFI_CHECK_RESULT onnxStatus ONNXIFI_ABI
|
136 | 141 | onnxReleaseGraph(onnxGraph graph) {
|
137 | 142 | return ONNXIFI_STATUS_SUCCESS;
|
138 | 143 | }
|
| 144 | + |
| 145 | +/* |
| 146 | + * ONNXIFI Extension Functions |
| 147 | + */ |
| 148 | + |
| 149 | +/* |
| 150 | + * This is the function list and the number of functions in onnxifi_ext |
| 151 | + * we have in this backend. It should be a subset of ALL_EXT_FUNCTION_LIST |
| 152 | + * in onnxifi_ext.h |
| 153 | + */ |
| 154 | +const int extension_function_number = 2; |
| 155 | +const char* extension_function_list[] = {"onnxGetExtensionFunctionAddress", |
| 156 | + "onnxSetIOAndRunGraph"}; |
| 157 | + |
| 158 | +ONNXIFI_PUBLIC ONNXIFI_CHECK_RESULT onnxStatus ONNXIFI_ABI |
| 159 | +onnxGetExtensionFunctionAddress( |
| 160 | + onnxBackendID backendID, |
| 161 | + const char* name, |
| 162 | + onnxExtensionFunctionPointer* function) { |
| 163 | + if (name == NULL || function == NULL) { |
| 164 | + return ONNXIFI_STATUS_INVALID_POINTER; |
| 165 | + } |
| 166 | + *function = NULL; |
| 167 | + int i; |
| 168 | + for (i = 0; i < extension_function_number; i++) { |
| 169 | + /* target function found */ |
| 170 | + if (strcmp(name, extension_function_list[i]) == 0) { |
| 171 | + switch (i) { |
| 172 | + case 0: |
| 173 | + *function = &onnxGetExtensionFunctionAddress; |
| 174 | + break; |
| 175 | + case 1: |
| 176 | + *function = &onnxSetIOAndRunGraph; |
| 177 | + break; |
| 178 | + } |
| 179 | + } |
| 180 | + } |
| 181 | + |
| 182 | + if (*function == NULL) { |
| 183 | + return ONNXIFI_STATUS_UNIDENTIFIED_NAME; |
| 184 | + } |
| 185 | + return ONNXIFI_STATUS_SUCCESS; |
| 186 | +} |
| 187 | + |
| 188 | +ONNXIFI_PUBLIC ONNXIFI_CHECK_RESULT onnxStatus ONNXIFI_ABI onnxSetIOAndRunGraph( |
| 189 | + onnxGraph graph, |
| 190 | + uint32_t inputsCount, |
| 191 | + const onnxTensorDescriptorV1* inputDescriptors, |
| 192 | + uint32_t outputsCount, |
| 193 | + const onnxTensorDescriptorV1* outputDescriptors, |
| 194 | + onnxMemoryFenceV1* outputFence) { |
| 195 | + return ONNXIFI_STATUS_SUCCESS; |
| 196 | +} |
0 commit comments