|
1 | 1 | /* |
2 | | - * Copyright 2024 NXP |
| 2 | + * Copyright 2022-2024 NXP |
3 | 3 | * |
4 | 4 | * SPDX-License-Identifier: BSD-3-Clause |
5 | 5 | * |
@@ -54,21 +54,21 @@ typedef void *NeutronModelHandle; |
54 | 54 | typedef struct { |
55 | 55 | /// Neutron microcode buffer address. |
56 | 56 | /// The Neutron microcode is generated by the Neutron converter tool. |
57 | | - /// The microcode buffer is allocated and initialized by the application or ML framework. |
| 57 | + /// The microcode buffer, 16 bytes aligned, is allocated and initialized by the application or ML framework. |
58 | 58 | /// The microcode buffer is passed by reference to the Neutron firmware. |
59 | 59 | /// The microcode buffer is specific for a given ML model. |
60 | 60 | const void *microcode; |
61 | 61 |
|
62 | 62 | /// Neutron weights buffer address. |
63 | 63 | /// The Neutron weights is generated by the Neutron converter tool. |
64 | | - /// The weights buffer is allocated and initialized by the application or ML framework. |
| 64 | + /// The weights buffer, 16 bytes aligned, is allocated and initialized by the application or ML framework. |
65 | 65 | /// The weights buffer address is passed by reference to the Neutron-firmware. |
66 | 66 | /// The weights buffer is specific for a given ML model. |
67 | 67 | const void *weights; |
68 | 68 |
|
69 | 69 | /// Neutron kernels buffer address. |
70 | 70 | /// The Neutron kernels are generated by the Neutron converter tool. |
71 | | - /// The kernels buffer is allocated and initialized by the application or ML framework. |
| 71 | + /// The kernels buffer, 16 bytes aligned, is allocated and initialized by the application or ML framework. |
72 | 72 | /// The kernels buffer address is passed by reference to the Neutron-firmware. |
73 | 73 | /// The kernels buffer is specific for a given ML model. |
74 | 74 | const void *kernels; |
@@ -137,6 +137,15 @@ NeutronError neutronInit(); |
137 | 137 | /// - Deinitialize the Neutron Driver library, releasing any resources aquired by neutronInit |
138 | 138 | NeutronError neutronDeinit(); |
139 | 139 |
|
| 140 | +/// - Prepare Neutron execution for a model with custom firmware. |
| 141 | +/// - This function is only available for Neutron-S. |
| 142 | +NeutronError neutronCustomPrepare(uint32_t *inputSize, int32_t numInputs, uint32_t *outputSize, int32_t numOutputs, |
| 143 | + const void *firmware, size_t firmwareSize, NeutronModelHandle *hdl); |
| 144 | + |
| 145 | +/// - Run Neutron custom firmware and get the results. |
| 146 | +/// - This function is only available for Neutron-S. |
| 147 | +NeutronError neutronCustomExec(NeutronModelHandle hdl, const NeutronDataConfig *neutron_dcfg); |
| 148 | + |
140 | 149 | /// - Prepare Neutron execution for a model with the given configuration. |
141 | 150 | /// - This function only prepares the execution by transferring the parameters to the firmware. |
142 | 151 | /// - This function allows caching a model and then running the same model but with different |
@@ -188,6 +197,17 @@ NeutronError neutronSetConfig(NeutronConfig *config); |
188 | 197 | /// - Used to get NeutronContext size. |
189 | 198 | size_t neutronGetModelContextSize(); |
190 | 199 |
|
| 200 | +/// - Allocates size bytes and returns a pointer to the allocated memory. |
| 201 | +/// The returned pointer address will be a multiple of the alignment. |
| 202 | +/// Returns NULL on failure. |
| 203 | +/// - alignment: Set to 0 if unsure of alignment requirements. |
| 204 | +/// - This function is only available for Neutron-S in the Linux environment. |
| 205 | +void *neutronMemAlloc(size_t alignment, size_t size); |
| 206 | + |
| 207 | +/// - Frees the memory buffer pointed to by ptr. |
| 208 | +/// - This function is only available for Neutron-S in the Linux environment. |
| 209 | +void neutronMemFree(void *ptr); |
| 210 | + |
191 | 211 | /// Other functions to control the state of driver/firmware. |
192 | 212 | #ifdef __cplusplus |
193 | 213 | } |
|
0 commit comments