diff --git a/js/web/lib/wasm/wasm-core-impl.ts b/js/web/lib/wasm/wasm-core-impl.ts index 3d55584abf..890ef58ada 100644 --- a/js/web/lib/wasm/wasm-core-impl.ts +++ b/js/web/lib/wasm/wasm-core-impl.ts @@ -328,7 +328,7 @@ export const run = errorCode = wasm._OrtGetTensorData( tensor, tensorDataOffset, tensorDataOffset + 4, tensorDataOffset + 8, tensorDataOffset + 12); if (errorCode !== 0) { - throw new Error(`Can't get a tensor data. error code = ${errorCode}`); + throw new Error(`Can't access output tensor data. error code = ${errorCode}`); } let tensorDataIndex = tensorDataOffset / 4; const dataType = wasm.HEAPU32[tensorDataIndex++]; diff --git a/onnxruntime/wasm/api.cc b/onnxruntime/wasm/api.cc index 85c7a6f477..2e52460b34 100644 --- a/onnxruntime/wasm/api.cc +++ b/onnxruntime/wasm/api.cc @@ -113,7 +113,7 @@ OrtSessionOptions* OrtCreateSessionOptions(size_t graph_optimization_level, RETURN_NULLPTR_IF_ERROR(EnableOrtCustomOps, session_options); #endif #if defined(USE_XNNPACK) - + RETURN_NULLPTR_IF_ERROR(SessionOptionsAppendExecutionProvider, session_options, "XNNPACK", nullptr, nullptr, 0); #endif return session_options; @@ -246,6 +246,12 @@ int OrtGetTensorData(OrtValue* tensor, int* data_type, void** data, size_t** dim size_t* p_dims = nullptr; void* p_string_data = nullptr; + ONNXType tensor_type; + RETURN_ERROR_CODE_IF_ERROR(GetValueType, tensor, &tensor_type); + if ( tensor_type != ONNX_TYPE_TENSOR ) { + return ORT_FAIL; + } + RETURN_ERROR_CODE_IF_ERROR(GetTensorTypeAndShape, tensor, &info); size_t dims_len = 0;