tenzr::ShardingSpec¶
#include <sharding.h>
Public Functions¶
| Name | |
|---|---|
| ShardingSpec() | |
| ShardingSpec(const NamedSharding & ns) | |
| ShardingType | type() const The sharding kind. |
| bool | IsReplicated() const Whether the spec is replicated. |
| bool | IsTiled() const Whether the spec is tiled. |
| const std::vector< int64_t > & | MeshShape() const The device mesh shape. |
| const std::vector< int > & | DimToAxis() const Mapping from tensor dimension to mesh axis. |
| std::string | ToString() const Human-readable description. |
| std::string | ToShardingAttribute() const Lower to a StableHLO/Shardy sharding attribute string. |
| ShardingSpec | Replicated() A replicated (no partitioning) spec. |
| ShardingSpec | Tiled(std::vector< int64_t > mesh_shape, std::vector< int > tensor_dim_to_mesh_axis) A tiled spec with mesh_shape and tensor-to-mesh axis mapping tensor_dim_to_mesh_axis. |
Detailed Description¶
Partitioning of an array across devices, either replicated or tiled over a device mesh.
Public Functions Documentation¶
function ShardingSpec¶
function ShardingSpec¶
Parameters:
- ns Named sharding to translate.
Build a ShardingSpec from a NamedSharding, marking it tiled when any tensor dimension is partitioned.
function type¶
The sharding kind.
function IsReplicated¶
Whether the spec is replicated.
function IsTiled¶
Whether the spec is tiled.
function MeshShape¶
The device mesh shape.
function DimToAxis¶
Mapping from tensor dimension to mesh axis.
function ToString¶
Human-readable description.
Return: Textual description of the sharding.
Render the sharding spec as a human-readable string.
function ToShardingAttribute¶
Lower to a StableHLO/Shardy sharding attribute string.
Return: Sharding attribute such as {replicated} or {devices=[...]}.
Emit the XLA sharding attribute string for this spec.
function Replicated¶
A replicated (no partitioning) spec.
Return: A Replicated spec.
Create a fully replicated sharding spec.
function Tiled¶
static ShardingSpec Tiled(
std::vector< int64_t > mesh_shape,
std::vector< int > tensor_dim_to_mesh_axis
)
A tiled spec with mesh_shape and tensor-to-mesh axis mapping tensor_dim_to_mesh_axis.
Parameters:
- mesh_shape Dimensions of the device mesh.
- tensor_dim_to_mesh_axis Mesh axis assigned to each tensor dimension; -1 for replicated.
Return: A Tiled spec.
Create a tiled sharding spec from a mesh shape and tensor-dim to mesh-axis mapping.