jax.experimental.pallas.fuser.push_pull_block_spec#
- jax.experimental.pallas.fuser.push_pull_block_spec(f, *block_specs, scalar_prefetch_handler=None, grid_len=None, **block_spec_kwargs)[source]#
Pushes
BlockSpecsforward through an output fusion, then pulls them back.For an output fusion
f(values, *args, **kwargs)with closed-over side inputsvalues(assignedno_block_specduring the forward push) and unfused kernel outputs*args, **kwargs, pushesblock_specsforward throughfand then pulls the resulting outputBlockSpecsbackward (withstrict_mode=False) to deriveBlockSpecsforvaluesand build the block-level kernel function.- Parameters:
f (Callable) – Output fusion function taking
(values, *args, **kwargs).*block_specs (Any) –
BlockSpecsfor the positional kernel outputs*args.scalar_prefetch_handler (Any | None) – Optional getter created by
make_scalar_prefetch_handlerthat selects this fusion’s scalar prefetch values from the kernel’s scalar prefetch inputs.grid_len (int | None) – Optional number of grid dimensions in the enclosing kernel; see
pull_block_spec.**block_spec_kwargs (Any) –
BlockSpecsfor the keyword kernel outputs**kwargs.
- Returns:
A function taking
(values, *args, **kwargs)(or their abstract types) and returning(kernel_fn, values_block_specs, kwarg_block_specs, out_type, out_block_specs), wherekernel_fn(program_ids, scalar_prefetch, values, *args, **kwargs)evaluatesfon a single block,values_block_specsandkwarg_block_specsare the pulledBlockSpecsforvaluesand**kwargs(pulled specs for positional*argsare omitted because they are already given by*block_specs), andout_typeandout_block_specsare theShapeDtypeStructsand pushedBlockSpecsfor the outputs off.