| Crates.io | deepcl-common |
| lib.rs | deepcl-common |
| version | 0.7.0 |
| created_at | 2025-10-18 00:51:27.08923+00 |
| updated_at | 2025-10-18 00:51:27.08923+00 |
| description | Common crate for DeepCL |
| homepage | |
| repository | https://github.com/kothagpt/deepcode/tree/main/crates/deepcl-common |
| max_upload_size | |
| id | 1888636 |
| size | 165,922 |
๐ DeepCL - Multi-Platform High-Performance Compute Language for Rust
Blazingly fast tensor operations and deep learning across GPUs, CPUs, and WebAssembly
DeepCL is a next-generation high-performance compute framework for Rust that brings GPU-accelerated tensor operations and deep learning capabilities to native applications. Built from the ground up for performance, portability, and developer experience, DeepCL enables you to harness the full power of modern hardware while maintaining the safety and expressiveness of Rust.
DeepCL is organized into modular crates for maximum flexibility:
| Crate | Description |
|---|---|
deepcl-core |
Core tensor operations and compute graph |
deepcl-runtime |
Async runtime for high-performance execution |
deepcl-cuda |
NVIDIA CUDA backend |
deepcl-wgpu |
WebGPU and SPIR-V support |
deepcl-cpu |
Optimized CPU backend |
deepcl-convolution |
Convolutional neural network operations |
deepcl-attention |
Transformer attention mechanisms |
deepcl-matmul |
Matrix multiplication optimizations |
deepcl-opt |
Kernel optimization and fusion |
use deepcl::{prelude::*, tensor::{Distribution, Tensor}};
fn main() -> Result<(), Box<dyn std::error::Error>> {
// Initialize runtime
let device = CudaDevice::default();
// Create tensors
let x: Tensor<Cuda, 2> = Tensor::random([32, 32], Distribution::Default, &device);
let y: Tensor<Cuda, 2> = Tensor::random([32, 32], Distribution::Default, &device);
// Perform operations
let result = x.matmul(y)?;
println!("Result shape: {:?}", result.shape());
Ok(())
}
use deepcl::{prelude::*, ir::{Instruction, Variable}};
#[cube] // DeepCL's GPU kernel language
fn custom_kernel(input: &Tensor<f32>) -> Tensor<f32> {
let value = input[ABSOLUTE_POS];
// Custom computation
let result = value * 2.0 + 1.0;
Tensor::new(result)
}
use deepcl::nn::{Linear, Module, Sequential};
#[derive(Module)]
pub struct MLP<B: Backend> {
layers: Sequential<B, (Linear<B, 784, 256>, Linear<B, 256, 10>)>,
}
impl<B: Backend> MLP<B> {
pub fn forward(&self, input: Tensor<B, 3>) -> Tensor<B, 3> {
self.layers.forward(input)
}
}
DeepCL supports multiple execution backends for maximum flexibility:
| Backend | Platforms | Use Case |
|---|---|---|
| CUDA | NVIDIA GPUs | High-performance training & inference |
| WGPU | All GPUs + WebAssembly | Cross-platform GPU computing |
| HIP | AMD GPUs | ROCm ecosystem integration |
| SPIR-V | Vulkan-compatible GPUs | Open standard GPU computing |
| Backend | Platforms | Use Case |
|---|---|---|
| CPU | x86, ARM | Optimized CPU operations |
| NdArray | All platforms | NumPy-style operations |
Run DeepCL models directly in web browsers:
# Build for web
wasm-pack build --target web --out-dir pkg
# Example: MNIST inference in browser
cd examples/mnist-inference-web
npm install
npm run serve
Explore comprehensive examples covering various use cases:
| Example | Description |
|---|---|
mnist |
Complete CNN training on MNIST |
image-classification-web |
Web-based image classification |
onnx-inference |
Import and run ONNX models |
custom-wgpu-kernel |
Write custom GPU shaders |
text-classification |
NLP with transformers |
wgan |
Generative adversarial networks |
# Basic installation
cargo add deepcl
# With CUDA support
cargo add deepcl --features cuda
# With WGPU support
cargo add deepcl --features wgpu
# Full installation
cargo add deepcl --features "cuda,wgpu,cpu,convolution,matmul"
| Feature | Description |
|---|---|
cuda |
NVIDIA CUDA backend |
wgpu |
WebGPU/SPIR-V backend |
cpu |
CPU backend |
convolution |
CNN operations |
matmul |
Matrix multiplication |
attention |
Transformer attention |
stdlib |
Standard library functions |
use deepcl::ir::{Operation, Operator};
// Define custom tensor operation
#[derive(Debug)]
pub struct CustomOp {
pub factor: f32,
}
impl Operation for CustomOp {
fn args(&self) -> Vec<Variable> {
// Implementation
}
}
use deepcl::prelude::*;
// Enable kernel fusion for better performance
#[cfg(feature = "fusion")]
use deepcl_fusion::Fusion;
type Backend = Fusion<Cuda>;
use deepcl::backend::{RemoteBackend, Router};
// Multi-GPU setup
type MultiGpuBackend = Router<(Cuda, Cuda)>;
// Remote execution
type RemoteBackend = deepcl_remote::RemoteBackend;
# Run all tests
cargo test
# Run specific backend tests
cargo test --features cuda
# Run benchmarks
cargo bench
# Test WebAssembly build
wasm-pack test --node
We welcome contributions from the community! Here's how you can help:
# Clone the repository
git clone https://github.com/kothagpt/deepcode.git
cd deepcode
# Install dependencies
cargo fetch
# Run tests
cargo test
# Build examples
cargo build --examples
DeepCL is designed for production use cases:
DeepCL is distributed under the terms of both the MIT license and the Apache License (Version 2.0). See LICENSE-APACHE and LICENSE-MIT for details.
DeepCL builds upon the excellent work of the Rust community and draws inspiration from frameworks like PyTorch, TensorFlow, and JAX. Special thanks to:
Made with โค๏ธ by the DeepCL community
โญ Star us on GitHub โข ๐ฌ Join our Discord โข ๐ Read the Book