edgeflowjs 0.1.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 (98) hide show
  1. package/README.md +473 -0
  2. package/dist/backends/index.d.ts +13 -0
  3. package/dist/backends/index.d.ts.map +1 -0
  4. package/dist/backends/index.js +32 -0
  5. package/dist/backends/index.js.map +1 -0
  6. package/dist/backends/onnx.d.ts +46 -0
  7. package/dist/backends/onnx.d.ts.map +1 -0
  8. package/dist/backends/onnx.js +249 -0
  9. package/dist/backends/onnx.js.map +1 -0
  10. package/dist/backends/wasm.d.ts +78 -0
  11. package/dist/backends/wasm.d.ts.map +1 -0
  12. package/dist/backends/wasm.js +358 -0
  13. package/dist/backends/wasm.js.map +1 -0
  14. package/dist/backends/webgpu.d.ts +143 -0
  15. package/dist/backends/webgpu.d.ts.map +1 -0
  16. package/dist/backends/webgpu.js +326 -0
  17. package/dist/backends/webgpu.js.map +1 -0
  18. package/dist/backends/webnn.d.ts +115 -0
  19. package/dist/backends/webnn.d.ts.map +1 -0
  20. package/dist/backends/webnn.js +202 -0
  21. package/dist/backends/webnn.js.map +1 -0
  22. package/dist/core/index.d.ts +9 -0
  23. package/dist/core/index.d.ts.map +1 -0
  24. package/dist/core/index.js +14 -0
  25. package/dist/core/index.js.map +1 -0
  26. package/dist/core/memory.d.ts +234 -0
  27. package/dist/core/memory.d.ts.map +1 -0
  28. package/dist/core/memory.js +554 -0
  29. package/dist/core/memory.js.map +1 -0
  30. package/dist/core/runtime.d.ts +129 -0
  31. package/dist/core/runtime.d.ts.map +1 -0
  32. package/dist/core/runtime.js +352 -0
  33. package/dist/core/runtime.js.map +1 -0
  34. package/dist/core/scheduler.d.ts +118 -0
  35. package/dist/core/scheduler.d.ts.map +1 -0
  36. package/dist/core/scheduler.js +600 -0
  37. package/dist/core/scheduler.js.map +1 -0
  38. package/dist/core/tensor.d.ts +149 -0
  39. package/dist/core/tensor.d.ts.map +1 -0
  40. package/dist/core/tensor.js +719 -0
  41. package/dist/core/tensor.js.map +1 -0
  42. package/dist/core/types.d.ts +367 -0
  43. package/dist/core/types.d.ts.map +1 -0
  44. package/dist/core/types.js +54 -0
  45. package/dist/core/types.js.map +1 -0
  46. package/dist/edgeflow.browser.js +5601 -0
  47. package/dist/edgeflow.browser.js.map +7 -0
  48. package/dist/edgeflow.browser.min.js +19 -0
  49. package/dist/edgeflow.browser.min.js.map +7 -0
  50. package/dist/index.d.ts +71 -0
  51. package/dist/index.d.ts.map +1 -0
  52. package/dist/index.js +158 -0
  53. package/dist/index.js.map +1 -0
  54. package/dist/pipelines/base.d.ts +122 -0
  55. package/dist/pipelines/base.d.ts.map +1 -0
  56. package/dist/pipelines/base.js +155 -0
  57. package/dist/pipelines/base.js.map +1 -0
  58. package/dist/pipelines/feature-extraction.d.ts +68 -0
  59. package/dist/pipelines/feature-extraction.d.ts.map +1 -0
  60. package/dist/pipelines/feature-extraction.js +197 -0
  61. package/dist/pipelines/feature-extraction.js.map +1 -0
  62. package/dist/pipelines/image-classification.d.ts +61 -0
  63. package/dist/pipelines/image-classification.d.ts.map +1 -0
  64. package/dist/pipelines/image-classification.js +140 -0
  65. package/dist/pipelines/image-classification.js.map +1 -0
  66. package/dist/pipelines/index.d.ts +58 -0
  67. package/dist/pipelines/index.d.ts.map +1 -0
  68. package/dist/pipelines/index.js +72 -0
  69. package/dist/pipelines/index.js.map +1 -0
  70. package/dist/pipelines/text-classification.d.ts +71 -0
  71. package/dist/pipelines/text-classification.d.ts.map +1 -0
  72. package/dist/pipelines/text-classification.js +175 -0
  73. package/dist/pipelines/text-classification.js.map +1 -0
  74. package/dist/tools/index.d.ts +143 -0
  75. package/dist/tools/index.d.ts.map +1 -0
  76. package/dist/tools/index.js +294 -0
  77. package/dist/tools/index.js.map +1 -0
  78. package/dist/utils/cache.d.ts +162 -0
  79. package/dist/utils/cache.d.ts.map +1 -0
  80. package/dist/utils/cache.js +443 -0
  81. package/dist/utils/cache.js.map +1 -0
  82. package/dist/utils/index.d.ts +8 -0
  83. package/dist/utils/index.d.ts.map +1 -0
  84. package/dist/utils/index.js +12 -0
  85. package/dist/utils/index.js.map +1 -0
  86. package/dist/utils/model-loader.d.ts +107 -0
  87. package/dist/utils/model-loader.d.ts.map +1 -0
  88. package/dist/utils/model-loader.js +694 -0
  89. package/dist/utils/model-loader.js.map +1 -0
  90. package/dist/utils/preprocessor.d.ts +147 -0
  91. package/dist/utils/preprocessor.d.ts.map +1 -0
  92. package/dist/utils/preprocessor.js +423 -0
  93. package/dist/utils/preprocessor.js.map +1 -0
  94. package/dist/utils/tokenizer.d.ts +140 -0
  95. package/dist/utils/tokenizer.d.ts.map +1 -0
  96. package/dist/utils/tokenizer.js +397 -0
  97. package/dist/utils/tokenizer.js.map +1 -0
  98. package/package.json +87 -0
