@@ -324,7 +324,7 @@ set_input(void *tflite_ctx, graph_execution_context ctx, uint32_t index,
324324 index);
325325
326326 int size = model_tensor_size * sizeof (float );
327- bh_memcpy_s (it, size, input_tensor->data , size);
327+ bh_memcpy_s (it, size, input_tensor->data . buf , size);
328328 }
329329 else { // TODO: Assuming uint8 quantized networks.
330330 TfLiteAffineQuantization *quant_info =
@@ -342,7 +342,7 @@ set_input(void *tflite_ctx, graph_execution_context ctx, uint32_t index,
342342 NN_DBG_PRINTF (" input tensor: (scale, offset) = (%f, %f)" , scale,
343343 zero_point);
344344
345- float *input_tensor_f = (float *)input_tensor->data ;
345+ float *input_tensor_f = (float *)input_tensor->data . buf ;
346346 for (uint32_t i = 0 ; i < model_tensor_size; ++i) {
347347 it[i] = (uint8_t )(input_tensor_f[i] / scale + zero_point);
348348 }
@@ -366,7 +366,7 @@ compute(void *tflite_ctx, graph_execution_context ctx)
366366
367367__attribute__ ((visibility(" default" ))) wasi_nn_error
368368get_output(void *tflite_ctx, graph_execution_context ctx, uint32_t index,
369- tensor_data output_tensor, uint32_t *output_tensor_size)
369+ tensor_data * output_tensor, uint32_t *output_tensor_size)
370370{
371371 TFLiteContext *tfl_ctx = (TFLiteContext *)tflite_ctx;
372372
@@ -392,7 +392,7 @@ get_output(void *tflite_ctx, graph_execution_context ctx, uint32_t index,
392392 if (tensor->quantization .type == kTfLiteNoQuantization ) {
393393 NN_DBG_PRINTF (" No quantization information" );
394394#if WASM_ENABLE_WASI_EPHEMERAL_NN != 0
395- if (*output_tensor_size < tensor->bytes ) {
395+ if (output_tensor-> size < tensor->bytes ) {
396396 NN_ERR_PRINTF (" Insufficient memory to copy tensor %d" , index);
397397 return too_large;
398398 }
@@ -401,12 +401,12 @@ get_output(void *tflite_ctx, graph_execution_context ctx, uint32_t index,
401401 * for now, maintain the bug-to-bug compatibility with the old abi,
402402 * where the size here is the number of fp32, not bytes.
403403 */
404- if (*output_tensor_size < tensor->bytes / sizeof (float )) {
404+ if (output_tensor-> size < tensor->bytes / sizeof (float )) {
405405 NN_ERR_PRINTF (" Insufficient memory to copy tensor %d" , index);
406406 return too_large;
407407 }
408408#endif
409- bh_memcpy_s (output_tensor, *output_tensor_size , tensor->data .data ,
409+ bh_memcpy_s (output_tensor-> buf , output_tensor-> size , tensor->data .data ,
410410 tensor->bytes );
411411#if WASM_ENABLE_WASI_EPHEMERAL_NN != 0
412412 *output_tensor_size = tensor->bytes ;
@@ -431,7 +431,7 @@ get_output(void *tflite_ctx, graph_execution_context ctx, uint32_t index,
431431 model_tensor_size *= (uint32_t )tensor->dims ->data [i];
432432
433433#if WASM_ENABLE_WASI_EPHEMERAL_NN != 0
434- if (*output_tensor_size / sizeof (float ) < model_tensor_size) {
434+ if (output_tensor-> size / sizeof (float ) < model_tensor_size) {
435435 NN_ERR_PRINTF (" Insufficient memory to copy tensor %d" , index);
436436 return too_large;
437437 }
@@ -440,7 +440,7 @@ get_output(void *tflite_ctx, graph_execution_context ctx, uint32_t index,
440440 * for now, maintain the bug-to-bug compatibility with the old abi,
441441 * where the size here is the number of fp32, not bytes.
442442 */
443- if (*output_tensor_size < model_tensor_size) {
443+ if (output_tensor-> size < model_tensor_size) {
444444 NN_ERR_PRINTF (" Insufficient memory to copy tensor %d" , index);
445445 return too_large;
446446 }
@@ -454,7 +454,7 @@ get_output(void *tflite_ctx, graph_execution_context ctx, uint32_t index,
454454 NN_DBG_PRINTF (" output tensor: (scale, offset) = (%f, %f)" , scale,
455455 zero_point);
456456
457- float *output_tensor_f = (float *)output_tensor;
457+ float *output_tensor_f = (float *)output_tensor-> buf ;
458458 for (uint32_t i = 0 ; i < model_tensor_size; ++i) {
459459 output_tensor_f[i] = (ot[i] - zero_point) * scale;
460460 }
0 commit comments