Reference

API & Operator Docs

The native C++ engine implements 20 ONNX operators for float32 tensors. The browser runtime is a separate, much smaller Rust interpreter implementing 5 of them (MatMul, Add, Relu, Sigmoid, Softmax) — enough for the fraud model, not for CNNs. Models using anything else are rejected with an explicit reason, never run approximately.

Interfaces

Python (pybind11 module crucible_py)
import numpy as np, crucible_py
model = crucible_py.load_model("resnet18.onnx")
print(crucible_py.check_model(model))      # [] when every op/attribute is supported
x = np.random.rand(1, 3, 224, 224).astype(np.float32)
y = crucible_py.run(model, {"input": x})    # first output, float32 ndarray
HTTP (FastAPI server)
curl -X POST $API/convert -H "Authorization: Bearer $TOKEN" \
     -F model_file=@fraud_detector.onnx          # -> onnx_model_id, unsupported_reasons
curl -X POST $API/infer -H "Authorization: Bearer $TOKEN" \
     -H "Content-Type: application/json" \
     -d '{"model_id":"<id>","input":[0,0,0,0,0,0,0],"input_shape":[1,7]}'
C ABI (shared library crucible)
CrucibleModel* m = crucible_load("model.onnx");
if (!m) { fprintf(stderr, "%s\n", crucible_last_error()); return 1; }
int64_t shape[2] = {1, 7};
CrucibleTensorDesc in = { shape, 2, 7, features };
float* out; CrucibleTensorDesc out_desc;
CrucibleStatus s = crucible_run(m, &in, 1, &out, &out_desc, 1);
crucible_free(m);
Browser (WASM runtime, wasm-bindgen)
import init, { runInference, modelInfo } from "/wasm/crucible_wasm.js";
await init();
const info = JSON.parse(modelInfo(bytes));   // supported, unsupported_reasons, inputs…
const y = runInference(bytes, new Float32Array(x), new Int32Array([1, 7]));

Linear algebra

MatMul
MatMul(A, B) → Y
nativewasm

Matrix product via Eigen. WASM runtime: 2-D operands only.

Gemm
Gemm(A, B, C?) → alpha·A'·B' + beta·C
native

A and B must be rank 2; C is broadcast to (M, N).

Attributes
alpha, betascales, default 1.0
transA, transBtranspose flags, default 0
Add
Add(A, B) → A + B
nativewasm

Numpy-style multidirectional broadcasting (both engines).

Activations

Relu
Relu(X) → max(0, X)
nativewasm

Elementwise.

Sigmoid
Sigmoid(X) → 1 / (1 + e^-X)
nativewasm

Elementwise.

Tanh
Tanh(X) → tanh(X)
native

Elementwise.

LeakyRelu
LeakyRelu(X) → X if X ≥ 0 else alpha·X
native

Elementwise.

Attributes
alphadefault 0.01
Elu
Elu(X) → X if X > 0 else alpha·(e^X − 1)
native

Elementwise.

Attributes
alphadefault 1.0
Gelu
Gelu(X) → X·Φ(X)
native

Exact (erf) or tanh approximation.

Attributes
approximate"none" (default) or "tanh"
Softmax
Softmax(X) → normalised along axis
nativewasm

Opset ≥ 13 normalises one axis (default −1); opset < 13 uses the legacy 2-D coercion (default axis 1). Same semantics in the WASM runtime.

Attributes
axisany valid axis

Convolution & normalisation

Conv
Conv(X[N,C,H,W], W[K,C/g,kH,kW], B?) → Y[N,K,Ho,Wo]
native

2-D only. im2col + Eigen GEMM; 1×1 convolutions skip im2col; depthwise uses a direct loop.

Attributes
strides, padspads must be [top, left, bottom, right]
group≥ 1 (grouped and depthwise supported)
dilationsonly 1 is supported
auto_padNOTSET or VALID only
BatchNormalization
BatchNormalization(X, scale, B, mean, var) → Y
native

Inference mode only.

Attributes
epsilondefault 1e-5
training_modemust be 0

Pooling

MaxPool
MaxPool(X[N,C,H,W]) → Y
native

2-D windows; the optional Indices output is not supported.

Attributes
kernel_shaperequired
strides, padsas Conv
ceil_mode, storage_ordermust be 0
AveragePool
AveragePool(X[N,C,H,W]) → Y
native

2-D windows.

Attributes
kernel_shaperequired
ceil_modemust be 0
GlobalAveragePool
GlobalAveragePool(X[N,C,H,W]) → Y[N,C,1,1]
native

Mean over the spatial dimensions.

Shape & plumbing

Reshape
Reshape(X, shape) → Y
native

Target shape from the second input; supports 0 (copy input dim) and one −1.

Attributes
allowzeromust be 0
Flatten
Flatten(X) → Y[prod(d<axis), prod(d≥axis)]
native

Metadata-only reshape.

Attributes
axisdefault 1
Concat
Concat(X1, …, Xn) → Y
native

All inputs share rank and every dim except axis.

Attributes
axisrequired
Identity
Identity(X) → X
native

Pass-through.

Dropout
Dropout(X) → X
native

Inference: identity. The optional mask output is not supported.