File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 44class dtype :
55 def __init__ (self , data_type ):
66 """An internal method. Please do not use this directly."""
7-
87 self ._underlying = data_type
98
109 def __repr__ (self ):
@@ -29,9 +28,31 @@ def __repr__(self):
2928 _infinicore .DataType .C128 : "complex128" ,
3029 _infinicore .DataType .BF16 : "bfloat16" ,
3130 }
32-
3331 return f"infinicore.{ repr_map [self ._underlying ]} "
3432
33+ def __eq__ (self , other ):
34+ """
35+ Compare two dtype objects for equality.
36+
37+ Args:
38+ other: The object to compare with
39+
40+ Returns:
41+ bool: True if both objects are dtype instances with the same underlying data type
42+ """
43+ if not isinstance (other , dtype ):
44+ return False
45+ return self ._underlying == other ._underlying
46+
47+ def __hash__ (self ):
48+ """
49+ Return a hash value for the dtype object.
50+
51+ Returns:
52+ int: Hash value based on the underlying data type
53+ """
54+ return hash (self ._underlying )
55+
3556
3657float32 = dtype (_infinicore .DataType .F32 )
3758float = float32
You can’t perform that action at this time.
0 commit comments