!5894 enhance ops API comment part3

Merge pull request !5894 from Simson/push-to-opensource
pull/5894/MERGE
mindspore-ci-bot 5 years ago committed by Gitee
commit 76e544fab6

@ -111,14 +111,14 @@ class Conv2d(_Conv):
2D convolution layer. 2D convolution layer.
Applies a 2D convolution over an input tensor which is typically of shape :math:`(N, C_{in}, H_{in}, W_{in})`, Applies a 2D convolution over an input tensor which is typically of shape :math:`(N, C_{in}, H_{in}, W_{in})`,
where :math:`N` is batch size and :math:`C_{in}` is channel number. For each batch of shape where :math:`N` is batch size, :math:`C_{in}` is channel number, and :math:`H_{in}, W_{in})` are height and width.
:math:`(C_{in}, H_{in}, W_{in})`, the formula is defined as: For each batch of shape :math:`(C_{in}, H_{in}, W_{in})`, the formula is defined as:
.. math:: .. math::
out_j = \sum_{i=0}^{C_{in} - 1} ccor(W_{ij}, X_i) + b_j, out_j = \sum_{i=0}^{C_{in} - 1} ccor(W_{ij}, X_i) + b_j,
where :math:`ccor` is the cross correlation operator, :math:`C_{in}` is the input channel number, :math:`j` ranges where :math:`ccor` is the cross-correlation operator, :math:`C_{in}` is the input channel number, :math:`j` ranges
from :math:`0` to :math:`C_{out} - 1`, :math:`W_{ij}` corresponds to the :math:`i`-th channel of the :math:`j`-th from :math:`0` to :math:`C_{out} - 1`, :math:`W_{ij}` corresponds to the :math:`i`-th channel of the :math:`j`-th
filter and :math:`out_{j}` corresponds to the :math:`j`-th channel of the output. :math:`W_{ij}` is a slice filter and :math:`out_{j}` corresponds to the :math:`j`-th channel of the output. :math:`W_{ij}` is a slice
of kernel and it has shape :math:`(\text{ks_h}, \text{ks_w})`, where :math:`\text{ks_h}` and of kernel and it has shape :math:`(\text{ks_h}, \text{ks_w})`, where :math:`\text{ks_h}` and
@ -162,8 +162,8 @@ class Conv2d(_Conv):
Tensor borders. `padding` should be greater than or equal to 0. Tensor borders. `padding` should be greater than or equal to 0.
padding (Union[int, tuple[int]]): Implicit paddings on both sides of the input. If `padding` is one integer, padding (Union[int, tuple[int]]): Implicit paddings on both sides of the input. If `padding` is one integer,
the padding of top, bottom, left and right is the same, equal to padding. If `padding` is a tuple the paddings of top, bottom, left and right are the same, equal to padding. If `padding` is a tuple
with four integers, the padding of top, bottom, left and right will be equal to padding[0], with four integers, the paddings of top, bottom, left and right will be equal to padding[0],
padding[1], padding[2], and padding[3] accordingly. Default: 0. padding[1], padding[2], and padding[3] accordingly. Default: 0.
dilation (Union[int, tuple[int]]): The data type is int or a tuple of 2 integers. Specifies the dilation rate dilation (Union[int, tuple[int]]): The data type is int or a tuple of 2 integers. Specifies the dilation rate
to use for dilated convolution. If set to be :math:`k > 1`, there will to use for dilated convolution. If set to be :math:`k > 1`, there will
@ -472,8 +472,8 @@ class Conv2dTranspose(_Conv):
- valid: Adopted the way of discarding. - valid: Adopted the way of discarding.
padding (Union[int, tuple[int]]): Implicit paddings on both sides of the input. If `padding` is one integer, padding (Union[int, tuple[int]]): Implicit paddings on both sides of the input. If `padding` is one integer,
the padding of top, bottom, left and right is the same, equal to padding. If `padding` is a tuple the paddings of top, bottom, left and right are the same, equal to padding. If `padding` is a tuple
with four integers, the padding of top, bottom, left and right will be equal to padding[0], with four integers, the paddings of top, bottom, left and right will be equal to padding[0],
padding[1], padding[2], and padding[3] accordingly. Default: 0. padding[1], padding[2], and padding[3] accordingly. Default: 0.
dilation (Union[int, tuple[int]]): The data type is int or a tuple of 2 integers. Specifies the dilation rate dilation (Union[int, tuple[int]]): The data type is int or a tuple of 2 integers. Specifies the dilation rate
to use for dilated convolution. If set to be :math:`k > 1`, there will to use for dilated convolution. If set to be :math:`k > 1`, there will
@ -856,8 +856,8 @@ class DepthwiseConv2d(Cell):
Tensor borders. `padding` should be greater than or equal to 0. Tensor borders. `padding` should be greater than or equal to 0.
padding (Union[int, tuple[int]]): Implicit paddings on both sides of the input. If `padding` is one integer, padding (Union[int, tuple[int]]): Implicit paddings on both sides of the input. If `padding` is one integer,
the padding of top, bottom, left and right is the same, equal to padding. If `padding` is a tuple the paddings of top, bottom, left and right are the same, equal to padding. If `padding` is a tuple
with four integers, the padding of top, bottom, left and right will be equal to padding[0], with four integers, the paddings of top, bottom, left and right will be equal to padding[0],
padding[1], padding[2], and padding[3] accordingly. Default: 0. padding[1], padding[2], and padding[3] accordingly. Default: 0.
dilation (Union[int, tuple[int]]): The data type is int or a tuple of 2 integers. Specifies the dilation rate dilation (Union[int, tuple[int]]): The data type is int or a tuple of 2 integers. Specifies the dilation rate
to use for dilated convolution. If set to be :math:`k > 1`, there will to use for dilated convolution. If set to be :math:`k > 1`, there will

