mlx.core.issubdtype#
- issubdtype(arg1: Dtype | DtypeCategory, arg2: Dtype | DtypeCategory) bool#
检查一个
Dtype或DtypeCategory是否是另一个的子类型。- 参数:
arg1 (联合类型[Dtype | DtypeCategory]) – 第一个 dtype 或类别。
arg2 (联合类型[Dtype | DtypeCategory]) – 第二个 dtype 或类别。
返回值:
一个布尔值,指示第一个输入是否是第二个输入的子类型。
- 返回类型:
bool
- 示例
但两者都是 floating 的子类型
>>> ints = mx.array([1, 2, 3], dtype=mx.int32) >>> mx.issubdtype(ints.dtype, mx.integer) True >>> mx.issubdtype(ints.dtype, mx.floating) False
>>> floats = mx.array([1, 2, 3], dtype=mx.float32) >>> mx.issubdtype(floats.dtype, mx.integer) False >>> mx.issubdtype(floats.dtype, mx.floating) True
为了方便,也允许使用 dtype-like 对象
>>> mx.issubdtype(mx.float64, mx.float32) False >>> mx.issubdtype(mx.float32, mx.float64) False
>>> mx.issubdtype(mx.float64, mx.floating) True >>> mx.issubdtype(mx.float32, mx.floating) True
目录
>>> mx.issubdtype(mx.float32, mx.inexact) True >>> mx.issubdtype(mx.signedinteger, mx.floating) False