Utility functions for broadcasting tensor shapes and sharding specs in auto‑parallel.
# Source: https://github.com/hpcaitech/ColossalAI | License: Apache-2.0 | Copyright 2021- HPC-AI Technology Inc. All rights reserved
# Provided via justclaw.it.com; keep this notice with the code.
from enum import Enum, auto
from typing import List
import torch
from torch.fx.node import Node
from colossalai.auto_parallel.tensor_shard.sharding_strategy import (
CommAction,
CommType,
OperationData,
OperationDataType,
)
from colossalai.tensor.comm_spec import CollectiveCommPattern, CommSpec
from colossalai.tensor.sharding_spec import ShardingSpec
__all__ = [
"BroadcastType",
"is_broadcastable",
"get_broadcast_shape",
"recover_sharding_spec_for_broadcast_shape",
"comm_actions_for_oprands",
]
class BroadcastType(Enum):
EQUAL = auto()
PADDING = au
... (truncated -- full source via MCP)
See the full source, get the GitHub permalink, and search for more like it.
Get a free API key