@ -284,12 +284,12 @@ class Conv2DBackpropFilter(PrimitiveWithInfer):
Args: Args:
out_channel (int): The dimensionality of the output space. out_channel (int): The dimensionality of the output space.
kernel_size (Union[int, tuple[int]]): The size of the convolution window. kernel_size (Union[int, tuple[int]]): The size of the convolution window.
pad_mode (str): "valid", "same", "pad" the mode to fill padding. Default: "valid". pad_mode (str): Modes to fill padding. It could be "valid", "same", or "pad". Default: "valid".
pad (int): The pad value to fill. Default: 0. pad (int): The pad value to be filled. Default: 0.
mode (int): 0 Math convolutiuon, 1 cross-correlation convolution , mode (int): Modes for different convolutions. 0 Math convolutiuon, 1 cross-correlation convolution ,
2 deconvolution, 3 depthwise convolution. Default: 1. 2 deconvolution, 3 depthwise convolution. Default: 1.
stride (tuple): The stride to apply conv filter. Default: (1, 1). stride (tuple): The stride to be applied to the convolution filter. Default: (1, 1).
dilation (tuple): Specifies the dilation rate to use for dilated convolution. Default: (1, 1, 1, 1). dilation (tuple): Specifies the dilation rate to be used for the dilated convolution. Default: (1, 1, 1, 1).
group (int): Splits input into groups. Default: 1. group (int): Splits input into groups. Default: 1.
Returns: Returns:
@ -349,12 +349,12 @@ class DepthwiseConv2dNativeBackpropFilter(PrimitiveWithInfer):
Args: Args:
channel_multiplier (int): The multipiler for the original output conv. channel_multiplier (int): The multipiler for the original output conv.
kernel_size (int or tuple): The size of the conv kernel. kernel_size (int or tuple): The size of the conv kernel.
mode (int): 0 Math convolutiuon, 1 cross-correlation convolution, mode (int): Modes for different convolutions. 0 Math convolutiuon, 1 cross-correlation convolution,
2 deconvolution,3 depthwise convolution. Defaul: 3. 2 deconvolution,3 depthwise convolution. Defaul: 3.
pad_mode (str): The mode to fill padding which can be: "valid", "same" or "pad". Default: "valid". pad_mode (str): The mode to fill padding which can be: "valid", "same" or "pad". Default: "valid".
pad (int): The pad value to fill. Default: 0. pad (int): The pad value to be filled. Default: 0.
pads (tuple): The pad list like (top, bottom, left, right). Default: (0, 0, 0, 0). pads (tuple): The pad list like (top, bottom, left, right). Default: (0, 0, 0, 0).
stride (int): The stride to apply conv filter. Default: 1. stride (int): The stride to be applied to the convolution filter. Default: 1.
dilation (int): Specifies the space to use between kernel elements. Default: 1. dilation (int): Specifies the space to use between kernel elements. Default: 1.
group (int): Splits input into groups. Default: 1. group (int): Splits input into groups. Default: 1.
@ -410,12 +410,12 @@ class DepthwiseConv2dNativeBackpropInput(PrimitiveWithInfer):
Args: Args:
channel_multiplier (int): The multipiler for the original output conv. channel_multiplier (int): The multipiler for the original output conv.
kernel_size (int or tuple): The size of the conv kernel. kernel_size (int or tuple): The size of the conv kernel.
mode (int): 0 Math convolutiuon, 1 cross-correlation convolution , mode (int): Modes for different convolutions. 0 Math convolutiuon, 1 cross-correlation convolution ,
2 deconvolution,3 depthwise convolution. Default: 3. 2 deconvolution,3 depthwise convolution. Default: 3.
pad_mode (str): "valid", "same", "pad" the mode to fill padding. Default: "valid". pad_mode (str): Modes to fill padding. It could be "valid", "same", or "pad". Default: "valid".
pad (int): the pad value to fill. Default: 0. pad (int): The pad value to be filled. Default: 0.
pads (tuple): The pad list like (top, bottom, left, right). Default: (0, 0, 0, 0). pads (tuple): The pad list like (top, bottom, left, right). Default: (0, 0, 0, 0).
stride (int): the stride to apply conv filter. Default: 1. stride (int): The stride to be applied to the convolution filter. Default: 1.
dilation (int): Specifies the space to use between kernel elements. Default: 1. dilation (int): Specifies the space to use between kernel elements. Default: 1.
group (int): Splits input into groups. Default: 1. group (int): Splits input into groups. Default: 1.

