Skip to content

Commit 01bbe25

Browse files
python format
1 parent 88e3073 commit 01bbe25

File tree

2 files changed

+74
-75
lines changed
  • mlir
    • include/mlir/Dialect/SparseTensor/IR
    • test/python/dialects/sparse_tensor

2 files changed

+74
-75
lines changed

mlir/include/mlir/Dialect/SparseTensor/IR/Enums.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -310,7 +310,6 @@ constexpr bool isLooseCompressedLT(LevelType lt) {
310310
static_cast<uint64_t>(LevelType::LooseCompressed);
311311
}
312312

313-
314313
/// Check if the `LevelType` needs positions array.
315314
constexpr bool isWithPosLT(LevelType lt) {
316315
return isCompressedLT(lt) || isLooseCompressedLT(lt);

mlir/test/python/dialects/sparse_tensor/dialect.py

Lines changed: 74 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -13,85 +13,85 @@ def run(f):
1313
# CHECK-LABEL: TEST: testEncodingAttr1D
1414
@run
1515
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}")
5353

5454

5555
# CHECK-LABEL: TEST: testEncodingAttr2D
5656
@run
5757
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}")
9595

9696

9797
# CHECK-LABEL: TEST: testEncodingAttrOnTensorType

0 commit comments

Comments
 (0)