この比較の残りの部分を読み込んでいます。

Shardy Doc Diff

作成日 差分は期限切れになりません
31 削除
864 行
52 追加
846 行
<!-- Autogenerated by mlir-tblgen; don't manually edit -->
<!-- Autogenerated by mlir-tblgen; don't manually edit -->

# 'sdy' Dialect
# 'sdy' Dialect


The Shardy (SDY) dialect defines an axis-based tensor sharding
_The Shardy (SDY) dialect defines an axis-based tensor sharding
representation and additional API components to attach shardings to tensors.
representation and additional API components to attach shardings to tensors._


[TOC]
[TOC]


## Operations
## Operations


### `sdy.all_gather` (sdy::AllGatherOp)
### `sdy.all_gather` (sdy::AllGatherOp)


_Gathers chunks of a tensor along axes_
_Gathers chunks of a tensor along axes_



Syntax:
Syntax:


```
```
operation ::= `sdy.all_gather` $gatheringAxes $tensor `out_sharding````=```$outSharding attr-dict `:` type($result)
operation ::= `sdy.all_gather` $gatheringAxes $tensor `out_sharding````=```$outSharding attr-dict `:` type($result)
```
```


Gathers chunks of a tensor along axes specified in `gatheringAxes`.
Gathers chunks of a tensor along axes specified in `gatheringAxes`.


The `gatheringAxes` is a list of lists of axes. Each inner list specifies
The `gatheringAxes` is a list of lists of axes. Each inner list specifies
the axes along which a separate gather should be performed. The outer list
the axes along which a separate gather should be performed. The outer list
is over the dimensions of the tensor. It will be applied to the sharding of
is over the dimensions of the tensor. It will be applied to the sharding of
the operand (`tensor`) to obtain the sharding of the result (`outSharding`).
the operand (`tensor`) to obtain the sharding of the result (`outSharding`).


Note that `outSharding` is not used to determine the sharding of the result.
Note that `outSharding` is not used to determine the sharding of the result.
Instead, the sharding of the result is determined by the sharding of the
Instead, the sharding of the result is determined by the sharding of the
operand and the `gatheringAxes`, and `outSharding` must match this inferred
operand and the `gatheringAxes`, and `outSharding` must match this inferred
sharding.
sharding.


Example:
Example:
```mlir
```mlir
%1 = stablehlo.tanh(%0) {sdy.sharding = #sdy.sharding_per_value<[<@mesh, [{"a", "b", "c"}, {}, {"d"}\]>]>} : tensor<8x8xf32>
%1 = stablehlo.tanh(%0) {sdy.sharding = #sdy.sharding_per_value<[<@mesh, [{"a", "b", "c"}, {}, {"d"}\]>]>} : tensor<8x8xf32>
%2 = sdy.all_gather gathering_axes=[{"b", "c"}, {}, {"d"}\] %1 to_sharding=<@mesh, [{"a"}, {}, {}\]> : tensor<8x8xf32>
%2 = sdy.all_gather gathering_axes=[{"b", "c"}, {}, {"d"}\] %1 to_sharding=<@mesh, [{"a"}, {}, {}\]> : tensor<8x8xf32>
```
```




Traits: `SameOperandsAndResultType`
Traits: `SameOperandsAndResultType`


Interfaces: `InferTypeOpInterface`
Interfaces: `InferTypeOpInterface`


#### Attributes:
#### Attributes:


<table>
<table>
<tr><th>Attribute</th><th>MLIR Type</th><th>Description</th></tr>
<tr><th>Attribute</th><th>MLIR Type</th><th>Description</th></tr>
<tr><td><code>gatheringAxes</code></td><td>::mlir::sdy::ListOfAxisRefListsAttr</td><td></td></tr>
<tr><td><code>gatheringAxes</code></td><td>::mlir::sdy::ListOfAxisRefListsAttr</td><td></td></tr>
<tr><td><code>outSharding</code></td><td>::mlir::sdy::TensorShardingAttr</td><td>Tensor sharding</td></tr>
<tr><td><code>outSharding</code></td><td>::mlir::sdy::TensorShardingAttr</td><td>Tensor sharding</td></tr>
</table>
</table>


#### Operands:
#### Operands:


| Operand | Description |
| Operand | Description |
| :-----: | ----------- |
| :-----: | ----------- |
| `tensor` | tensor of any type values
| `tensor` | tensor of any type values |


#### Results:
#### Results:


| Result | Description |
| Result | Description |
| :----: | ----------- |
| :----: | ----------- |
| `result` | tensor of any type values
| `result` | tensor of any type values |





### `sdy.constant` (sdy::ConstantOp)
### `sdy.constant` (sdy::ConstantOp)


_Constant operation_
_Constant operation_


Produces an `output` tensor from a constant `value`.
Produces an `output` tensor from a constant `value`.


See:
See:
https://github.com/openxla/stablehlo/blob/main/docs/spec.md#constant
https://github.com/openxla/stablehlo/blob/main/docs/spec.md#constant


NOTE: SDY defines its own constant op that isn't ConstantLike and doesn't
NOTE: SDY defines its own constant op that isn't ConstantLike and doesn't
have a folder, so that we'll be able to duplicate constants without any
have a folder, so that we'll be able to duplicate constants without any
greedy pattern rewriter folding them back into a single constant. In this
greedy pattern rewriter folding them back into a single constant. In this
way, constants can be sharded differently for every use, and no propagation
way, constants can be sharded differently for every use, and no propagation
is done between constants (or constant expressions).
is done between constants (or constant expressions).


Example:
Example:
```mlir
```mlir
%output = sdy.constant dense<[[0.0, 1.0], [2.0, 3.0]]> : tensor<2x2xf32>
%output = sdy.constant dense<[[0.0, 1.0], [2.0, 3.0]]> : tensor<2x2xf32>
```
```


Traits: `AlwaysSpeculatableImplTrait`
Traits: `AlwaysSpeculatableImplTrait`


Interfaces: `ConditionallySpeculatable`, `InferTypeOpInterface`, `NoMemoryEffect (MemoryEffectOpInterface)`
Interfaces: `ConditionallySpeculatable`, `InferTypeOpInterface`, `NoMemoryEffect (MemoryEffectOpInterface)`


Effects: `MemoryEffects::Effect{}`
Effects: `MemoryEffects::Effect{}`


#### Attributes:
#### Attributes:


<table>
<table>
<tr><th>Attribute</th><th>MLIR Type</th><th>Description</th></tr>
<tr><th>Attribute</th><th>MLIR Type</th><th>Description</th></tr>
<tr><td><code>value</code></td><td>::mlir::ElementsAttr</td><td>constant vector/tensor attribute</td></tr>
<tr><td><code>value</code></td><td>::mlir::ElementsAttr</td><td>constant vector/tensor attribute</td></tr>
</table>
</table>