@ -292,7 +292,7 @@ class IsSubClass(PrimitiveWithInfer):
Check whether one type is sub class of another type. Check whether one type is sub class of another type.
Inputs: Inputs:
- **sub_type** (mindspore.dtype) - The type to be check. Only constant value is allowed. - **sub_type** (mindspore.dtype) - The type to be checked. Only constant value is allowed.
- **type_** (mindspore.dtype) - The target type. Only constant value is allowed. - **type_** (mindspore.dtype) - The target type. Only constant value is allowed.
Outputs: Outputs:
@ -326,7 +326,7 @@ class IsInstance(PrimitiveWithInfer):
Check whether an object is an instance of a target type. Check whether an object is an instance of a target type.
Inputs: Inputs:
- **inst** (Any Object) - The instance to be check. Only constant value is allowed. - **inst** (Any Object) - The instance to be checked. Only constant value is allowed.
- **type_** (mindspore.dtype) - The target type. Only constant value is allowed. - **type_** (mindspore.dtype) - The target type. Only constant value is allowed.
Outputs: Outputs:
@ -1100,7 +1100,7 @@ class InvertPermutation(PrimitiveWithInfer):
Only constant value is allowed. Only constant value is allowed.
Outputs: Outputs:
tuple[int]. the lenth is same as input. tuple[int]. It has the same length as the input.
Examples: Examples:
>>> invert = P.InvertPermutation() >>> invert = P.InvertPermutation()
@ -2355,15 +2355,15 @@ class DiagPart(PrimitiveWithInfer):
class Eye(PrimitiveWithInfer): class Eye(PrimitiveWithInfer):
""" """
Creates a tensor with ones on the diagonal and zeros elsewhere. Creates a tensor with ones on the diagonal and zeros the rest.
Inputs: Inputs:
- **n** (int) - Number of rows of returned tensor - **n** (int) - The number of rows of returned tensor
- **m** (int) - Number of columns of returned tensor - **m** (int) - The number of columns of returned tensor
- **t** (mindspore.dtype) - MindSpore's dtype, The data type of the returned tensor. - **t** (mindspore.dtype) - MindSpore's dtype, The data type of the returned tensor.
Outputs: Outputs:
Tensor, a tensor with ones on the diagonal and zeros elsewhere. Tensor, a tensor with ones on the diagonal and the rest of elements are zero.
Examples: Examples:
>>> eye = P.Eye() >>> eye = P.Eye()
@ -3453,8 +3453,8 @@ class InplaceUpdate(PrimitiveWithInfer):
Inputs: Inputs:
- **x** (Tensor) - A tensor which to be inplace updated. It can be one of the following data types: - **x** (Tensor) - A tensor which to be inplace updated. It can be one of the following data types:
float32, float16, int32. float32, float16 and int32.
- **v** (Tensor) - A tensor of the same type as `x`. Same dimension size as `x` except - **v** (Tensor) - A tensor with the same type as `x` and the same dimension size as `x` except
the first dimension, which must be the same as the size of `indices`. the first dimension, which must be the same as the size of `indices`.
Outputs: Outputs:

