ivy.default_dtype(*, dtype=None, item=None, as_native=False)[source]#
  • item (Optional[Union[Array, NativeArray]], default: None) – Number or array for inferring the dtype.

  • dtype (Optional[Union[Dtype, str]], default: None) – The dtype to be returned.

  • as_native (bool, default: False) – Whether to return the dtype as native dtype.

Return type:

Union[Dtype, NativeDtype, str]


Return dtype as native or ivy dtype if provided, else if item is given, return its dtype, otherwise return the global default dtype.


>>> ivy.default_dtype()
>>> ivy.set_default_dtype(ivy.bool)
>>> ivy.default_dtype()
>>> ivy.set_default_dtype(ivy.int16)
>>> ivy.default_dtype()
>>> ivy.set_default_dtype(ivy.float64)
>>> ivy.default_dtype()
>>> ivy.default_dtype(dtype="int32")
>>> ivy.default_dtype(dtype=ivy.float16)
>>> ivy.default_dtype(item=53.234)
>>> ivy.default_dtype(item=[1, 2, 3])
>>> x = ivy.array([5.2, 9.7], dtype="complex128")
>>> ivy.default_dtype(item=x)