Merge pull request !20200 from lianliguang/code_docs_primitive
This commit is contained in:
i-robot 2021-07-13 12:51:19 +00:00 committed by Gitee
commit d0dae7bb94
2 changed files with 40 additions and 39 deletions

View File

@ -568,7 +568,7 @@ class TBERegOp(RegOp):
class DataType: class DataType:
""" r"""
Ascend ops various combinations of dtype and format. Ascend ops various combinations of dtype and format.
The current list below may be incomplete. The current list below may be incomplete.
@ -577,6 +577,7 @@ class DataType:
current support: current support:
.. code-block:: .. code-block::
None_None = ("", "") None_None = ("", "")
None_Default = ("", "DefaultFormat") None_Default = ("", "DefaultFormat")
BOOL_None = ("bool", "") BOOL_None = ("bool", "")

View File

@ -100,7 +100,7 @@ class Primitive(Primitive_):
name (str): Attribute Name. name (str): Attribute Name.
value (Any): Attribute value. value (Any): Attribute value.
Example: Examples:
>>> import mindspore.ops as P >>> import mindspore.ops as P
>>> a = P.Add() >>> a = P.Add()
>>> a = a.add_prim_attr("attr",1) >>> a = a.add_prim_attr("attr",1)
@ -119,7 +119,7 @@ class Primitive(Primitive_):
Args: Args:
name (str): Attribute Name. name (str): Attribute Name.
Example: Examples:
>>> import mindspore.ops as P >>> import mindspore.ops as P
>>> a = P.Add() >>> a = P.Add()
>>> a = a.add_prim_attr("attr",1) >>> a = a.add_prim_attr("attr",1)
@ -142,7 +142,7 @@ class Primitive(Primitive_):
In other parallel modes, please set it to be 0. In other parallel modes, please set it to be 0.
Args: Args:
stage (int): The stage id for the current operation. stage (int): The stage id for the current operation.
Example: Examples:
>>> from mindspore.ops import operations as P >>> from mindspore.ops import operations as P
>>> add = P.Add() >>> add = P.Add()
>>> print(add.set_stage(0)) >>> print(add.set_stage(0))
@ -161,7 +161,7 @@ class Primitive(Primitive_):
Args: Args:
strategy (tuple): Strategy describes the distributed parallel mode of the current primitive. strategy (tuple): Strategy describes the distributed parallel mode of the current primitive.
Example: Examples:
>>> from mindspore.ops import operations as P >>> from mindspore.ops import operations as P
>>> add = P.Add() >>> add = P.Add()
>>> print(add.shard(((1, 1), (1, 1)))) >>> print(add.shard(((1, 1), (1, 1))))
@ -189,7 +189,7 @@ class Primitive(Primitive_):
Args: Args:
instance_name (str): Instance name of primitive operator set by user. instance_name (str): Instance name of primitive operator set by user.
Example: Examples:
>>> import mindspore.ops as P >>> import mindspore.ops as P
>>> a = P.Add() >>> a = P.Add()
>>> a.set_prim_instance_name("add") >>> a.set_prim_instance_name("add")
@ -269,7 +269,7 @@ class Primitive(Primitive_):
Args: Args:
inputs (list[str]): list of inputs names. inputs (list[str]): list of inputs names.
outputs (list[str]): list of outputs names. outputs (list[str]): list of outputs names.
Example: Examples:
>>> import mindspore.ops as P >>> import mindspore.ops as P
>>> a = P.Add() >>> a = P.Add()
>>> a.init_prim_io_names(["x","y"],["sum"]) >>> a.init_prim_io_names(["x","y"],["sum"])
@ -301,7 +301,7 @@ class Primitive(Primitive_):
Args: Args:
mode (bool): Specifies whether the primitive is recomputed. Default: True. mode (bool): Specifies whether the primitive is recomputed. Default: True.
Example: Examples:
>>> import mindspore.ops as P >>> import mindspore.ops as P
>>> a = P.Add() >>> a = P.Add()
>>> a = a.recompute() >>> a = a.recompute()