Skip to main content

teeny_compiler/
lib.rs

1/*
2 * Copyright (c) 2026 Teenygrad.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 *   http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17//! Compiles a [teenygrad](https://teenygrad.org) computational graph (FXGraph, traced from
18//! `teeny-core`) down to a target backend — LLVM/MLIR object code today ([`compiler::backend`]),
19//! with an `ndarray`-backed CPU path behind the `ndarray` feature.
20//!
21//! Compiling kernels through the LLVM backend shells out to the custom `teenyc` compiler at
22//! *runtime*, resolved via [`compiler::find_teenyc`] (`TEENYC_PATH`, or a `rustup`-linked
23//! toolchain otherwise) — not needed to build this crate itself. See the crate README for the
24//! `cargo-teeny` setup.
25
26#![warn(missing_docs)]
27
28/// Compilation backends and drivers (LLVM/MLIR, `ndarray`).
29pub mod compiler;
30/// Error types.
31pub mod errors;
32/// FXGraph, the compiler's intermediate representation.
33pub mod fxgraph;
34
35/// Initialize logging for the teeny-compiler
36pub fn init_logging() {
37    use tracing_subscriber::{EnvFilter, fmt};
38
39    let _ = fmt()
40        .with_env_filter(EnvFilter::from_default_env())
41        .try_init();
42}