Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into snnn/update_docker_im…
Browse files Browse the repository at this point in the history
…ages
  • Loading branch information
snnn committed Jan 5, 2025
2 parents 2bb560b + b7ef81a commit c9c52e1
Show file tree
Hide file tree
Showing 12 changed files with 220 additions and 199 deletions.
83 changes: 51 additions & 32 deletions js/node/script/install.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
// Step.1: Check if we should exit early
const os = require('os');
const fs = require('fs');
const https = require('https');
const path = require('path');
const tar = require('tar');
const { execFileSync } = require('child_process');
Expand Down Expand Up @@ -80,44 +81,62 @@ To use ONNX Runtime Node.js binding with CUDA v11 support, please follow the man
}.tgz`,
}[INSTALL_CUDA_FLAG || tryGetCudaVersion()];
console.log(`Downloading "${artifactUrl}"...`);
fetch(artifactUrl).then((res) => {
if (!res.ok) {
throw new Error(`Failed to download the binaries: ${res.status} ${res.statusText}.

const FILES = new Set([
'libonnxruntime_providers_tensorrt.so',
'libonnxruntime_providers_shared.so',
`libonnxruntime.so.${ORT_VERSION}`,
'libonnxruntime_providers_cuda.so',
]);

downloadAndExtract(artifactUrl, BIN_FOLDER, FILES);

