Skip to content

Commit d25716c

Browse files
committed
Fix error message to only mention Float16Array for float16 tensors
Address review comment: the "or Float16Array" text in the type mismatch error was shown for all tensor types. Now it only appears when the expected type is float16.
1 parent 8efca19 commit d25716c

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

js/node/src/tensor_helper.cc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,8 @@ Ort::Value NapiValueToOrtValue(Napi::Env env, Napi::Value value, OrtMemoryInfo*
214214

215215
ORT_NAPI_THROW_TYPEERROR_IF(!isValidTypedArray, env,
216216
"Tensor.data must be a typed array (", DATA_TYPE_TYPEDARRAY_MAP[elemType],
217-
" or Float16Array) for ", tensorTypeString, " tensors, but got typed array (", typedArrayType, ").");
217+
elemType == ONNX_TENSOR_ELEMENT_DATA_TYPE_FLOAT16 ? " or Float16Array" : "",
218+
") for ", tensorTypeString, " tensors, but got typed array (", typedArrayType, ").");
218219

219220
char* buffer = reinterpret_cast<char*>(tensorDataTypedArray.ArrayBuffer().Data());
220221
size_t bufferByteOffset = tensorDataTypedArray.ByteOffset();

0 commit comments

Comments
 (0)