@ -26,23 +26,24 @@ class ControlDepend(Primitive):
Adds control dependency relation between source and destination operation. Adds control dependency relation between source and destination operation.
In many cases, we need to control the execution order of operations. ControlDepend is designed for this. In many cases, we need to control the execution order of operations. ControlDepend is designed for this.
ControlDepend will indicate the execution engine to run the operations in specific order. ControlDepend ControlDepend will instruct the execution engine to run the operations in a specific order. ControlDepend
tells the engine that the destination operations should depend on the source operation which means the source tells the engine that the destination operations should depend on the source operation which means the source
operations should be executed before the destination. operations should be executed before the destination.
Note: Note:
This operation does not work in `PYNATIVE_MODE`. This operation does not work in `PYNATIVE_MODE`.
Args: Args:
depend_mode (int): Use 0 for normal depend, 1 for depend on operations that used the parameter. Default: 0. depend_mode (int): Use 0 for a normal dependency relation. Use 1 to depends on operations which using Parameter
as its input. Default: 0.
Inputs: Inputs:
- **src** (Any) - The source input. It can be a tuple of operations output or a single operation output. We do - **src** (Any) - The source input. It can be a tuple of operations output or a single operation output. We do
not concern about the input data, but concern about the operation that generates the input data. not concern about the input data, but concern about the operation that generates the input data.
If `depend_mode = 1` is specified and the source input is parameter, we will try to find the operations that If `depend_mode` is 1 and the source input is Parameter, we will try to find the operations that
used the parameter as input. used the parameter as input.
- **dst** (Any) - The destination input. It can be a tuple of operations output or a single operation output. - **dst** (Any) - The destination input. It can be a tuple of operations output or a single operation output.
We do not concern about the input data, but concern about the operation that generates the input data. We do not concern about the input data, but concern about the operation that generates the input data.
If `depend_mode = 1` is specified and the source input is parameter, we will try to find the operations that If `depend_mode` is 1 and the source input is Parameter, we will try to find the operations that
used the parameter as input. used the parameter as input.
Outputs: Outputs:
@ -80,7 +81,7 @@ class GeSwitch(PrimitiveWithInfer):
""" """
Adds control switch to data. Adds control switch to data.
Switch data to flow into false or true branch depend on the condition. If the condition is true, Switch data flows into false or true branch depending on the condition. If the condition is true,
the true branch will be activated, or vise verse. the true branch will be activated, or vise verse.
Inputs: Inputs:

@ -248,14 +248,14 @@ class InsertGradientOf(PrimitiveWithInfer):
class HookBackward(PrimitiveWithInfer): class HookBackward(PrimitiveWithInfer):
""" """
Used as tag to hook gradient in intermediate variables. Note that this function This operation is used as a tag to hook gradient in intermediate variables. Note that this function
is only supported in Pynative Mode. is only supported in Pynative Mode.
Note: Note:
The hook function should be defined like `hook_fn(grad) -> Tensor or None`, The hook function should be defined like `hook_fn(grad) -> Tensor or None`,
which grad is the gradient passed to the primitive and gradient may be where grad is the gradient passed to the primitive and gradient may be
modified and passed to nex primitive. the difference between hook function and modified and passed to next primitive. The difference between a hook function and
callback of InsertGradientOf is that hook function is executed in python callback of InsertGradientOf is that a hook function is executed in the python
environment while callback will be parsed and added to the graph. environment while callback will be parsed and added to the graph.
Args: Args:

