synor/sdk/flutter/lib/synor_compute.dart
Gulshan Yadav 62ec3c92da feat(sdk): add Flutter/Dart SDK for Synor Compute
Complete SDK implementation for Flutter and Dart applications:

lib/src/types.dart:
- Precision, ProcessorType, Priority, JobStatus enums
- SynorConfig for client configuration
- MatMulOptions, Conv2dOptions, AttentionOptions, InferenceOptions
- PricingInfo and UsageStats data classes
- SynorException for error handling

lib/src/tensor.dart:
- Full Tensor class with shape, dtype, and data
- Factory constructors: zeros, ones, rand, randn, eye, linspace, arange
- Operations: reshape, transpose, flatten
- Statistics: sum, mean, std, min, max, argmin, argmax
- Element-wise: add, sub, mul, div, scalar ops
- Activations: relu, sigmoid, tanh, softmax
- JSON serialization with base64-encoded binary data

lib/src/job.dart:
- JobResult with status, result, timing, and cost
- Job class with WebSocket streaming and HTTP polling
- JobStatusUpdate for real-time progress tracking
- JobBatch for parallel job management

lib/src/client.dart:
- SynorCompute main client
- Operations: matmul, conv2d, attention, elementwise, reduce
- LLM inference with streaming support
- Tensor upload/download/delete
- Job management: submit, cancel, list
- Pricing and usage statistics

Platform support: Android, iOS, Linux, macOS, Web, Windows
2026-01-11 14:27:55 +05:30

92 lines
2.6 KiB
Dart

/// Synor Compute SDK for Flutter/Dart
///
/// A high-performance SDK for distributed heterogeneous computing.
/// Supports CPU, GPU, TPU, NPU, LPU, FPGA, DSP, WebGPU, and WASM processors.
///
/// ## Quick Start
///
/// ```dart
/// import 'package:synor_compute/synor_compute.dart';
///
/// void main() async {
/// // Create client
/// final client = SynorCompute(apiKey: 'your-api-key');
///
/// // Matrix multiplication
/// final a = Tensor.rand([512, 512]);
/// final b = Tensor.rand([512, 512]);
/// final result = await client.matmul(a, b, options: MatMulOptions(
/// precision: Precision.fp16,
/// processor: ProcessorType.gpu,
/// ));
///
/// print('Result shape: ${result.result!.shape}');
/// print('Execution time: ${result.executionTimeMs}ms');
///
/// // LLM Inference
/// final response = await client.inference(
/// 'llama-3-70b',
/// 'Explain quantum computing',
/// options: InferenceOptions(maxTokens: 256),
/// );
/// print(response.result);
///
/// // Streaming inference
/// await for (final token in client.inferenceStream(
/// 'llama-3-70b',
/// 'Write a haiku about computing',
/// )) {
/// stdout.write(token);
/// }
///
/// // Clean up
/// client.dispose();
/// }
/// ```
///
/// ## Features
///
/// - **Matrix Operations**: matmul, conv2d, attention, elementwise, reduce
/// - **LLM Inference**: Standard and streaming inference
/// - **Tensor Management**: Upload, download, and delete tensors
/// - **Job Management**: Submit, poll, cancel, and list jobs
/// - **Pricing**: Get real-time pricing for all processor types
/// - **Usage Statistics**: Track compute usage and costs
///
/// ## Supported Processors
///
/// | Processor | Best For |
/// |-----------|----------|
/// | CPU | General compute, small batches |
/// | GPU | Large matrix operations, training |
/// | TPU | Tensor operations, inference |
/// | NPU | Neural network inference |
/// | LPU | Large language model inference |
/// | FPGA | Custom operations, low latency |
/// | DSP | Signal processing |
/// | WebGPU | Browser-based compute |
/// | WASM | Portable compute |
library synor_compute;
export 'src/types.dart'
show
Precision,
ProcessorType,
Priority,
JobStatus,
BalancingStrategy,
DType,
SynorConfig,
MatMulOptions,
Conv2dOptions,
AttentionOptions,
InferenceOptions,
PricingInfo,
UsageStats,
SynorException;
export 'src/tensor.dart' show Tensor;
export 'src/job.dart' show JobResult, JobStatusUpdate, Job, JobBatch;
export 'src/client.dart' show SynorCompute;