Return True iff ``ty`` is ``!cc.measure_handle`` or transitively contains one. The walk stops at callable / function-type boundaries: a callable parameter's signature is a device-side type contract for the body of the callable, not a slot for a handle value.
(ty, _seen=None)
| 46 | |
| 47 | |
| 48 | def containsMeasureHandle(ty, _seen=None): |
| 49 | """Return True iff ``ty`` is ``!cc.measure_handle`` or transitively |
| 50 | contains one. The walk stops at callable / function-type boundaries: a |
| 51 | callable parameter's signature is a device-side type contract for the |
| 52 | body of the callable, not a slot for a handle value. |
| 53 | """ |
| 54 | if _seen is None: |
| 55 | _seen = set() |
| 56 | if ty is None or id(ty) in _seen: |
| 57 | return False |
| 58 | _seen.add(id(ty)) |
| 59 | if cc.MeasureHandleType.isinstance(ty): |
| 60 | return True |
| 61 | if cc.PointerType.isinstance(ty): |
| 62 | return containsMeasureHandle(cc.PointerType.getElementType(ty), _seen) |
| 63 | if cc.ArrayType.isinstance(ty): |
| 64 | return containsMeasureHandle(cc.ArrayType.getElementType(ty), _seen) |
| 65 | if cc.StdvecType.isinstance(ty): |
| 66 | return containsMeasureHandle(cc.StdvecType.getElementType(ty), _seen) |
| 67 | if cc.StructType.isinstance(ty): |
| 68 | return any( |
| 69 | containsMeasureHandle(t, _seen) for t in cc.StructType.getTypes(ty)) |
| 70 | return False |
| 71 | |
| 72 | |
| 73 | def getMLIRContext(): |
no test coverage detected