package/README.md ADDED
@@ -0,0 +1,473 @@
1
+ # edgeFlow.js
2
+
3
+ <div align="center">
4
+
5
+ **Lightweight, high-performance browser ML inference framework.**
6
+
7
+ [![npm version](https://img.shields.io/npm/v/edgeflowjs.svg)](https://www.npmjs.com/package/edgeflowjs)
8
+ [![bundle size](https://img.shields.io/bundlephobia/minzip/edgeflowjs)](https://bundlephobia.com/package/edgeflowjs)
9
+ [![license](https://img.shields.io/npm/l/edgeflowjs)](LICENSE)
10
+
11
+ [Documentation](https://edgeflow.js.org) · [Examples](examples/) · [API Reference](https://edgeflow.js.org/api) · [English](README.md) | [中文](README_CN.md)
12
+
13
+ </div>
14
+
15
+ ---
16
+
17
+ ## ✨ Features
18
+
19
+ - 🚀 **Native Concurrency** - Run multiple models in parallel, no more serial execution bottleneck
20
+ - 📦 **Lightweight** - Core bundle < 500KB, zero runtime dependencies
21
+ - 🔄 **Native Batch Processing** - Efficient batch inference out of the box
22
+ - 💾 **Smart Memory Management** - Automatic memory tracking and cleanup
23
+ - 🎯 **Developer Friendly** - Full TypeScript support with intuitive APIs
24
+ - 🔌 **Modular Architecture** - Import only what you need
25
+ - 📥 **Advanced Model Loading** - Preloading, sharding, resume download support
26
+ - 💿 **Intelligent Caching** - IndexedDB-based model caching for offline use
27
+ - ⚡ **High Performance** - WebGPU-first with automatic fallback to WebNN/WASM
28
+
29
+ ## 📦 Installation
30
+
31
+ ```bash
32
+ npm install edgeflow
33
+ ```
34
+
35
+ ```bash
36
+ yarn add edgeflow
37
+ ```
38
+
39
+ ```bash
40
+ pnpm add edgeflow
41
+ ```
42
+
43
+ ## 🚀 Quick Start
44
+
45
+ ### Try the Demo
46
+
47
+ Run the interactive demo locally to test all features:
48
+
49
+ ```bash
50
+ # Clone and install
51
+ git clone https://github.com/user/edgeflow.js.git
52
+ cd edgeflow.js
53
+ npm install
54
+
55
+ # Build and start demo server
56
+ npm run demo
57
+ ```
58
+
59
+ Open **http://localhost:3000** in your browser:
60
+
61
+ 1. **Load Model** - Enter a Hugging Face ONNX model URL and click "Load Model"
62
+ ```
63
+ https://huggingface.co/Xenova/distilbert-base-uncased-finetuned-sst-2-english/resolve/main/onnx/model_quantized.onnx
64
+ ```
65
+
66
+ 2. **Test Features**:
67
+ - 🧮 **Tensor Operations** - Test tensor creation, math ops, softmax, relu
68
+ - 📝 **Text Classification** - Run sentiment analysis on text
69
+ - 🔍 **Feature Extraction** - Extract embeddings from text
70
+ - ⚡ **Concurrent Execution** - Test parallel inference
71
+ - 📋 **Task Scheduler** - Test priority-based task scheduling
72
+ - 💾 **Memory Management** - Test allocation and cleanup
73
+
74
+ ### Basic Usage
75
+
76
+ ```typescript
77
+ import { pipeline } from 'edgeflow';
78
+
79
+ // Create a sentiment analysis pipeline
80
+ const sentiment = await pipeline('sentiment-analysis');
81
+
82
+ // Run inference
83
+ const result = await sentiment.run('I love this product!');
84
+ console.log(result);
85
+ // { label: 'positive', score: 0.98, processingTime: 12.5 }
86
+ ```
87
+
88
+ ### Batch Processing
89
+
90
+ ```typescript
91
+ // Native batch processing support
92
+ const results = await sentiment.run([
93
+ 'This is amazing!',
94
+ 'This is terrible.',
95
+ 'It\'s okay I guess.'
96
+ ]);
97
+
98
+ console.log(results);
99
+ // [
100
+ // { label: 'positive', score: 0.95 },
101
+ // { label: 'negative', score: 0.92 },
102
+ // { label: 'neutral', score: 0.68 }
103
+ // ]
104
+ ```
105
+
106
+ ### Concurrent Execution
107
+
108
+ ```typescript
109
+ import { pipeline } from 'edgeflow';
110
+
111
+ // Create multiple pipelines
112
+ const classifier = await pipeline('text-classification');
113
+ const extractor = await pipeline('feature-extraction');
114
+
115
+ // Run concurrently - no more serial bottleneck!
116
+ const [classification, features] = await Promise.all([
117
+ classifier.run('Sample text'),
118
+ extractor.run('Sample text')
119
+ ]);
120
+ ```
121
+
122
+ ### Image Classification
123
+
124
+ ```typescript
125
+ import { pipeline } from 'edgeflow';
126
+
127
+ const classifier = await pipeline('image-classification');
128
+
129
+ // From URL
130
+ const result = await classifier.run('https://example.com/image.jpg');
131
+
132
+ // From HTMLImageElement
133
+ const img = document.getElementById('myImage');
134
+ const result = await classifier.run(img);
135
+
136
+ // Batch
137
+ const results = await classifier.run([img1, img2, img3]);
138
+ ```
139
+
140
+ ## 🎯 Supported Tasks
141
+
142
+ | Task | Pipeline | Status |
143
+ |------|----------|--------|
144
+ | Text Classification | `text-classification` | ✅ |
145
+ | Sentiment Analysis | `sentiment-analysis` | ✅ |
146
+ | Feature Extraction | `feature-extraction` | ✅ |
147
+ | Image Classification | `image-classification` | ✅ |
148
+ | Object Detection | `object-detection` | 🔜 |
149
+ | Text Generation | `text-generation` | 🔜 |
150
+ | Speech Recognition | `automatic-speech-recognition` | 🔜 |
151
+
152
+ ## ⚡ Performance
153
+
154
+ ### Comparison with transformers.js
155
+
156
+ | Feature | transformers.js | edgeFlow.js |
157
+ |---------|-----------------|-------------|
158
+ | Concurrent Execution | ❌ Serial | ✅ Parallel |
159
+ | Batch Processing | ⚠️ Partial | ✅ Native |
160
+ | Memory Management | ⚠️ Basic | ✅ Complete |
161
+ | Bundle Size | ~2-5MB | <500KB |
162
+ | Dependencies | ONNX Runtime | Optional |
163
+
164
+ ### Benchmarks
165
+
166
+ ```
167
+ Text Classification (BERT-base):
168
+ - transformers.js: 45ms (serial)
169
+ - edgeFlow.js: 42ms (parallel capable)
170
+
171
+ Concurrent 4 models:
172
+ - transformers.js: 180ms (4 × 45ms serial)
173
+ - edgeFlow.js: 52ms (parallel execution)
174
+ ```
175
+
176
+ ## 🔧 Configuration
177
+
178
+ ### Runtime Selection
179
+
180
+ ```typescript
181
+ import { pipeline } from 'edgeflow';
182
+
183
+ // Automatic (recommended)
184
+ const model = await pipeline('text-classification');
185
+
186
+ // Specify runtime
187
+ const model = await pipeline('text-classification', {
188
+ runtime: 'webgpu' // or 'webnn', 'wasm', 'auto'
189
+ });
190
+ ```
191
+
192
+ ### Memory Management
193
+
194
+ ```typescript
195
+ import { pipeline, getMemoryStats, gc } from 'edgeflow';
196
+
197
+ const model = await pipeline('text-classification');
198
+
199
+ // Use the model
200
+ await model.run('text');
201
+
202
+ // Check memory usage
203
+ console.log(getMemoryStats());
204
+ // { allocated: 50MB, used: 45MB, peak: 52MB, tensorCount: 12 }
205
+
206
+ // Explicit cleanup
207
+ model.dispose();
208
+
209
+ // Force garbage collection
210
+ gc();
211
+ ```
212
+
213
+ ### Scheduler Configuration
214
+
215
+ ```typescript
216
+ import { configureScheduler } from 'edgeflow';
217
+
218
+ configureScheduler({
219
+ maxConcurrentTasks: 4,
220
+ maxConcurrentPerModel: 1,
221
+ defaultTimeout: 30000,
222
+ enableBatching: true,
223
+ maxBatchSize: 32,
224
+ });
225
+ ```
226
+
227
+ ### Caching
228
+
229
+ ```typescript
230
+ import { pipeline, Cache } from 'edgeflow';
231
+
232
+ // Create a cache
233
+ const cache = new Cache({
234
+ strategy: 'lru',
235
+ maxSize: 100 * 1024 * 1024, // 100MB
236
+ persistent: true, // Use IndexedDB
237
+ });
238
+
239
+ const model = await pipeline('text-classification', {
240
+ cache: true
241
+ });
242
+ ```
243
+
244
+ ## 🛠️ Advanced Usage
245
+
246
+ ### Custom Model Loading
247
+
248
+ ```typescript
249
+ import { loadModel, runInference } from 'edgeflow';
250
+
251
+ // Load from URL with caching, sharding, and resume support
252
+ const model = await loadModel('https://example.com/model.bin', {
253
+ runtime: 'webgpu',
254
+ quantization: 'int8',
255
+ cache: true, // Enable IndexedDB caching (default: true)
256
+ resumable: true, // Enable resume download (default: true)
257
+ chunkSize: 5 * 1024 * 1024, // 5MB chunks for large models
258
+ onProgress: (progress) => console.log(`Loading: ${progress * 100}%`)
259
+ });
260
+
261
+ // Run inference
262
+ const outputs = await runInference(model, inputs);
263
+
264
+ // Cleanup
265
+ model.dispose();
266
+ ```
267
+
268
+ ### Preloading Models
269
+
270
+ ```typescript
271
+ import { preloadModel, preloadModels, getPreloadStatus } from 'edgeflow';
272
+
273
+ // Preload a single model in background (with priority)
274
+ preloadModel('https://example.com/model1.onnx', { priority: 10 });
275
+
276
+ // Preload multiple models
277
+ preloadModels([
278
+ { url: 'https://example.com/model1.onnx', priority: 10 },
279
+ { url: 'https://example.com/model2.onnx', priority: 5 },
280
+ ]);
281
+
282
+ // Check preload status
283
+ const status = getPreloadStatus('https://example.com/model1.onnx');
284
+ // 'pending' | 'loading' | 'complete' | 'error' | 'not_found'
285
+ ```
286
+
287
+ ### Model Caching
288
+
289
+ ```typescript
290
+ import {
291
+ isModelCached,
292
+ getCachedModel,
293
+ deleteCachedModel,
294
+ clearModelCache,
295
+ getModelCacheStats
296
+ } from 'edgeflow';
297
+
298
+ // Check if model is cached
299
+ if (await isModelCached('https://example.com/model.onnx')) {
300
+ console.log('Model is cached!');
301
+ }
302
+
303
+ // Get cached model data directly
304
+ const modelData = await getCachedModel('https://example.com/model.onnx');
305
+
306
+ // Delete a specific cached model
307
+ await deleteCachedModel('https://example.com/model.onnx');
308
+
309
+ // Clear all cached models
310
+ await clearModelCache();
311
+
312
+ // Get cache statistics
313
+ const stats = await getModelCacheStats();
314
+ console.log(`${stats.models} models cached, ${stats.totalSize} bytes total`);
315
+ ```
316
+
317
+ ### Resume Downloads
318
+
319
+ Large model downloads automatically support resuming from where they left off:
320
+
321
+ ```typescript
322
+ import { loadModelData } from 'edgeflow';
323
+
324
+ // Download with progress and resume support
325
+ const modelData = await loadModelData('https://example.com/large-model.onnx', {
326
+ resumable: true,
327
+ chunkSize: 10 * 1024 * 1024, // 10MB chunks
328
+ parallelConnections: 4, // Download 4 chunks in parallel
329
+ onProgress: (progress) => {
330
+ console.log(`${progress.percent.toFixed(1)}% downloaded`);
331
+ console.log(`Speed: ${(progress.speed / 1024 / 1024).toFixed(2)} MB/s`);
332
+ console.log(`ETA: ${(progress.eta / 1000).toFixed(0)}s`);
333
+ console.log(`Chunk ${progress.currentChunk}/${progress.totalChunks}`);
334
+ }
335
+ });
336
+ ```
337
+
338
+ ### Model Quantization
339
+
340
+ ```typescript
341
+ import { quantize } from 'edgeflow/tools';
342
+
343
+ const quantized = await quantize(model, {
344
+ method: 'int8',
345
+ calibrationData: samples,
346
+ });
347
+
348
+ console.log(`Compression: ${quantized.compressionRatio}x`);
349
+ // Compression: 3.8x
350
+ ```
351
+
352
+ ### Benchmarking
353
+
354
+ ```typescript
355
+ import { benchmark } from 'edgeflow/tools';
356
+
357
+ const result = await benchmark(
358
+ () => model.run('sample text'),
359
+ { warmupRuns: 5, runs: 100 }
360
+ );
361
+
362
+ console.log(result);
363
+ // {
364
+ // avgTime: 12.5,
365
+ // minTime: 10.2,
366
+ // maxTime: 18.3,
367
+ // throughput: 80 // inferences/sec
368
+ // }
369
+ ```
370
+
371
+ ### Memory Scope
372
+
373
+ ```typescript
374
+ import { withMemoryScope, tensor } from 'edgeflow';
375
+
376
+ const result = await withMemoryScope(async (scope) => {
377
+ // Tensors tracked in scope
378
+ const a = scope.track(tensor([1, 2, 3]));
379
+ const b = scope.track(tensor([4, 5, 6]));
380
+
381
+ // Process...
382
+ const output = process(a, b);
383
+
384
+ // Keep result, dispose others
385
+ return scope.keep(output);
386
+ });
387
+ // a and b automatically disposed
388
+ ```
389
+
390
+ ## 🔌 Tensor Operations
391
+
392
+ ```typescript
393
+ import { tensor, zeros, ones, matmul, softmax, relu } from 'edgeflow';
394
+
395
+ // Create tensors
396
+ const a = tensor([[1, 2], [3, 4]]);
397
+ const b = zeros([2, 2]);
398
+ const c = ones([2, 2]);
399
+
400
+ // Operations
401
+ const d = matmul(a, c);
402
+ const probs = softmax(d);
403
+ const activated = relu(d);
404
+
405
+ // Cleanup
406
+ a.dispose();
407
+ b.dispose();
408
+ c.dispose();
409
+ ```
410
+
411
+ ## 🌐 Browser Support
412
+
413
+ | Browser | WebGPU | WebNN | WASM |
414
+ |---------|--------|-------|------|
415
+ | Chrome 113+ | ✅ | ✅ | ✅ |
416
+ | Edge 113+ | ✅ | ✅ | ✅ |
417
+ | Firefox 118+ | ⚠️ Flag | ❌ | ✅ |
418
+ | Safari 17+ | ⚠️ Preview | ❌ | ✅ |
419
+
420
+ ## 📖 API Reference
421
+
422
+ ### Core
423
+
424
+ - `pipeline(task, options?)` - Create a pipeline for a task
425
+ - `loadModel(url, options?)` - Load a model from URL
426
+ - `runInference(model, inputs)` - Run model inference
427
+ - `getScheduler()` - Get the global scheduler
428
+ - `getMemoryManager()` - Get the memory manager
429
+
430
+ ### Pipelines
431
+
432
+ - `TextClassificationPipeline`
433
+ - `SentimentAnalysisPipeline`
434
+ - `FeatureExtractionPipeline`
435
+ - `ImageClassificationPipeline`
436
+
437
+ ### Utilities
438
+
439
+ - `Tokenizer` - Text tokenization
440
+ - `ImagePreprocessor` - Image preprocessing
441
+ - `AudioPreprocessor` - Audio preprocessing
442
+ - `Cache` - Caching utilities
443
+
444
+ ### Tools
445
+
446
+ - `quantize(model, options)` - Quantize a model
447
+ - `prune(model, options)` - Prune model weights
448
+ - `benchmark(fn, options)` - Benchmark inference
449
+ - `analyzeModel(model)` - Analyze model structure
450
+
451
+ ## 🤝 Contributing
452
+
453
+ We welcome contributions! Please see our [Contributing Guide](CONTRIBUTING.md) for details.
454
+
455
+ 1. Fork the repository
456
+ 2. Create your feature branch (`git checkout -b feature/amazing-feature`)
457
+ 3. Commit your changes (`git commit -m 'Add amazing feature'`)
458
+ 4. Push to the branch (`git push origin feature/amazing-feature`)
459
+ 5. Open a Pull Request
460
+
461
+ ## 📄 License
462
+
463
+ MIT © edgeFlow.js Contributors
464
+
465
+ ---
466
+
467
+ <div align="center">
468
+
469
+ **[Get Started](https://edgeflow.js.org/getting-started) · [API Docs](https://edgeflow.js.org/api) · [Examples](examples/)**
470
+
471
+ Made with ❤️ for the edge AI community
472
+
473
+ </div>
@@ -0,0 +1,13 @@
1
+ /**
2
+ * edgeFlow.js - Backend Exports
3
+ */
4
+ export { WebGPURuntime, createWebGPURuntime } from './webgpu.js';
5
+ export { WebNNRuntime, createWebNNRuntime } from './webnn.js';
6
+ export { WASMRuntime, createWASMRuntime } from './wasm.js';
7
+ export { ONNXRuntime, createONNXRuntime } from './onnx.js';
8
+ export type { Runtime, RuntimeType, RuntimeCapabilities } from '../core/types.js';
9
+ /**
10
+ * Register all available backends
11
+ */
12
+ export declare function registerAllBackends(): void;
13
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/backends/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,OAAO,EAAE,aAAa,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAGjE,OAAO,EAAE,YAAY,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAG9D,OAAO,EAAE,WAAW,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAC;AAG3D,OAAO,EAAE,WAAW,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAC;AAG3D,YAAY,EAAE,OAAO,EAAE,WAAW,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AAUlF;;GAEG;AACH,wBAAgB,mBAAmB,IAAI,IAAI,CAK1C"}
@@ -0,0 +1,32 @@
1
+ /**
2
+ * edgeFlow.js - Backend Exports
3
+ */
4
+ // WebGPU Backend
5
+ export { WebGPURuntime, createWebGPURuntime } from './webgpu.js';
6
+ // WebNN Backend
7
+ export { WebNNRuntime, createWebNNRuntime } from './webnn.js';
8
+ // WASM Backend (basic tensor ops)
9
+ export { WASMRuntime, createWASMRuntime } from './wasm.js';
10
+ // ONNX Runtime Backend (real model inference)
11
+ export { ONNXRuntime, createONNXRuntime } from './onnx.js';
12
+ /**
13
+ * Initialize all backends with the runtime manager
14
+ */
15
+ import { registerRuntime } from '../core/runtime.js';
16
+ import { createWebGPURuntime } from './webgpu.js';
17
+ import { createWebNNRuntime } from './webnn.js';
18
+ import { createONNXRuntime } from './onnx.js';
19
+ /**
20
+ * Register all available backends
21
+ */
22
+ export function registerAllBackends() {
23
+ registerRuntime('webgpu', createWebGPURuntime);
24
+ registerRuntime('webnn', createWebNNRuntime);
25
+ // Use ONNX Runtime as the WASM backend for real model inference
26
+ registerRuntime('wasm', createONNXRuntime);
27
+ }
28
+ /**
29
+ * Auto-register backends on module load
30
+ */
31
+ registerAllBackends();
32
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/backends/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,iBAAiB;AACjB,OAAO,EAAE,aAAa,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAEjE,gBAAgB;AAChB,OAAO,EAAE,YAAY,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAE9D,kCAAkC;AAClC,OAAO,EAAE,WAAW,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAC;AAE3D,8CAA8C;AAC9C,OAAO,EAAE,WAAW,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAC;AAK3D;;GAEG;AACH,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAClD,OAAO,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAChD,OAAO,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAC;AAE9C;;GAEG;AACH,MAAM,UAAU,mBAAmB;IACjC,eAAe,CAAC,QAAQ,EAAE,mBAAmB,CAAC,CAAC;IAC/C,eAAe,CAAC,OAAO,EAAE,kBAAkB,CAAC,CAAC;IAC7C,gEAAgE;IAChE,eAAe,CAAC,MAAM,EAAE,iBAAiB,CAAC,CAAC;AAC7C,CAAC;AAED;;GAEG;AACH,mBAAmB,EAAE,CAAC"}
@@ -0,0 +1,46 @@
1
+ /**
2
+ * edgeFlow.js - ONNX Runtime Backend
3
+ *
4
+ * Uses onnxruntime-web for real ONNX model inference.
5
+ * Automatically loads ONNX Runtime from CDN when needed.
6
+ */
7
+ import { Runtime, RuntimeType, RuntimeCapabilities, LoadedModel, ModelLoadOptions, Tensor } from '../core/types.js';
8
+ /**
9
+ * ONNXRuntime - Real ONNX model inference using onnxruntime-web
10
+ * Automatically loads ONNX Runtime from CDN when first used.
11
+ */
12
+ export declare class ONNXRuntime implements Runtime {
13
+ readonly name: RuntimeType;
14
+ private initialized;
15
+ private executionProvider;
16
+ get capabilities(): RuntimeCapabilities;
17
+ /**
18
+ * Check if ONNX Runtime is available (always true - will be loaded from CDN)
19
+ */
20
+ isAvailable(): Promise<boolean>;
21
+ /**
22
+ * Initialize the ONNX runtime (loads from CDN if needed)
23
+ */
24
+ initialize(): Promise<void>;
25
+ /**
26
+ * Load a model from ArrayBuffer
27
+ */
28
+ loadModel(modelData: ArrayBuffer, options?: ModelLoadOptions): Promise<LoadedModel>;
29
+ /**
30
+ * Run inference
31
+ */
32
+ run(model: LoadedModel, inputs: Tensor[]): Promise<Tensor[]>;
33
+ /**
34
+ * Unload a model
35
+ */
36
+ private unloadModel;
37
+ /**
38
+ * Dispose the runtime
39
+ */
40
+ dispose(): void;
41
+ }
42
+ /**
43
+ * Create ONNX runtime factory
44
+ */
45
+ export declare function createONNXRuntime(): Runtime;
46
+ //# sourceMappingURL=onnx.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"onnx.d.ts","sourceRoot":"","sources":["../../src/backends/onnx.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EACL,OAAO,EACP,WAAW,EACX,mBAAmB,EACnB,WAAW,EACX,gBAAgB,EAEhB,MAAM,EAIP,MAAM,kBAAkB,CAAC;AAuF1B;;;GAGG;AACH,qBAAa,WAAY,YAAW,OAAO;IACzC,QAAQ,CAAC,IAAI,EAAE,WAAW,CAAU;IAEpC,OAAO,CAAC,WAAW,CAAS;IAC5B,OAAO,CAAC,iBAAiB,CAA6B;IAEtD,IAAI,YAAY,IAAI,mBAAmB,CAStC;IAED;;OAEG;IACG,WAAW,IAAI,OAAO,CAAC,OAAO,CAAC;IAKrC;;OAEG;IACG,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC;IAejC;;OAEG;IACG,SAAS,CACb,SAAS,EAAE,WAAW,EACtB,OAAO,GAAE,gBAAqB,GAC7B,OAAO,CAAC,WAAW,CAAC;IA0EvB;;OAEG;IACG,GAAG,CAAC,KAAK,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC;IAmElE;;OAEG;YACW,WAAW;IAQzB;;OAEG;IACH,OAAO,IAAI,IAAI;CAKhB;AAED;;GAEG;AACH,wBAAgB,iBAAiB,IAAI,OAAO,CAE3C"}