deepcl-common

Crates.iodeepcl-common
lib.rsdeepcl-common
version0.7.0
created_at2025-10-18 00:51:27.08923+00
updated_at2025-10-18 00:51:27.08923+00
descriptionCommon crate for DeepCL
homepage
repositoryhttps://github.com/kothagpt/deepcode/tree/main/crates/deepcl-common
max_upload_size
id1888636
size165,922
KhulnaSoft bot (khulnasoft-bot)

documentation

README

๐Ÿš€ DeepCL - Multi-Platform High-Performance Compute Language for Rust

Blazingly fast tensor operations and deep learning across GPUs, CPUs, and WebAssembly


๐ŸŒŸ Overview

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.

โœจ Key Features

๐Ÿ—๏ธ Architecture

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

๐Ÿš€ Quick Start

Basic Tensor Operations

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(())
}

Custom GPU Kernels

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)
}

Deep Learning Model

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)
    }
}

๐ŸŽฏ Backends

DeepCL supports multiple execution backends for maximum flexibility:

GPU Backends

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

CPU Backends

Backend Platforms Use Case
CPU x86, ARM Optimized CPU operations
NdArray All platforms NumPy-style operations

๐ŸŒ WebAssembly Support

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

๐Ÿ“š Examples

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

๐Ÿ› ๏ธ Installation

Cargo

# 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 Flags

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

๐Ÿ”ฌ Advanced Usage

Custom Operations

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
    }
}

Performance Optimization

use deepcl::prelude::*;

// Enable kernel fusion for better performance
#[cfg(feature = "fusion")]
use deepcl_fusion::Fusion;

type Backend = Fusion<Cuda>;

Distributed Computing

use deepcl::backend::{RemoteBackend, Router};

// Multi-GPU setup
type MultiGpuBackend = Router<(Cuda, Cuda)>;

// Remote execution
type RemoteBackend = deepcl_remote::RemoteBackend;

๐Ÿงช Testing

# Run all tests
cargo test

# Run specific backend tests
cargo test --features cuda

# Run benchmarks
cargo bench

# Test WebAssembly build
wasm-pack test --node

๐Ÿ“– Documentation

๐Ÿค Contributing

We welcome contributions from the community! Here's how you can help:

  1. ๐Ÿ› Bug Reports: Use GitHub Issues
  2. ๐Ÿ’ก Feature Requests: Open an issue with your ideas
  3. ๐Ÿ“ Documentation: Help improve our guides and examples
  4. ๐Ÿงช Testing: Add tests for new functionality
  5. โšก Performance: Optimize existing code or add new backends

Development Setup

# 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

๐Ÿข Enterprise

DeepCL is designed for production use cases:

๐Ÿ“„ License

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.

๐Ÿ™ Acknowledgments

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

Commit count: 0

cargo fmt