未验证 提交 daebb80a 编写于 作者: L LiYuRio 提交者: GitHub

add doc for tensor dist attr (#55984)

上级 30cefa2d
...@@ -232,6 +232,31 @@ int tensor_properties_set_persistable(TensorObject* self, ...@@ -232,6 +232,31 @@ int tensor_properties_set_persistable(TensorObject* self,
EAGER_CATCH_AND_THROW_RETURN_NEG EAGER_CATCH_AND_THROW_RETURN_NEG
} }
PyDoc_STRVAR(tensor_dist_attr__doc__,
R"DOC(dist_attr
Get dist_attr property from shard tensor.
Returns:
core.TensorDistAttr: the dist attr of shard tensor
Examples:
.. code-block:: python
import paddle
import paddle.distributed as dist
mesh = dist.ProcessMesh([[2, 4, 5], [0, 1, 3]], dim_names=["x", "y"])
dist_attr = dist.DistAttr(mesh=mesh, sharding_specs=['x', 'y'])
a = paddle.to_tensor([[1,2,3],
[5,6,7]])
d_tensor = dist.shard_tensor(a, dist_attr=dist_attr)
print(d_tensor.dist_attr)
)DOC");
PyObject* tensor_properties_get_dist_attr(TensorObject* self, void* closure) { PyObject* tensor_properties_get_dist_attr(TensorObject* self, void* closure) {
EAGER_TRY EAGER_TRY
if (self->tensor.is_dist_tensor()) { if (self->tensor.is_dist_tensor()) {
...@@ -488,7 +513,7 @@ struct PyGetSetDef variable_properties[] = { // NOLINT ...@@ -488,7 +513,7 @@ struct PyGetSetDef variable_properties[] = { // NOLINT
{"dist_attr", {"dist_attr",
(getter)tensor_properties_get_dist_attr, (getter)tensor_properties_get_dist_attr,
nullptr, nullptr,
nullptr, tensor_dist_attr__doc__,
nullptr}, nullptr},
{"_place_str", {"_place_str",
(getter)tensor_properties_get_place_str, (getter)tensor_properties_get_place_str,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册