async function downloadAndExtract(url, dest, files) {
return new Promise((resolve, reject) => {
https.get(url, (res) => {
const { statusCode } = res;
const contentType = res.headers['content-type'];

if (statusCode === 301 || statusCode === 302) {
downloadAndExtract(res.headers.location, dest, files).then(
(value) => resolve(value),
(reason) => reject(reason),
);
return;
} else if (statusCode !== 200) {
throw new Error(`Failed to download the binaries: ${res.statusCode} ${res.statusMessage}.
Use "--onnxruntime-node-install-cuda=skip" to skip the installation. You will still be able to use ONNX Runtime, but the CUDA EP will not be available.`);
}
}

// Extract the binaries

const FILES = new Set([
'libonnxruntime_providers_tensorrt.so',
'libonnxruntime_providers_shared.so',
`libonnxruntime.so.${ORT_VERSION}`,
'libonnxruntime_providers_cuda.so',
]);

Readable.fromWeb(res.body)
.pipe(
tar.t({
strict: true,
onentry: (entry) => {
const filename = path.basename(entry.path);
if (entry.type === 'File' && FILES.has(filename)) {
console.log(`Extracting "${filename}" to "${BIN_FOLDER}"...`);
entry.pipe(fs.createWriteStream(path.join(BIN_FOLDER, filename)));
entry.on('finish', () => {
console.log(`Finished extracting "${filename}".`);
});
}
},
}),
)
.on('error', (err) => {
throw new Error(`Failed to extract the binaries: ${err.message}.
if (!contentType || !/^application\/octet-stream/.test(contentType)) {
throw new Error(`unexpected content type: ${contentType}`);
}

res
.pipe(
tar.t({
strict: true,
onentry: (entry) => {
const filename = path.basename(entry.path);
if (entry.type === 'File' && files.has(filename)) {
console.log(`Extracting "${filename}" to "${dest}"...`);
entry.pipe(fs.createWriteStream(path.join(dest, filename)));
entry.on('finish', () => {
console.log(`Finished extracting "${filename}".`);
});
}
},
}),
)
.on('error', (err) => {
throw new Error(`Failed to extract the binaries: ${err.message}.
Use "--onnxruntime-node-install-cuda=skip" to skip the installation. You will still be able to use ONNX Runtime, but the CUDA EP will not be available.`);
});
});
});
});
}

function tryGetCudaVersion() {
// Should only return 11 or 12.
Expand Down
160 changes: 80 additions & 80 deletions js/web/test/data/ops/conv.jsonc
Original file line number Diff line number Diff line change
Expand Up @@ -391,48 +391,48 @@
}
]
},
{
"name": "conv - vectorize group - B",
"operator": "Conv",
"inputShapeDefinitions": "rankOnly",
"opset": { "domain": "", "version": 17 },
"attributes": [
{ "name": "kernel_shape", "data": [2, 2], "type": "ints" },
{ "name": "group", "data": 3, "type": "int" }
],
"cases": [
{
"name": "T[0]",
"inputs": [
{
"data": [
0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0, 17.0, 18.0,
19.0, 20.0, 21.0, 22.0, 23.0, 0, 0, 0
],
"dims": [1, 3, 3, 3],
"type": "float32"
},
{
"data": [1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0],
"dims": [3, 1, 2, 2],
"type": "float32"
},
{
"data": [0.1, 0.2, 0.3],
"dims": [3],
"type": "float32"
}
],
"outputs": [
{
"data": [27.1, 37.1, 57.1, 67.1, 293.2, 319.2, 371.2, 397.2, 847.3, 889.3, 409.3, 428.3],
"dims": [1, 3, 2, 2],
"type": "float32"
}
]
}
]
},
// {
// "name": "conv - vectorize group - B",
// "operator": "Conv",
// "inputShapeDefinitions": "rankOnly",
// "opset": { "domain": "", "version": 17 },
// "attributes": [
// { "name": "kernel_shape", "data": [2, 2], "type": "ints" },
// { "name": "group", "data": 3, "type": "int" }
// ],
// "cases": [
// {
// "name": "T[0]",
// "inputs": [
// {
// "data": [
// 0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0, 17.0, 18.0,
// 19.0, 20.0, 21.0, 22.0, 23.0, 0, 0, 0
// ],
// "dims": [1, 3, 3, 3],
// "type": "float32"
// },
// {
// "data": [1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0],
// "dims": [3, 1, 2, 2],
// "type": "float32"
// },
// {
// "data": [0.1, 0.2, 0.3],
// "dims": [3],
// "type": "float32"
// }
// ],
// "outputs": [
// {
// "data": [27.1, 37.1, 57.1, 67.1, 293.2, 319.2, 371.2, 397.2, 847.3, 889.3, 409.3, 428.3],
// "dims": [1, 3, 2, 2],
// "type": "float32"
// }
// ]
// }
// ]
// },
{
"name": "conv - vectorize group - C",
"operator": "Conv",
Expand Down Expand Up @@ -470,44 +470,44 @@
}
]
},
{
"name": "conv - vectorize group - D",
"operator": "Conv",
"inputShapeDefinitions": "rankOnly",
"opset": { "domain": "", "version": 17 },
"attributes": [
{ "name": "kernel_shape", "data": [2, 2], "type": "ints" },
{ "name": "group", "data": 3, "type": "int" },
{ "name": "strides", "data": [2, 2], "type": "ints" }
],
"cases": [
{
"name": "T[0] strides = [2, 2]",
"inputs": [
{
"data": [
0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0, 17.0, 18.0,
19.0, 20.0, 21.0, 22.0, 23.0, 24.0, 25.0, 26.0, 27.0, 28.0, 29.0, 30.0, 31.0, 32.0, 33.0, 34.0, 35.0
],
"dims": [1, 3, 3, 4],
"type": "float32"
},
{
"data": [1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0],
"dims": [3, 1, 2, 2],
"type": "float32"
}
],
"outputs": [
{
"data": [34, 54, 386, 438, 1122, 1206],
"dims": [1, 3, 1, 2],
"type": "float32"
}
]
}
]
},
// {
// "name": "conv - vectorize group - D",
// "operator": "Conv",
// "inputShapeDefinitions": "rankOnly",
// "opset": { "domain": "", "version": 17 },
// "attributes": [
// { "name": "kernel_shape", "data": [2, 2], "type": "ints" },
// { "name": "group", "data": 3, "type": "int" },
// { "name": "strides", "data": [2, 2], "type": "ints" }
// ],
// "cases": [
// {
// "name": "T[0] strides = [2, 2]",
// "inputs": [
// {
// "data": [
// 0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0, 17.0, 18.0,
// 19.0, 20.0, 21.0, 22.0, 23.0, 24.0, 25.0, 26.0, 27.0, 28.0, 29.0, 30.0, 31.0, 32.0, 33.0, 34.0, 35.0
// ],
// "dims": [1, 3, 3, 4],
// "type": "float32"
// },
// {
// "data": [1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0],
// "dims": [3, 1, 2, 2],
// "type": "float32"
// }
// ],
// "outputs": [
// {
// "data": [34, 54, 386, 438, 1122, 1206],
// "dims": [1, 3, 1, 2],
// "type": "float32"
// }
// ]
// }
// ]
// },
{
"name": "conv - pointwise",
"operator": "Conv",
Expand Down
Loading

0 comments on commit c9c52e1

Please sign in to comment.