Documentation
¶
Overview ¶
Package distributed defines a dtensor.Tensor, a logical tensor distributed across multiple devices organized as a distributed.DeviceMesh.
Index ¶
- type Tensor
- func (dt *Tensor) Clone() (*Tensor, error)
- func (dt *Tensor) DType() dtypes.DType
- func (dt *Tensor) Finalize() error
- func (dt *Tensor) FinalizeAll() error
- func (dt *Tensor) Merge() (*tensors.Tensor, error)
- func (dt *Tensor) Mesh() *distributed.DeviceMesh
- func (dt *Tensor) NumShards() int
- func (dt *Tensor) Ok() bool
- func (dt *Tensor) Shape() shapes.Shape
- func (dt *Tensor) ShardShape() shapes.Shape
- func (dt *Tensor) ShardingSpec() *distributed.ShardingSpec
- func (dt *Tensor) Shards() []*tensors.Tensor
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Tensor ¶
type Tensor struct {
// contains filtered or unexported fields
}
Tensor is a logical tensor meant to be distributed across multiple devices (organized as a distributed.DeviceMesh). It is a container for its shards (concrete tensors.Tensor), one per device. The shards may or may not be stored on a backend (or local on the host), it's up to the caller to manage the shards storage.
The logical distributed Tensor can be either replicated or sharded at each axis. When an axis is sharded, it is shared over a DeviceMesh axis, and the distributed tensor is equally split across that configured mesh axis. When an axis is replicated, the tensor is replicated across all mesh axes.
The idea is that when executing a distributed computation, each device will receive the corresponding tensor shard, replicated and/or sharded, according to the specification.
func NewTensor ¶
func NewTensor(spec *distributed.ShardingSpec, shards []*tensors.Tensor) (*Tensor, error)
NewTensor creates a new distributed Tensor. It assumes the provided shards are already on their respective devices.
func ShardTensor ¶
func ShardTensor(spec *distributed.ShardingSpec, t *tensors.Tensor) (*Tensor, error)
ShardTensor splits a tensor into individual shards. This all happen on the host, and the shards of the returned dtensor.Tensor are local tensors.
func (*Tensor) Clone ¶
Clone creates a copy of the distributed Tensor. It clones each shard on the device it currently resides.
func (*Tensor) Finalize ¶
Finalize releases the memory associated with the distributed tensor. It calls FinalizeAll on each of the shards. It is safe to call Finalize on an already finalized tensor.
func (*Tensor) FinalizeAll ¶
FinalizeAll is an alias to Finalize.
func (*Tensor) Mesh ¶
func (dt *Tensor) Mesh() *distributed.DeviceMesh
Mesh redt.logicaturns the distributed.DeviceMesh for this tensor.
func (*Tensor) Ok ¶
Ok returns whether the distributed tensor is in a valid state -- and hasn't been finalized.
func (*Tensor) ShardShape ¶
ShardShape returns the shape of the individual shards.
func (*Tensor) ShardingSpec ¶
func (dt *Tensor) ShardingSpec() *distributed.ShardingSpec
distributed.ShardingSpec returns the sharding specification for this tensor.