Document feedback

Question document fragment

When a question document fragment contains a formula, it is displayed as a space.

Submission type
issue

It's a little complicated...

I'd like to ask someone.

PR

Just a small problem.

I can fix it online!

Please select the submission type

Problem type
Specifications and Common Mistakes

- Specifications and Common Mistakes:

- Misspellings or punctuation mistakes,incorrect formulas, abnormal display.

- Incorrect links, empty cells, or wrong formats.

- Chinese characters in English context.

- Minor inconsistencies between the UI and descriptions.

- Low writing fluency that does not affect understanding.

- Incorrect version numbers, including software package names and version numbers on the UI.

Usability

- Usability:

- Incorrect or missing key steps.

- Missing main function descriptions, keyword explanation, necessary prerequisites, or precautions.

- Ambiguous descriptions, unclear reference, or contradictory context.

- Unclear logic, such as missing classifications, items, and steps.

Correctness

- Correctness:

- Technical principles, function descriptions, supported platforms, parameter types, or exceptions inconsistent with that of software implementation.

- Incorrect schematic or architecture diagrams.

- Incorrect commands or command parameters.

- Incorrect code.

- Commands inconsistent with the functions.

- Wrong screenshots.

- Sample code running error, or running results inconsistent with the expectation.

Risk Warnings

- Risk Warnings:

- Lack of risk warnings for operations that may damage the system or important data.

Content Compliance

- Content Compliance:

- Contents that may violate applicable laws and regulations or geo-cultural context-sensitive words and expressions.

- Copyright infringement.

Please select the type of question

Problem description

Describe the bug so that we can quickly locate the problem.

mindspore.ops.div

View Source On Gitee
mindspore.ops.div(input, other, *, rounding_mode=None)[source]

Divide the first input tensor by the second input tensor in floating-point type element-wise.

outi=inputi/otheri

Note

  • The two input tensors must be broadcastable.

  • The two input tensors can not be bool type at the same time,

  • The two input tensors comply with the implicit type conversion rules to make the data types consistent.

Parameters
  • input (Union[Tensor, Number, bool]) – The first input tensor.

  • other (Union[Tensor, Number, bool]) – The second input tensor.

Keyword Arguments

rounding_mode (str, optional) –

Type of rounding applied to the result. Default None . Three types are defined as:

  • None: the same as true division in Python or true_divide in NumPy.

  • "floor": rounds the results of the division down, which is the same as floor division in Python or floor_divide in NumPy.

  • "trunc": rounds the results of the division towards zero, which is the same as C-style integer division.

Returns

Tensor

Supported Platforms:

Ascend GPU CPU

Examples

>>> import mindspore
>>> input = mindspore.tensor([[-0.3711, -1.9353, -0.4605, -0.2917],
...                           [ 0.1815, -1.0111,  0.9805, -1.5923],
...                           [ 0.1062,  1.4581,  0.7759, -1.2344],
...                           [-0.1830, -0.0313,  1.1908, -1.4757]])
>>> other = mindspore.tensor([ 0.8032,  0.2930, -0.8113, -0.2308])
>>> output = mindspore.ops.div(input, other)
>>> print(output)
[[-0.4620269  -6.605119    0.5676076   1.2638649 ]
 [ 0.22597112 -3.4508533  -1.2085541   6.899047  ]
 [ 0.13222112  4.97645    -0.95636636  5.348354  ]
 [-0.22783864 -0.10682594 -1.4677677   6.3938475 ]]
>>> output = mindspore.ops.div(input, other, rounding_mode='floor')
>>> print(output)
[[-1. -7.  0.  1.]
 [ 0. -4. -2.  6.]
 [ 0.  4. -1.  5.]
 [-1. -1. -2.  6.]]