torch.tx.TypedTensorExpr
export interface TypedTensorExpr {
// Overload 1: String call → returns curried pattern function with FULL type safety
// Usage: $('a @ b')({ a, b })
<const P extends string>(pattern: P): PatternFunction<P>;
// Overload 2: Tagged template WITH interpolations → evaluates immediately
// Usage: $`${a} @ ${b}`
<const Strings extends readonly string[], const Tensors extends readonly [TensorOrNumber, ...TensorOrNumber[]]>(
strings: TemplateStringsArray & { readonly raw: Strings },
...tensors: Tensors
): TensorExprResult<Strings, Tensors>;
// Overload 3: Tagged template WITHOUT interpolations → ERROR at runtime
// This overload exists only to provide a helpful error message
(strings: TemplateStringsArray): never;
}Tensor expression DSL with two distinct modes:
1. Pattern Mode (curried, full type safety)
$('x @ w + b')({ x, w, b }) // Compile-time shape inferenceUse this for reusable expressions or when you want TypeScript to catch shape errors.
2. Interpolation Mode (immediate evaluation)
$`${x} @ ${w} + ${b}` // Evaluates immediately, returns TensorUse this for inline expressions with existing tensor variables.