Blyx v0.1.0-alpha is here! Read the release notes ->
Home / Code Examples

Searchable Blyx Code Examples

Explore practical code samples across AI, GPU kernels, actor concurrency, CLI binaries, and high-performance networking.

Static Neural Network Layer

AI & Tensor

Compile-time dimension checked matrix multiplication pass.

import std.tensor;

fn forward(w: tensor<f32, 128, 64>, x: tensor<f32, 64, 32>) -> tensor<f32, 128, 32> {
    return matmul(w, x);
}

Inline GPU Thread Grid Vector Scaling

GPU

Direct PTX lower GPU kernel.

gpu {
    let tid = thread_id();
    data[tid] = data[tid] * 2.5;
}

Lock-Free Ping-Pong Message Passing

Actors

142M msg/sec concurrency runtime.

actor PingPong {
    fn receive(msg: Message) {
        match msg { Ping => send(Pong) }
    }
}

Fast Arguments Parser & Streaming Input

CLI

Zero dependency CLI utility.

import std.cli;

fn main() {
    let args = cli::parse();
    println("Command: {}", args.command);
}

Asynchronous HTTP/3 Server

Networking

High throughput web service.

import std.net.http;

fn main() {
    let server = http::Server::bind("127.0.0.1:8080");
    server.listen(|req| -> Response { Response::ok("Blyx Server") });
}