mindspore.dtype

Data Type

  • class mindspore.dtype

The actual path of dtype is /mindspore/common/dtype.py.Run the following command to import the package:

  1. Copyimport mindspore.common.dtype as mstype

or

  1. Copyfrom mindspore import dtype as mstype

Numeric Type

Currently, MindSpore supports Int type, Uint type and Float type.The following table lists the details.


Definition

Description

mindspore.int8 , mindspore.byte

8-bit integer

mindspore.int16 , mindspore.short

16-bit integer

mindspore.int32 , mindspore.intc

32-bit integer

mindspore.int64 , mindspore.intp

64-bit integer

mindspore.uint8 , mindspore.ubyte

unsigned 8-bit integer

mindspore.uint16 , mindspore.ushort

unsigned 16-bit integer

mindspore.uint32 , mindspore.uintc

unsigned 32-bit integer

mindspore.uint64 , mindspore.uintp

unsigned 64-bit integer

mindspore.float16 , mindspore.half

16-bit floating-point number

mindspore.float32 , mindspore.single

32-bit floating-point number

mindspore.float64 , mindspore.double

64-bit floating-point number

Other Type

For other defined types, see the following table.


Type

Description

tensor

MindSpore’s tensor type. Data format uses NCHW.

MetaTensor

A tensor only has data type and shape.

bool

Bool number.

int

Integer scalar.

uint

Unsigned integer scalar.

float

Floating-point scalar.

number

Number, including int , uint , float and bool .

list

List constructed by tensor , such as List[T0,T1,…,Tn] , where the element Ti can be of different types.

tuple

Tuple constructed by tensor , such as Tuple[T0,T1,…,Tn] , where the element Ti can be of different types.

function

Function. Return in two ways, one returns Func directly, the other returns Func(args: List[T0,T1,…,Tn], retval: T) .

type_type

Type of type.

type_none

No matching return type, corresponding to the type(None) in Python.

symbolic_key

The value of a variable managed by embd, which is used as a key of the variable in env_type .

env_type

Used to store the gradient of the free variable of a function, where the key is the symbolic_key of the free variable’s node and the value is the gradient.

Tree Topology

The relationships of the above types are as follows:

  1. Copy└─── mindspore.dtype
  2. ├─── number
  3. ├─── bool_
  4. ├─── int_
  5. ├─── int8, byte
  6. ├─── int16, short
  7. ├─── int32, intc
  8. └─── int64, intp
  9. ├─── uint
  10. ├─── uint8, ubyte
  11. ├─── uint16, ushort
  12. ├─── uint32, uintc
  13. └─── uint64, uintp
  14. └─── float_
  15. ├─── float16
  16. ├─── float32
  17. └─── float64
  18. ├─── tensor
  19. ├─── Array[float32]
  20. └─── ...
  21. ├─── list_
  22. ├─── List[int32,float32]
  23. └─── ...
  24. ├─── tuple_
  25. ├─── Tuple[int32,float32]
  26. └─── ...
  27. ├─── function
  28. ├─── Func
  29. ├─── Func[(int32, float32), int32]
  30. └─── ...
  31. ├─── MetaTensor
  32. ├─── type_type
  33. ├─── type_none
  34. ├─── symbolic_key
  35. └─── env_type