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.

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.Symbol

class mindspore.Symbol(max=0, min=1, divisor=1, remainder=0, unique=False, **kawgs)[source]

Symbol is a data structure to indicate the symbolic info of shape.

For dynamic shape networks, compared with only setting the unknown dimensions ( None ) in Tensor , providing more symbolic shape info can help the framework better optimize the computation graph, to improve the performance of network execution.

Parameters
  • max (int) – The maximum length of this dimension, which is valid when it's greater than min. Default: 0 .

  • min (int) – The minimum length of this dimension. Default: 1 .

  • divisor (int) – The divisor( d ). When remainder is 0, it means this dimension can be divided by d . Default: 1 .

  • remainder (int) – The remainder( r ) when symbol is represented by dN+r,N1 . Default: 0 .

  • unique (bool) – When the symbol object is used multiple times, if unique is True , the shape items of this symbol are considered to be same length, otherwise only symbol info is shared by multiple dimensions. Default: False .

Outputs:

Symbol.

Raises
  • TypeError – If max, min, divisor, remainder is not an int.

  • TypeError – If unique is not a bool.

  • ValueError – If min is not positive value.

  • ValueError – If divisor is not positive value.

  • ValueError – If remainder is not in the range [0,d) .

Examples

>>> import numpy as np
>>> import mindspore as ms
>>> from mindspore import nn, Tensor, Symbol
>>>
>>> class Net(nn.Cell):
...     def __init__(self):
...         super(Net, self).__init__()
...         self.abs = ms.ops.Abs()
...     def construct(self, x):
...         return self.abs(x)
...
>>> net = Net()
>>> s1 = Symbol(divisor=8, remainder=1)
>>> s2 = Symbol(max=32, unique=True)
>>> dyn_t = Tensor(shape=(None, s1, s1, s2, s2), dtype=ms.float32)
>>> net.set_inputs(dyn_t)
>>> # the shape values of last two dimensions must be equal, because "s2" is set to "unique"
>>> net(Tensor(np.random.randn(1, 9, 17, 32, 32), dtype=ms.float32)).shape
(1, 9, 17, 32, 32)
>>> net(Tensor(np.random.randn(8, 25, 9, 30, 30), dtype=ms.float32)).shape
(8, 25, 9, 30, 30)