@@ -13,85 +13,85 @@ def run(f):
13
13
# CHECK-LABEL: TEST: testEncodingAttr1D
14
14
@run
15
15
def testEncodingAttr1D ():
16
- with Context () as ctx :
17
- parsed = Attribute .parse (
18
- "#sparse_tensor.encoding<{"
19
- " map = (d0) -> (d0 : compressed),"
20
- " posWidth = 16,"
21
- " crdWidth = 32"
22
- "}>"
23
- )
24
- # CHECK: #sparse_tensor.encoding<{ map = (d0) -> (d0 : compressed), posWidth = 16, crdWidth = 32 }>
25
- print (parsed )
26
-
27
- casted = st .EncodingAttr (parsed )
28
- # CHECK: equal: True
29
- print (f"equal: { casted == parsed } " )
30
-
31
- # CHECK: lvl_types: [<LevelType.compressed: 131072>]
32
- print (f"lvl_types: { casted .lvl_types } " )
33
- # CHECK: dim_to_lvl: (d0) -> (d0)
34
- print (f"dim_to_lvl: { casted .dim_to_lvl } " )
35
- # CHECK: lvl_to_dim: (d0) -> (d0)
36
- print (f"lvl_to_dim: { casted .lvl_to_dim } " )
37
- # CHECK: pos_width: 16
38
- print (f"pos_width: { casted .pos_width } " )
39
- # CHECK: crd_width: 32
40
- print (f"crd_width: { casted .crd_width } " )
41
-
42
- created = st .EncodingAttr .get (casted .lvl_types , None , None , 0 , 0 )
43
- # CHECK: #sparse_tensor.encoding<{ map = (d0) -> (d0 : compressed) }>
44
- print (created )
45
- # CHECK: created_equal: False
46
- print (f"created_equal: { created == casted } " )
47
-
48
- # Verify that the factory creates an instance of the proper type.
49
- # CHECK: is_proper_instance: True
50
- print (f"is_proper_instance: { isinstance (created , st .EncodingAttr )} " )
51
- # CHECK: created_pos_width: 0
52
- print (f"created_pos_width: { created .pos_width } " )
16
+ with Context () as ctx :
17
+ parsed = Attribute .parse (
18
+ "#sparse_tensor.encoding<{"
19
+ " map = (d0) -> (d0 : compressed),"
20
+ " posWidth = 16,"
21
+ " crdWidth = 32"
22
+ "}>"
23
+ )
24
+ # CHECK: #sparse_tensor.encoding<{ map = (d0) -> (d0 : compressed), posWidth = 16, crdWidth = 32 }>
25
+ print (parsed )
26
+
27
+ casted = st .EncodingAttr (parsed )
28
+ # CHECK: equal: True
29
+ print (f"equal: { casted == parsed } " )
30
+
31
+ # CHECK: lvl_types: [<LevelType.compressed: 131072>]
32
+ print (f"lvl_types: { casted .lvl_types } " )
33
+ # CHECK: dim_to_lvl: (d0) -> (d0)
34
+ print (f"dim_to_lvl: { casted .dim_to_lvl } " )
35
+ # CHECK: lvl_to_dim: (d0) -> (d0)
36
+ print (f"lvl_to_dim: { casted .lvl_to_dim } " )
37
+ # CHECK: pos_width: 16
38
+ print (f"pos_width: { casted .pos_width } " )
39
+ # CHECK: crd_width: 32
40
+ print (f"crd_width: { casted .crd_width } " )
41
+
42
+ created = st .EncodingAttr .get (casted .lvl_types , None , None , 0 , 0 )
43
+ # CHECK: #sparse_tensor.encoding<{ map = (d0) -> (d0 : compressed) }>
44
+ print (created )
45
+ # CHECK: created_equal: False
46
+ print (f"created_equal: { created == casted } " )
47
+
48
+ # Verify that the factory creates an instance of the proper type.
49
+ # CHECK: is_proper_instance: True
50
+ print (f"is_proper_instance: { isinstance (created , st .EncodingAttr )} " )
51
+ # CHECK: created_pos_width: 0
52
+ print (f"created_pos_width: { created .pos_width } " )
53
53
54
54
55
55
# CHECK-LABEL: TEST: testEncodingAttr2D
56
56
@run
57
57
def testEncodingAttr2D ():
58
- with Context () as ctx :
59
- parsed = Attribute .parse (
60
- "#sparse_tensor.encoding<{"
61
- " map = (d0, d1) -> (d1 : dense, d0 : compressed),"
62
- " posWidth = 8,"
63
- " crdWidth = 32"
64
- "}>"
65
- )
66
- # CHECK: #sparse_tensor.encoding<{ map = (d0, d1) -> (d1 : dense, d0 : compressed), posWidth = 8, crdWidth = 32 }>
67
- print (parsed )
68
-
69
- casted = st .EncodingAttr (parsed )
70
- # CHECK: equal: True
71
- print (f"equal: { casted == parsed } " )
72
-
73
- # CHECK: lvl_types: [<LevelType.dense: 65536>, <LevelType.compressed: 131072>]
74
- print (f"lvl_types: { casted .lvl_types } " )
75
- # CHECK: dim_to_lvl: (d0, d1) -> (d1, d0)
76
- print (f"dim_to_lvl: { casted .dim_to_lvl } " )
77
- # CHECK: lvl_to_dim: (d0, d1) -> (d1, d0)
78
- print (f"lvl_to_dim: { casted .lvl_to_dim } " )
79
- # CHECK: pos_width: 8
80
- print (f"pos_width: { casted .pos_width } " )
81
- # CHECK: crd_width: 32
82
- print (f"crd_width: { casted .crd_width } " )
83
-
84
- created = st .EncodingAttr .get (
85
- casted .lvl_types ,
86
- casted .dim_to_lvl ,
87
- casted .lvl_to_dim ,
88
- 8 ,
89
- 32 ,
90
- )
91
- # CHECK: #sparse_tensor.encoding<{ map = (d0, d1) -> (d1 : dense, d0 : compressed), posWidth = 8, crdWidth = 32 }>
92
- print (created )
93
- # CHECK: created_equal: True
94
- print (f"created_equal: { created == casted } " )
58
+ with Context () as ctx :
59
+ parsed = Attribute .parse (
60
+ "#sparse_tensor.encoding<{"
61
+ " map = (d0, d1) -> (d1 : dense, d0 : compressed),"
62
+ " posWidth = 8,"
63
+ " crdWidth = 32"
64
+ "}>"
65
+ )
66
+ # CHECK: #sparse_tensor.encoding<{ map = (d0, d1) -> (d1 : dense, d0 : compressed), posWidth = 8, crdWidth = 32 }>
67
+ print (parsed )
68
+
69
+ casted = st .EncodingAttr (parsed )
70
+ # CHECK: equal: True
71
+ print (f"equal: { casted == parsed } " )
72
+
73
+ # CHECK: lvl_types: [<LevelType.dense: 65536>, <LevelType.compressed: 131072>]
74
+ print (f"lvl_types: { casted .lvl_types } " )
75
+ # CHECK: dim_to_lvl: (d0, d1) -> (d1, d0)
76
+ print (f"dim_to_lvl: { casted .dim_to_lvl } " )
77
+ # CHECK: lvl_to_dim: (d0, d1) -> (d1, d0)
78
+ print (f"lvl_to_dim: { casted .lvl_to_dim } " )
79
+ # CHECK: pos_width: 8
80
+ print (f"pos_width: { casted .pos_width } " )
81
+ # CHECK: crd_width: 32
82
+ print (f"crd_width: { casted .crd_width } " )
83
+
84
+ created = st .EncodingAttr .get (
85
+ casted .lvl_types ,
86
+ casted .dim_to_lvl ,
87
+ casted .lvl_to_dim ,
88
+ 8 ,
89
+ 32 ,
90
+ )
91
+ # CHECK: #sparse_tensor.encoding<{ map = (d0, d1) -> (d1 : dense, d0 : compressed), posWidth = 8, crdWidth = 32 }>
92
+ print (created )
93
+ # CHECK: created_equal: True
94
+ print (f"created_equal: { created == casted } " )
95
95
96
96
97
97
# CHECK-LABEL: TEST: testEncodingAttrOnTensorType
0 commit comments