@@ -5,44 +5,47 @@ import * as path from 'path';
55const ort = require ( path . join ( __dirname , '../../' ) ) ;
66import * as process from 'process' ;
77
8- const modelData = 'CAMSDGJhY2tlbmQtdGVzdDpiChEKAWEKAWISAWMiBk1hdE11bBIOdGVzdF9tYXRtdWxfMmRaEwoBYRIOCgwIARIICgIIAwoCCARaEwoBYhIOCgwIARIICgIIBAoCCANiEwoBYxIOCgwIARIICgIIAwoCCANCAhAJ' ;
8+ const modelData =
9+ 'CAMSDGJhY2tlbmQtdGVzdDpiChEKAWEKAWISAWMiBk1hdE11bBIOdGVzdF9tYXRtdWxfMmRaEwoBYRIOCgwIARIICgIIAwoCCARaEwoBYhIOCgwIARIICgIIBAoCCANiEwoBYxIOCgwIARIICgIIAwoCCANCAhAJ' ;
910const shouldProcessExit = process . argv . includes ( '--process-exit' ) ;
1011const shouldThrowException = process . argv . includes ( '--throw-exception' ) ;
1112const shouldRelease = process . argv . includes ( '--release' ) ;
1213
1314async function main ( ) {
14- try {
15- const modelBuffer = Buffer . from ( modelData , 'base64' ) ;
16- const session = await ort . InferenceSession . create ( modelBuffer ) ;
17-
18- const dataA = Float32Array . from ( [ 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 , 10 , 11 , 12 ] ) ;
19- const dataB = Float32Array . from ( [ 10 , 20 , 30 , 40 , 50 , 60 , 70 , 80 , 90 , 100 , 110 , 120 ] ) ;
20- const tensorA = new ort . Tensor ( 'float32' , dataA , [ 3 , 4 ] ) ;
21- const tensorB = new ort . Tensor ( 'float32' , dataB , [ 4 , 3 ] ) ;
22-
23- const results = await session . run ( { a : tensorA , b : tensorB } ) ;
24- console . log ( 'SUCCESS: Inference completed' ) ;
25- console . log ( `Result: ${ results . c . data } ` ) ;
26-
27- if ( shouldRelease ) {
28- await session . release ( ) ;
29- console . log ( 'Session released' ) ;
30- } else {
31- console . log ( 'Session NOT released (testing cleanup behavior)' ) ;
32- }
33-
34- if ( shouldThrowException ) {
35- setTimeout ( ( ) => { throw new Error ( 'Test exception' ) ; } , 10 ) ;
36- return ;
37- }
38-
39- if ( shouldProcessExit ) {
40- process . exit ( 0 ) ;
41- }
42- } catch ( e ) {
43- console . error ( `ERROR: ${ e } ` ) ;
44- process . exit ( 1 ) ;
15+ try {
16+ const modelBuffer = Buffer . from ( modelData , 'base64' ) ;
17+ const session = await ort . InferenceSession . create ( modelBuffer ) ;
18+
19+ const dataA = Float32Array . from ( [ 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 , 10 , 11 , 12 ] ) ;
20+ const dataB = Float32Array . from ( [ 10 , 20 , 30 , 40 , 50 , 60 , 70 , 80 , 90 , 100 , 110 , 120 ] ) ;
21+ const tensorA = new ort . Tensor ( 'float32' , dataA , [ 3 , 4 ] ) ;
22+ const tensorB = new ort . Tensor ( 'float32' , dataB , [ 4 , 3 ] ) ;
23+
24+ const results = await session . run ( { a : tensorA , b : tensorB } ) ;
25+ console . log ( 'SUCCESS: Inference completed' ) ;
26+ console . log ( `Result: ${ results . c . data } ` ) ;
27+
28+ if ( shouldRelease ) {
29+ await session . release ( ) ;
30+ console . log ( 'Session released' ) ;
31+ } else {
32+ console . log ( 'Session NOT released (testing cleanup behavior)' ) ;
4533 }
34+
35+ if ( shouldThrowException ) {
36+ setTimeout ( ( ) => {
37+ throw new Error ( 'Test exception' ) ;
38+ } , 10 ) ;
39+ return ;
40+ }
41+
42+ if ( shouldProcessExit ) {
43+ process . exit ( 0 ) ;
44+ }
45+ } catch ( e ) {
46+ console . error ( `ERROR: ${ e } ` ) ;
47+ process . exit ( 1 ) ;
48+ }
4649}
4750
48- main ( ) ;
51+ void main ( ) ;
0 commit comments