oidn-web 0.4.0 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (106) hide show
  1. package/CHANGELOG.md +45 -0
  2. package/README.md +83 -19
  3. package/dist/oidn.js +3239 -2642
  4. package/dist/oidn.umd.cjs +512 -296
  5. package/lib/UNet.d.ts +54 -20
  6. package/lib/UNet.js +194 -118
  7. package/lib/UNet.js.map +1 -1
  8. package/lib/backend.d.ts +1 -8
  9. package/lib/backend.js +1 -9
  10. package/lib/backend.js.map +1 -1
  11. package/lib/finalRgbShader.d.ts +13 -0
  12. package/lib/finalRgbShader.js +160 -0
  13. package/lib/finalRgbShader.js.map +1 -0
  14. package/lib/graphOptimizer.js +1 -2
  15. package/lib/graphOptimizer.js.map +1 -1
  16. package/lib/hdrTransfer.d.ts +14 -0
  17. package/lib/hdrTransfer.js +61 -0
  18. package/lib/hdrTransfer.js.map +1 -0
  19. package/lib/main.d.ts +16 -7
  20. package/lib/main.js +4 -5
  21. package/lib/main.js.map +1 -1
  22. package/lib/nativeUNet.d.ts +39 -3
  23. package/lib/nativeUNet.js +449 -120
  24. package/lib/nativeUNet.js.map +1 -1
  25. package/lib/process.d.ts +5 -11
  26. package/lib/process.js +35 -49
  27. package/lib/process.js.map +1 -1
  28. package/lib/tileScheduler.d.ts +32 -4
  29. package/lib/tileScheduler.js +133 -20
  30. package/lib/tileScheduler.js.map +1 -1
  31. package/package.json +9 -2
  32. package/src/UNet.ts +287 -158
  33. package/src/backend.ts +1 -14
  34. package/src/finalRgbShader.ts +186 -0
  35. package/src/graphOptimizer.ts +1 -2
  36. package/src/hdrTransfer.ts +88 -0
  37. package/src/main.ts +28 -13
  38. package/src/nativeUNet.ts +515 -116
  39. package/src/process.ts +43 -70
  40. package/src/tileScheduler.ts +216 -24
  41. package/benchmarks/compare.mjs +0 -651
  42. package/benchmarks/leak.mjs +0 -255
  43. package/benchmarks/results/before-spatial.json +0 -391
  44. package/benchmarks/results/before-spatial.md +0 -47
  45. package/benchmarks/results/int8-scan.json +0 -2007
  46. package/benchmarks/results/int8-scan.md +0 -160
  47. package/benchmarks/results/int8-w8a8-scan.json +0 -2007
  48. package/benchmarks/results/int8-w8a8-scan.md +0 -160
  49. package/benchmarks/results/int8-weight-channel.json +0 -1413
  50. package/benchmarks/results/int8-weight-channel.md +0 -118
  51. package/benchmarks/results/int8-weight-only.json +0 -1437
  52. package/benchmarks/results/int8-weight-only.md +0 -118
  53. package/benchmarks/results/kernel-webnn-final.json +0 -1115
  54. package/benchmarks/results/kernel-webnn-final.md +0 -104
  55. package/benchmarks/results/latest-optimized.json +0 -375
  56. package/benchmarks/results/latest-optimized.md +0 -47
  57. package/benchmarks/results/latest.json +0 -391
  58. package/benchmarks/results/latest.md +0 -47
  59. package/benchmarks/results/profile-baseline.json +0 -331
  60. package/benchmarks/results/profile-baseline.md +0 -12
  61. package/benchmarks/results/profile-conv2x.json +0 -331
  62. package/benchmarks/results/profile-conv2x.md +0 -12
  63. package/benchmarks/results/profile-fast-init.json +0 -385
  64. package/benchmarks/results/profile-fast-init.md +0 -47
  65. package/benchmarks/results/profile-fp16-fma.json +0 -369
  66. package/benchmarks/results/profile-fp16-fma.md +0 -47
  67. package/benchmarks/results/profile-fp16-tiled-decoder.json +0 -369
  68. package/benchmarks/results/profile-fp16-tiled-decoder.md +0 -47
  69. package/benchmarks/results/profile-fp16-tiled-encoder.json +0 -369
  70. package/benchmarks/results/profile-fp16-tiled-encoder.md +0 -47
  71. package/benchmarks/results/profile-fp16-unfused-pool.json +0 -385
  72. package/benchmarks/results/profile-fp16-unfused-pool.md +0 -47
  73. package/benchmarks/results/profile-input-major.json +0 -347
  74. package/benchmarks/results/profile-input-major.md +0 -12
  75. package/benchmarks/results/profile-k16.json +0 -347
  76. package/benchmarks/results/profile-k16.md +0 -12
  77. package/benchmarks/results/profile-k4.json +0 -347
  78. package/benchmarks/results/profile-k4.md +0 -12
  79. package/benchmarks/results/profile-pool-reuse.json +0 -331
  80. package/benchmarks/results/profile-pool-reuse.md +0 -12
  81. package/benchmarks/results/profile-precompiled.json +0 -385
  82. package/benchmarks/results/profile-precompiled.md +0 -47
  83. package/benchmarks/results/profile-static-channels.json +0 -385
  84. package/benchmarks/results/profile-static-channels.md +0 -47
  85. package/benchmarks/results/profile-static-io.json +0 -385
  86. package/benchmarks/results/profile-static-io.md +0 -47
  87. package/benchmarks/results/profile-tiled-conv.json +0 -331
  88. package/benchmarks/results/profile-tiled-conv.md +0 -12
  89. package/benchmarks/results/profile-tiled-decoder.json +0 -347
  90. package/benchmarks/results/profile-tiled-decoder.md +0 -12
  91. package/benchmarks/results/profile-tiled-matmul.json +0 -331
  92. package/benchmarks/results/profile-tiled-matmul.md +0 -12
  93. package/benchmarks/results/profile-unfused-decoder.json +0 -379
  94. package/benchmarks/results/profile-unfused-decoder.md +0 -12
  95. package/benchmarks/results/profile-unfused-pool.json +0 -347
  96. package/benchmarks/results/profile-unfused-pool.md +0 -12
  97. package/benchmarks/results/spatial-auto.json +0 -575
  98. package/benchmarks/results/spatial-auto.md +0 -61
  99. package/benchmarks/results/subgroup-smoke.json +0 -1094
  100. package/benchmarks/results/subgroup-smoke.md +0 -104
  101. package/benchmarks/results/webnn-smoke.json +0 -739
  102. package/benchmarks/results/webnn-smoke.md +0 -76
  103. package/scripts/inspect-model.mjs +0 -64
  104. package/tests/modelSpec.test.mjs +0 -128
  105. package/tests/resourceLifecycle.test.mjs +0 -383
  106. package/tests/tileScheduler.test.mjs +0 -90
