torch.tx.evaluateEfficient
function evaluateEfficient(pattern: string, tensors: Record<string, TensorOrNumber>, options?: EfficientOptions): AnyTensorEvaluate an expression efficiently with optional output buffer.
If out is provided, the result is written to it instead of allocating
a new tensor. This is useful for reducing memory allocations in hot loops.
Parameters
patternstring- The expression pattern
tensorsRecord<string, TensorOrNumber>- Variable bindings
optionsEfficientOptionsoptional- Evaluation options including output buffer
Returns
AnyTensor– The result tensor (same as out if provided)Examples
const out = torch.empty(2, 4);
// Evaluate and write to existing buffer
evaluateEfficient('x @ w + b', { x, w, b }, { out });
// `out` now contains the result