@ -29,9 +29,9 @@ class CropAndResize(PrimitiveWithInfer):
In case that the output shape depends on crop_size, the crop_size should be constant. In case that the output shape depends on crop_size, the crop_size should be constant.
Args: Args:
method (str): An optional string specifying the sampling method for resizing. method (str): An optional string that specifies the sampling method for resizing.
It can be either "bilinear" or "nearest" and default to "bilinear" It can be either "bilinear" or "nearest". Default: "bilinear"
extrapolation_value (float): An optional float defaults to 0. Value used for extrapolation, when applicable. extrapolation_value (float): An optional float value used extrapolation, if applicable. Default: 0.
Inputs: Inputs:
- **x** (Tensor) - The input image must be a 4-D tensor of shape [batch, image_height, image_width, depth]. - **x** (Tensor) - The input image must be a 4-D tensor of shape [batch, image_height, image_width, depth].

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

@ -244,7 +244,7 @@ class IOU(PrimitiveWithInfer):
Args: Args:
mode (string): The mode is used to specify the calculation method, mode (string): The mode is used to specify the calculation method,
now support 'iou' (intersection over union) or 'iof' now supporting 'iou' (intersection over union) or 'iof'
(intersection over foreground) mode. Default: 'iou'. (intersection over foreground) mode. Default: 'iou'.
Inputs: Inputs:
@ -350,7 +350,7 @@ class Partial(Primitive):
class Depend(Primitive): class Depend(Primitive):
""" """
Depend is used for process side-effect operations. Depend is used for processing side-effect operations.
Inputs: Inputs:
- **value** (Tensor) - the real value to return for depend operator. - **value** (Tensor) - the real value to return for depend operator.

@ -131,9 +131,9 @@ class Gamma(PrimitiveWithInfer):
Inputs: Inputs:
- **shape** (tuple) - The shape of random tensor to be generated. Only constant value is allowed. - **shape** (tuple) - The shape of random tensor to be generated. Only constant value is allowed.
- **alpha** (Tensor) - The α distribution parameter. - **alpha** (Tensor) - The α distribution parameter.
It is also known as the shape parameter. With float32 data type. It is also known as the shape parameter with float32 data type.
- **beta** (Tensor) - The β distribution parameter. - **beta** (Tensor) - The β distribution parameter.
It is also known as the scale parameter. With float32 data type. It is also known as the scale parameter with float32 data type.
Outputs: Outputs:
Tensor. The shape should be the broadcasted shape of Input "shape" and shapes of alpha and beta. Tensor. The shape should be the broadcasted shape of Input "shape" and shapes of alpha and beta.

@ -130,14 +130,14 @@ def set_algo_parameters(**kwargs):
Set algo parameter config. Set algo parameter config.
Note: Note:
Attribute name is needed. The attribute name is required.
Args: Args:
tensor_slice_align_enable (bool): Whether checking tensor slice shape for MatMul. Default: False tensor_slice_align_enable (bool): Whether to check the shape of tensor slice of MatMul. Default: False
tensor_slice_align_size (int): The minimum tensor slice shape of MatMul, the value must be in [1, 1024]. tensor_slice_align_size (int): The minimum tensor slice shape of MatMul, the value must be in [1, 1024].
Default: 16 Default: 16
fully_use_devices (bool): Whether ONLY generating strategies that fully use all available devices. Default: True fully_use_devices (bool): Whether ONLY generating strategies that fully use all available devices. Default: True
elementwise_op_strategy_follow (bool): Whether the elementwise operator have the same strategies as its elementwise_op_strategy_follow (bool): Whether the elementwise operator has the same strategies as its
subsequent operators. Default: False subsequent operators. Default: False
Raises: Raises:
@ -155,7 +155,7 @@ def get_algo_parameters(attr_key):
Get algo parameter config attributes. Get algo parameter config attributes.
Note: Note:
Return value according to the attribute value. Returns the specified attribute value.
Args: Args:
attr_key (str): The key of the attribute. attr_key (str): The key of the attribute.

Loading…
Cancel
Save