@@ -1,90 +0,0 @@
1
- import test from 'node:test';
2
- import assert from 'node:assert/strict';
3
-
4
- import {
5
- DynamicTileController,
6
- fitTileDimension,
7
- waitForSubmittedGPUWork
8
- } from '../lib/tileScheduler.js';
9
-
10
- test('starts conservatively and respects the hard maximum', () => {
11
- assert.equal(new DynamicTileController(512).tileSize, 384);
12
- assert.equal(new DynamicTileController(320).tileSize, 320);
13
- assert.equal(fitTileDimension(512, 384), 384);
14
- assert.equal(fitTileDimension(300, 384), 304);
15
- });
16
-
17
- test('reduces slow tiles and grows fast tiles within configured bounds', () => {
18
- const controller = new DynamicTileController(512);
19
-
20
- assert.equal(controller.observe([30, 32, 34]), true);
21
- assert.equal(controller.tileSize, 256);
22
- assert.equal(controller.observe([40]), false);
23
- assert.equal(controller.tileSize, 256);
24
-
25
- assert.equal(controller.observe([4, 6, 8]), true);
26
- assert.equal(controller.tileSize, 384);
27
- assert.equal(controller.observe([5]), true);
28
- assert.equal(controller.tileSize, 512);
29
- assert.equal(controller.observe([5]), false);
30
- });
31
-
32
- test('uses the median and ignores invalid timings', () => {
33
- const controller = new DynamicTileController(512);
34
-
35
- assert.equal(controller.observe([1, 30, Number.NaN]), false);
36
- assert.equal(controller.tileSize, 384);
37
- assert.equal(controller.observe([Number.NaN, Number.POSITIVE_INFINITY]), false);
38
- });
39
-
40
- test('can restore fixed-size behavior', () => {
41
- const controller = new DynamicTileController(500, false);
42
-
43
- assert.equal(controller.tileSize, 496);
44
- assert.equal(controller.observe([100]), false);
45
- assert.equal(controller.tileSize, 496);
46
- });
47
-
48
- test('supports custom adaptive limits and timing targets', () => {
49
- const controller = new DynamicTileController(768, {
50
- minTileSize: 128,
51
- initialTileSize: 512,
52
- targetTileTimeMs: 24,
53
- adjustmentStep: 64
54
- });
55
-
56
- assert.equal(controller.tileSize, 512);
57
- controller.observe([40]);
58
- assert.equal(controller.tileSize, 448);
59
- controller.observe([8]);
60
- assert.equal(controller.tileSize, 512);
61
- });
62
-
63
- test('waits for submitted GPU work before continuing', async () => {
64
- let release;
65
- let completed = false;
66
- const pendingGPUWork = new Promise((resolve) => {
67
- release = resolve;
68
- });
69
- const queue = {
70
- onSubmittedWorkDone: () => pendingGPUWork
71
- };
72
-
73
- const wait = waitForSubmittedGPUWork(queue).then(() => {
74
- completed = true;
75
- });
76
- await Promise.resolve();
77
- assert.equal(completed, false);
78
-
79
- release();
80
- await wait;
81
- assert.equal(completed, true);
82
- });
83
-
84
- test('does not strand scheduling when the GPU wait rejects', async () => {
85
- await assert.doesNotReject(() =>
86
- waitForSubmittedGPUWork({
87
- onSubmittedWorkDone: () => Promise.reject(new Error('device lost'))
88
- })
89
- );
90
- });