pl.optimizations¶
pl.at(..., optimizations=[...]) 列表接受的那些优化项 —— pl.split、pl.cross_core_slot 等。见运行时开销。
Optimization config entries for pl.at(..., optimizations=[...]).
Each entry is an orthogonal optimization hint applied to the enclosing scope.
The entries can be combined freely in the optimizations= list.
Available entries
-
pl.split(mode)— Cross-core data-transfer split hint, consumed by theExpandMixedKernelpass. Lowers the scope toInCorewithsplit_=mode::with pl.at(level=pl.Level.CORE_GROUP, optimizations=[pl.split(pl.SplitMode.UP_DOWN)]): ...
-
pl.cross_core_slot(slot_num=N)— Slot count (ring depth) for the automatic cross-core pipe. Orthogonal to splitting; combine freely::with pl.at(level=pl.Level.CORE_GROUP, optimizations=[pl.split(pl.SplitMode.UP_DOWN), pl.cross_core_slot(slot_num=4)]): ...
CrossCoreSlot
dataclass
¶
Bases: Optimization
Slot count (ring depth) for the automatic cross-core pipe.
Orthogonal to splitting — it sizes a data channel, it does not partition
work. Sets the slot_num scope attr, which OutlineIncoreScopes
propagates to the outlined function and ExpandMixedKernel reads to size
both the reserved buffer (slot_size * slot_num) and the emitted
initialize_pipe slot_num attribute, in whichever directions the
scope actually uses (cube→vector, vector→cube, or both).
Omitting the entry keeps the default depth of 2 per live direction — enough to double-buffer the handoff while leaving on-chip room for the tiles. The value is ignored when the outlined scope ends up with no cross-core ops.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
slot_num
|
int
|
Ring depth. Must be a positive integer. |
required |
slot_num
instance-attribute
¶
Optimization
¶
Base class for pl.at(..., optimizations=[...]) entries.
Split
dataclass
¶
Bases: Optimization
Cross-core data-transfer split hint.
Sets ScopeStmt::split_ on the enclosing pl.at scope; that metadata
is consumed by the ExpandMixedKernel pass via the outlined function's
SplitMode. optimizations=[pl.split(mode)] lowers the scope to
ScopeKind::InCore with the split metadata attached.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mode
|
SplitMode
|
Split mode ( |
required |
slot_num
|
int | None
|
Deprecated — use |
None
|
cross_core_slot(*, slot_num)
¶
Create a CrossCoreSlot optimization entry.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
slot_num
|
int
|
Cross-core pipe slot count (ring depth). Must be positive. |
required |
Returns:
| Type | Description |
|---|---|
CrossCoreSlot
|
|
Raises:
| Type | Description |
|---|---|
ValueError
|
If |
Examples:
split(mode, *, slot_num=None)
¶
Create a Split optimization entry.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mode
|
SplitMode
|
Split mode. May be |
required |
slot_num
|
int | None
|
Deprecated — use |
None
|
Returns:
| Type | Description |
|---|---|
Split
|
|
Raises:
| Type | Description |
|---|---|
ValueError
|
If |