Skip to main content
Clorch maps closely to PyTorch’s package structure. Each Clojure namespace corresponds to a PyTorch module, making it straightforward to translate Python patterns. This page lists every namespace, its purpose, and the key public symbols it provides. Expand each accordion for the full function catalogue with brief descriptions.

clorch.torch — Core Tensor Operations

The primary namespace for creating, transforming, and inspecting tensors. It mirrors torch.* top-level functions, extended with Clojure-idiomatic memory-management utilities and LLM-specific primitives.

clorch.autograd — Automatic Differentiation

Provides the five core autograd operations. Mirrors torch.autograd and the .grad attribute pattern from PyTorch.

clorch.nn — Neural Network Modules

The module system, layer zoo, and model-building macros. Mirrors torch.nn.

clorch.nn.functional — Stateless Functional API

Stateless function counterparts for all clorch.nn layer types. Use these when you want to pass weights explicitly rather than maintain module objects.

clorch.nn.init — Parameter Initialization

Functions for in-place weight initialization, matching torch.nn.init.

clorch.nn.parallel — DistributedDataParallel

Wraps a model for synchronous data-parallel training across NCCL ranks.

clorch.optim — Optimizers

Gradient-based parameter update algorithms, matching torch.optim.

clorch.amp — Automatic Mixed Precision

Implements PyTorch-style AMP with autocast and a dynamic gradient scaler for float16 training.

clorch.distributed — Distributed Training

NCCL-backed collective operations and the managed worker launcher.

clorch.data — Data Loading

Dataset protocols, the DataLoader, and distributed sampling.

clorch.cuda — CUDA Utilities

Device discovery, selection, and seeding.

clorch.distributions — Probability Distributions

Probability distribution objects for sampling and log-probability computation.

clorch.linalg — Linear Algebra

A dedicated namespace mirroring torch.linalg, grouping all decomposition and solving operations.

clorch.einsum — Einsum eDSL

A Clojure macro-based eDSL for expressing tensor contractions declaratively, without string-notation index labels.
Example forms: