torch.tx.partialPattern
function partialPattern(pattern: string, boundVars: Record<string, TensorOrNumber>): <T extends Record<string, TensorOrNumber>>(tensors: T) => AnyTensorCreate a partial application of a pattern.
Binds some variables, returning a function that takes the remaining ones. Useful for creating specialized versions of general patterns.
Parameters
patternstring- The pattern to partially apply
boundVarsRecord<string, TensorOrNumber>- Variables to bind (will be embedded in the pattern)
Returns
<T extends Record<string, TensorOrNumber>>(tensors: T) => AnyTensor– A function that takes the remaining variablesExamples
// Create a linear layer with fixed weights
const linear = $.partial('x @ w + b', { w: weights, b: bias });
// Now only needs 'x'
const y1 = linear({ x: input1 });
const y2 = linear({ x: input2 });