torch.tx.createEfficientPattern
function createEfficientPattern(pattern: string): (tensors: Record<string, TensorOrNumber>, options?: EfficientOptions) => AnyTensorCreate a curried efficient evaluation function.
The returned function can be called repeatedly with different inputs, optionally writing to the same output buffer.
Parameters
patternstring- The expression pattern
Returns
(tensors: Record<string, TensorOrNumber>, options?: EfficientOptions) => AnyTensor– A function that evaluates the pattern with given tensorsExamples
const linear = createEfficientPattern('x @ w + b');
const out = torch.empty(2, 4);
// Evaluate multiple batches to the same output
for (const batch of batches) {
linear({ x: batch, w, b }, { out });
process(out);
}