Skip to content

Commit db7714f

Browse files
authored
wasi_nn_tensorflowlite.cpp: reject non-fp32 input earlier (#4388)
this backend assumes fp32 here and there. it's safer to reject unexpected inputs explicitly.
1 parent 4bf799c commit db7714f

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

core/iwasm/libraries/wasi-nn/src/wasi_nn_tensorflowlite.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -281,6 +281,11 @@ set_input(void *tflite_ctx, graph_execution_context ctx, uint32_t index,
281281
{
282282
TFLiteContext *tfl_ctx = (TFLiteContext *)tflite_ctx;
283283

284+
if (input_tensor->type != fp32) {
285+
NN_ERR_PRINTF("unsupported input tensor type %u", input_tensor->type);
286+
return runtime_error;
287+
}
288+
284289
wasi_nn_error res;
285290
if (success != (res = is_valid_graph_execution_context(tfl_ctx, ctx)))
286291
return res;

0 commit comments

Comments
 (0)