Replicates and converts Tensors in `x` to local DeviceArrays. Args: x: The tensor to replicate. Returns: Replicated tensor.
(x: NestedTensor)
| 656 | ) -> NestedTensor: |
| 657 | """Best-effort activation sharding hint: shards `x` by `partition_spec` if non-None. |
| 658 | |
| 659 | Manual axes (from an enclosing `shard_map`) in `partition_spec` are downgraded to |
| 660 | `PartitionSpec.UNCONSTRAINED`; still-Auto axes apply as usual. Activation sharding is a |
| 661 | hint XLA can override anyway, so silently dropping the Manual portion is safe. For |
| 662 | parameters / state where a wrong axis is a real bug, use `with_sharding_constraint`. |
| 663 | For `shard_map` `in_specs`/`out_specs` (which reject `UNCONSTRAINED`), use |
| 664 | `manual_axes_to_none`. |
| 665 | |
| 666 | When all mesh axes are Manual (no Auto axes remain), `with_sharding_constraint` is |
| 667 | skipped entirely — there's nothing left for the compiler to constrain, and the call |
| 668 | would be a no-op wrapper at best (see `_manual_axes_to_unconstrained`). |
| 669 | |
| 670 | `partition_spec` may be a `PartitionSpec` or a flat sequence of axis entries (wrapped |
no outgoing calls