Skip to content

Commit

Permalink
Miscellaneous edits.
Browse files Browse the repository at this point in the history
  • Loading branch information
satyajandhyala committed Jul 18, 2024
1 parent ae12127 commit ab2e3b1
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 10 deletions.
2 changes: 1 addition & 1 deletion js/web/lib/wasm/jsep/init.ts
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ export const init =

await backend.download(
Number(gpuDataId),
() => module.HEAPU8.subarray(Number(dataOffset) >>> 0, Number(dataOffset + size) >>> 0));
() => module.HEAPU8.subarray(Number(dataOffset) >>> 0, Number(dataOffset) >>> 0 + Number(size)));
},

// jsepCreateKernel
Expand Down
8 changes: 4 additions & 4 deletions onnxruntime/core/framework/tensorprotoutils.cc
Original file line number Diff line number Diff line change
Expand Up @@ -947,9 +947,9 @@ Status GetExtDataFromTensorProto(const Env& env, const std::filesystem::path& mo
if (!fileData) {
return 2; // File not found in preloaded files.
}
const offset = $1 >>> 0;
const length = $2 >>> 0;
const buffer = $3 >>> 0;
const offset = Number($1 >>> 0);
const length = Number($2 >>> 0);
const buffer = Number($3 >>> 0);

if (offset + length > fileData.byteLength) {
return 3; // Out of bounds.
Expand All @@ -958,7 +958,7 @@ Status GetExtDataFromTensorProto(const Env& env, const std::filesystem::path& mo
try {
// Copy the file data (fileData,offset,length) into WebAssembly memory
// (HEAPU8,buffer,length).
HEAPU8.set(fileData.subarray(Number(offset), Number(offset) + length), buffer);
HEAPU8.set(fileData.subarray(offset, offset + length), buffer);
return 0;
} catch {
return 4;
Expand Down
9 changes: 5 additions & 4 deletions onnxruntime/core/graph/model.cc
Original file line number Diff line number Diff line change
Expand Up @@ -552,12 +552,13 @@ static Status SaveModel(Model& model, const T& file_path) {
model_proto.SerializeToArray(buffer, buffer_size);

EM_ASM(({
const buffer = $0;
const buffer_size = $1;
const buffer = Number($0);
const buffer_size = Number($1);
const file_path = UTF8ToString($2);
const bytes = new Uint8Array(buffer_size);
bytes.set(HEAPU8.subarray(Number(buffer), Number(buffer) + buffer_size));
if (typeof process == 'object' && typeof process.versions == 'object' && typeof process.versions.node == 'string') {
bytes.set(HEAPU8.subarray(buffer, buffer + buffer_size));
if (typeof process == 'object' && typeof process.versions == 'object' &&
typeof process.versions.node == 'string') {
// Node.js
require('fs').writeFileSync(file_path, bytes);
} else {
Expand Down
2 changes: 1 addition & 1 deletion onnxruntime/core/providers/js/js_kernel.h
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ class JsKernel : public OpKernel {
return status;
}

intptr_t status_code = EM_ASM_INT(
int status_code = EM_ASM_INT(
{ return Module.jsepRunKernel($0, $1, Module.jsepSessionState.sessionHandle, Module.jsepSessionState.errors); },
this, reinterpret_cast<uintptr_t>(p_serialized_kernel_context));

Expand Down

0 comments on commit ab2e3b1

Please sign in to comment.