brintos

brintos / llvm-project-archived public Read only

0
0
Text · 21.7 KiB · 2f3c446 Raw
720 lines · python
1# RUN: %PYTHON %s | FileCheck %s2 3import gc4 5from mlir.ir import *6 7 8def run(f):9    print("\nTEST:", f.__name__)10    f()11    gc.collect()12    assert Context._get_live_count() == 013    return f14 15 16# CHECK-LABEL: TEST: testParsePrint17@run18def testParsePrint():19    with Context() as ctx:20        t = Attribute.parse('"hello"')21    assert t.context is ctx22    ctx = None23    gc.collect()24    # CHECK: "hello"25    print(str(t))26    # CHECK: StringAttr("hello")27    print(repr(t))28 29 30# CHECK-LABEL: TEST: testParseError31@run32def testParseError():33    with Context():34        try:35            t = Attribute.parse("BAD_ATTR_DOES_NOT_EXIST")36        except MLIRError as e:37            # CHECK: testParseError: <38            # CHECK:   Unable to parse attribute:39            # CHECK:   error: "BAD_ATTR_DOES_NOT_EXIST":1:1: expected attribute value40            # CHECK: >41            print(f"testParseError: <{e}>")42        else:43            print("Exception not produced")44 45 46# CHECK-LABEL: TEST: testAttrEq47@run48def testAttrEq():49    with Context():50        a1 = Attribute.parse('"attr1"')51        a2 = Attribute.parse('"attr2"')52        a3 = Attribute.parse('"attr1"')53        # CHECK: a1 == a1: True54        print("a1 == a1:", a1 == a1)55        # CHECK: a1 == a2: False56        print("a1 == a2:", a1 == a2)57        # CHECK: a1 == a3: True58        print("a1 == a3:", a1 == a3)59        # CHECK: a1 is None: False60        print("a1 is None:", a1 is None)61 62 63# CHECK-LABEL: TEST: testAttrHash64@run65def testAttrHash():66    with Context():67        a1 = Attribute.parse('"attr1"')68        a2 = Attribute.parse('"attr2"')69        a3 = Attribute.parse('"attr1"')70        # CHECK: hash(a1) == hash(a3): True71        print("hash(a1) == hash(a3):", a1.__hash__() == a3.__hash__())72 73        s = set()74        s.add(a1)75        s.add(a2)76        s.add(a3)77        # CHECK: len(s): 278        print("len(s): ", len(s))79 80 81# CHECK-LABEL: TEST: testAttrCast82@run83def testAttrCast():84    with Context():85        a1 = Attribute.parse('"attr1"')86        a2 = Attribute(a1)87        # CHECK: a1 == a2: True88        print("a1 == a2:", a1 == a2)89 90 91# CHECK-LABEL: TEST: testAttrIsInstance92@run93def testAttrIsInstance():94    with Context():95        a1 = Attribute.parse("42")96        a2 = Attribute.parse("[42]")97        assert IntegerAttr.isinstance(a1)98        assert not IntegerAttr.isinstance(a2)99        assert not ArrayAttr.isinstance(a1)100        assert ArrayAttr.isinstance(a2)101 102 103# CHECK-LABEL: TEST: testAttrEqDoesNotRaise104@run105def testAttrEqDoesNotRaise():106    with Context():107        a1 = Attribute.parse('"attr1"')108        not_an_attr = "foo"109        # CHECK: False110        print(a1 == not_an_attr)111        # CHECK: False112        print(a1 is None)113        # CHECK: True114        print(a1 is not None)115 116 117# CHECK-LABEL: TEST: testAttrCapsule118@run119def testAttrCapsule():120    with Context() as ctx:121        a1 = Attribute.parse('"attr1"')122    # CHECK: mlir.ir.Attribute._CAPIPtr123    attr_capsule = a1._CAPIPtr124    print(attr_capsule)125    a2 = Attribute._CAPICreate(attr_capsule)126    assert a2 == a1127    assert a2.context is ctx128 129 130# CHECK-LABEL: TEST: testStandardAttrCasts131@run132def testStandardAttrCasts():133    with Context():134        a1 = Attribute.parse('"attr1"')135        astr = StringAttr(a1)136        aself = StringAttr(astr)137        # CHECK: StringAttr("attr1")138        print(repr(astr))139        try:140            tillegal = StringAttr(Attribute.parse("1.0"))141        except ValueError as e:142            # CHECK: ValueError: Cannot cast attribute to StringAttr (from Attribute(1.000000e+00 : f64))143            print("ValueError:", e)144        else:145            print("Exception not produced")146 147 148# CHECK-LABEL: TEST: testAffineMapAttr149@run150def testAffineMapAttr():151    with Context() as ctx:152        d0 = AffineDimExpr.get(0)153        d1 = AffineDimExpr.get(1)154        c2 = AffineConstantExpr.get(2)155        map0 = AffineMap.get(2, 3, [])156 157        # CHECK: affine_map<(d0, d1)[s0, s1, s2] -> ()>158        attr_built = AffineMapAttr.get(map0)159        print(str(attr_built))160        assert attr_built.value == map0161        attr_parsed = Attribute.parse(str(attr_built))162        assert attr_built == attr_parsed163 164 165# CHECK-LABEL: TEST: testIntegerSetAttr166@run167def testIntegerSetAttr():168    with Context() as ctx:169        d0 = AffineDimExpr.get(0)170        d1 = AffineDimExpr.get(1)171        s0 = AffineSymbolExpr.get(0)172        c42 = AffineConstantExpr.get(42)173        set0 = IntegerSet.get(2, 1, [d0 - d1, s0 - c42], [True, False])174 175        # CHECK: affine_set<(d0, d1)[s0] : (d0 - d1 == 0, s0 - 42 >= 0)>176        attr_built = IntegerSetAttr.get(set0)177        print(str(attr_built))178 179        attr_parsed = Attribute.parse(str(attr_built))180        assert attr_built == attr_parsed181 182 183# CHECK-LABEL: TEST: testFloatAttr184@run185def testFloatAttr():186    with Context(), Location.unknown():187        fattr = FloatAttr(Attribute.parse("42.0 : f32"))188        # CHECK: fattr value: 42.0189        print("fattr value:", fattr.value)190        # CHECK: fattr float: 42.0 <class 'float'>191        print("fattr float:", float(fattr), type(float(fattr)))192 193        # Test factory methods.194        # CHECK: default_get: 4.200000e+01 : f32195        print("default_get:", FloatAttr.get(F32Type.get(), 42.0))196        # CHECK: f32_get: 4.200000e+01 : f32197        print("f32_get:", FloatAttr.get_f32(42.0))198        # CHECK: f64_get: 4.200000e+01 : f64199        print("f64_get:", FloatAttr.get_f64(42.0))200        try:201            fattr_invalid = FloatAttr.get(IntegerType.get_signless(32), 42)202        except MLIRError as e:203            # CHECK: Invalid attribute:204            # CHECK: error: unknown: expected floating point type205            print(e)206        else:207            print("Exception not produced")208 209 210# CHECK-LABEL: TEST: testIntegerAttr211@run212def testIntegerAttr():213    with Context() as ctx:214        i_attr = IntegerAttr(Attribute.parse("42"))215        # CHECK: i_attr value: 42216        print("i_attr value:", i_attr.value)217        # CHECK: i_attr type: i64218        print("i_attr type:", i_attr.type)219        # CHECK: i_attr int: 42 <class 'int'>220        print("i_attr int:", int(i_attr), type(int(i_attr)))221        si_attr = IntegerAttr(Attribute.parse("-1 : si8"))222        # CHECK: si_attr value: -1223        print("si_attr value:", si_attr.value)224        ui_attr = IntegerAttr(Attribute.parse("255 : ui8"))225        # CHECK: i_attr int: -1 <class 'int'>226        print("si_attr int:", int(si_attr), type(int(si_attr)))227        # CHECK: ui_attr value: 255228        print("ui_attr value:", ui_attr.value)229        # CHECK: i_attr int: 255 <class 'int'>230        print("ui_attr int:", int(ui_attr), type(int(ui_attr)))231        idx_attr = IntegerAttr(Attribute.parse("-1 : index"))232        # CHECK: idx_attr value: -1233        print("idx_attr value:", idx_attr.value)234        # CHECK: idx_attr int: -1 <class 'int'>235        print("idx_attr int:", int(idx_attr), type(int(idx_attr)))236 237        # Test factory methods.238        # CHECK: default_get: 42 : i32239        print("default_get:", IntegerAttr.get(IntegerType.get_signless(32), 42))240 241 242# CHECK-LABEL: TEST: testBoolAttr243@run244def testBoolAttr():245    with Context() as ctx:246        battr = BoolAttr(Attribute.parse("true"))247        # CHECK: iattr value: True248        print("iattr value:", battr.value)249        # CHECK: iattr bool: True <class 'bool'>250        print("iattr bool:", bool(battr), type(bool(battr)))251 252        # Test factory methods.253        # CHECK: default_get: true254        print("default_get:", BoolAttr.get(True))255 256 257# CHECK-LABEL: TEST: testFlatSymbolRefAttr258@run259def testFlatSymbolRefAttr():260    with Context() as ctx:261        sattr = Attribute.parse("@symbol")262        # CHECK: symattr value: symbol263        print("symattr value:", sattr.value)264 265        # Test factory methods.266        # CHECK: default_get: @foobar267        print("default_get:", FlatSymbolRefAttr.get("foobar"))268 269 270# CHECK-LABEL: TEST: testSymbolRefAttr271@run272def testSymbolRefAttr():273    with Context() as ctx:274        sattr = Attribute.parse("@symbol1::@symbol2")275        # CHECK: symattr value: ['symbol1', 'symbol2']276        print("symattr value:", sattr.value)277 278        # CHECK: default_get: @symbol1::@symbol2279        print("default_get:", SymbolRefAttr.get(["symbol1", "symbol2"]))280 281        # CHECK: default_get: @"@symbol1"::@"@symbol2"282        print("default_get:", SymbolRefAttr.get(["@symbol1", "@symbol2"]))283 284 285# CHECK-LABEL: TEST: testOpaqueAttr286@run287def testOpaqueAttr():288    with Context() as ctx:289        ctx.allow_unregistered_dialects = True290        oattr = OpaqueAttr(Attribute.parse("#pytest_dummy.dummyattr<>"))291        # CHECK: oattr value: pytest_dummy292        print("oattr value:", oattr.dialect_namespace)293        # CHECK: oattr value: b'dummyattr<>'294        print("oattr value:", oattr.data)295 296        # Test factory methods.297        # CHECK: default_get: #foobar<123>298        print(299            "default_get:",300            OpaqueAttr.get("foobar", bytes("123", "utf-8"), NoneType.get()),301        )302 303 304# CHECK-LABEL: TEST: testStringAttr305@run306def testStringAttr():307    with Context() as ctx:308        sattr = StringAttr(Attribute.parse('"stringattr"'))309        # CHECK: sattr value: stringattr310        print("sattr value:", sattr.value)311        # CHECK: sattr value: b'stringattr'312        print("sattr value:", sattr.value_bytes)313 314        # Test factory methods.315        # CHECK: default_get: "foobar"316        print("default_get:", StringAttr.get("foobar"))317        # CHECK: typed_get: "12345" : i32318        print("typed_get:", StringAttr.get_typed(IntegerType.get_signless(32), "12345"))319 320 321# CHECK-LABEL: TEST: testNamedAttr322@run323def testNamedAttr():324    with Context():325        a = Attribute.parse('"stringattr"')326        named = a.get_named("foobar")  # Note: under the small object threshold327        # CHECK: attr: "stringattr"328        print("attr:", named.attr)329        # CHECK: name: foobar330        print("name:", named.name)331        # CHECK: named: NamedAttribute(foobar="stringattr")332        print("named:", named)333 334 335# CHECK-LABEL: TEST: testDenseIntAttr336@run337def testDenseIntAttr():338    with Context():339        raw = Attribute.parse("dense<[[0,1,2],[3,4,5]]> : vector<2x3xi32>")340        # CHECK: attr: dense<[{{\[}}0, 1, 2], [3, 4, 5]]>341        print("attr:", raw)342 343        a = DenseIntElementsAttr(raw)344        assert len(a) == 6345 346        # CHECK: 0 1 2 3 4 5347        for value in a:348            print(value, end=" ")349        print()350 351        # CHECK: i32352        print(ShapedType(a.type).element_type)353 354        raw = Attribute.parse("dense<[true,false,true,false]> : vector<4xi1>")355        # CHECK: attr: dense<[true, false, true, false]>356        print("attr:", raw)357 358        a = DenseIntElementsAttr(raw)359        assert len(a) == 4360 361        # CHECK: 1 0 1 0362        for value in a:363            print(value, end=" ")364        print()365 366        # CHECK: i1367        print(ShapedType(a.type).element_type)368 369        shape = Attribute.parse("dense<[0, 1, 2, 3]> : vector<4xindex>")370        # CHECK: attr: dense<[0, 1, 2, 3]>371        print("attr:", shape)372 373 374@run375def testDenseArrayGetItem():376    def print_item(attr_asm):377        attr = Attribute.parse(attr_asm)378        print(f"{len(attr)}: {attr[0]}, {attr[1]}")379 380    with Context():381        # CHECK: 2: False, True382        print_item("array<i1: false, true>")383        # CHECK: 2: 2, 3384        print_item("array<i8: 2, 3>")385        # CHECK: 2: 4, 5386        print_item("array<i16: 4, 5>")387        # CHECK: 2: 6, 7388        print_item("array<i32: 6, 7>")389        # CHECK: 2: 8, 9390        print_item("array<i64: 8, 9>")391        # CHECK: 2: 1.{{0+}}, 2.{{0+}}392        print_item("array<f32: 1.0, 2.0>")393        # CHECK: 2: 3.{{0+}}, 4.{{0+}}394        print_item("array<f64: 3.0, 4.0>")395 396        class MyBool:397            def __bool__(self):398                return True399 400        # CHECK: myboolarray: array<i1: true>401        print("myboolarray:", DenseBoolArrayAttr.get([MyBool()]))402 403 404# CHECK-LABEL: TEST: testDenseArrayAttrConstruction405@run406def testDenseArrayAttrConstruction():407    with Context(), Location.unknown():408 409        def create_and_print(cls, x):410            try:411                darr = cls.get(x)412                print(f"input: {x} ({type(x)}), result: {darr}")413            except Exception as ex:414                print(f"input: {x} ({type(x)}), error: {ex}")415 416        # CHECK: input: [4, 2] (<class 'list'>),417        # CHECK-SAME: result: array<i8: 4, 2>418        create_and_print(DenseI8ArrayAttr, [4, 2])419 420        # CHECK: input: [4, 2.0] (<class 'list'>),421        # CHECK-SAME: error: get(): incompatible function arguments422        create_and_print(DenseI8ArrayAttr, [4, 2.0])423 424        # CHECK: input: [40000, 2] (<class 'list'>),425        # CHECK-SAME: error: get(): incompatible function arguments426        create_and_print(DenseI8ArrayAttr, [40000, 2])427 428        # CHECK: input: range(0, 4) (<class 'range'>),429        # CHECK-SAME: result: array<i8: 0, 1, 2, 3>430        create_and_print(DenseI8ArrayAttr, range(4))431 432        # CHECK: input: [IntegerAttr(4 : i64), IntegerAttr(2 : i64)] (<class 'list'>),433        # CHECK-SAME: result: array<i8: 4, 2>434        create_and_print(DenseI8ArrayAttr, [Attribute.parse(f"{x}") for x in [4, 2]])435 436        # CHECK: input: [IntegerAttr(4000 : i64), IntegerAttr(2 : i64)] (<class 'list'>),437        # CHECK-SAME: error: get(): incompatible function arguments438        create_and_print(DenseI8ArrayAttr, [Attribute.parse(f"{x}") for x in [4000, 2]])439 440        # CHECK: input: [IntegerAttr(4 : i64), FloatAttr(2.000000e+00 : f64)] (<class 'list'>),441        # CHECK-SAME: error: get(): incompatible function arguments442        create_and_print(DenseI8ArrayAttr, [Attribute.parse(f"{x}") for x in [4, 2.0]])443 444        # CHECK: input: [IntegerAttr(4 : i8), IntegerAttr(2 : ui16)] (<class 'list'>),445        # CHECK-SAME: result: array<i8: 4, 2>446        create_and_print(447            DenseI8ArrayAttr, [Attribute.parse(s) for s in ["4 : i8", "2 : ui16"]]448        )449 450        # CHECK: input: [FloatAttr(4.000000e+00 : f64), FloatAttr(2.000000e+00 : f64)] (<class 'list'>)451        # CHECK-SAME: result: array<f32: 4.000000e+00, 2.000000e+00>452        create_and_print(453            DenseF32ArrayAttr, [Attribute.parse(f"{x}") for x in [4.0, 2.0]]454        )455 456        # CHECK: [BoolAttr(true), BoolAttr(false)] (<class 'list'>),457        # CHECK-SAME: result: array<i1: true, false>458        create_and_print(459            DenseBoolArrayAttr, [Attribute.parse(f"{x}") for x in ["true", "false"]]460        )461 462 463# CHECK-LABEL: TEST: testDenseIntAttrGetItem464@run465def testDenseIntAttrGetItem():466    def print_item(attr_asm):467        attr = Attribute.parse(attr_asm)468        dtype = ShapedType(attr.type).element_type469        try:470            item = attr[0]471            print(f"{dtype}:", item)472        except TypeError as e:473            print(f"{dtype}:", e)474 475    with Context():476        # CHECK: i1: 1477        print_item("dense<true> : tensor<i1>")478        # CHECK: i8: 123479        print_item("dense<123> : tensor<i8>")480        # CHECK: i16: 123481        print_item("dense<123> : tensor<i16>")482        # CHECK: i32: 123483        print_item("dense<123> : tensor<i32>")484        # CHECK: i64: 123485        print_item("dense<123> : tensor<i64>")486        # CHECK: ui8: 123487        print_item("dense<123> : tensor<ui8>")488        # CHECK: ui16: 123489        print_item("dense<123> : tensor<ui16>")490        # CHECK: ui32: 123491        print_item("dense<123> : tensor<ui32>")492        # CHECK: ui64: 123493        print_item("dense<123> : tensor<ui64>")494        # CHECK: si8: -123495        print_item("dense<-123> : tensor<si8>")496        # CHECK: si16: -123497        print_item("dense<-123> : tensor<si16>")498        # CHECK: si32: -123499        print_item("dense<-123> : tensor<si32>")500        # CHECK: si64: -123501        print_item("dense<-123> : tensor<si64>")502 503        # CHECK: i7: Unsupported integer type504        print_item("dense<123> : tensor<i7>")505 506 507# CHECK-LABEL: TEST: testDenseFPAttr508@run509def testDenseFPAttr():510    with Context():511        raw = Attribute.parse("dense<[0.0, 1.0, 2.0, 3.0]> : vector<4xf32>")512        # CHECK: attr: dense<[0.000000e+00, 1.000000e+00, 2.000000e+00, 3.000000e+00]>513 514        print("attr:", raw)515 516        a = DenseFPElementsAttr(raw)517        assert len(a) == 4518 519        # CHECK: 0.0 1.0 2.0 3.0520        for value in a:521            print(value, end=" ")522        print()523 524        # CHECK: f32525        print(ShapedType(a.type).element_type)526 527 528# CHECK-LABEL: TEST: testDictAttr529@run530def testDictAttr():531    with Context():532        dict_attr = {533            "stringattr": StringAttr.get("string"),534            "integerattr": IntegerAttr.get(IntegerType.get_signless(32), 42),535        }536 537        a = DictAttr.get(dict_attr)538 539        # CHECK: attr: {integerattr = 42 : i32, stringattr = "string"}540        print("attr:", a)541 542        assert len(a) == 2543 544        # CHECK: integerattr: IntegerAttr(42 : i32)545        print("integerattr:", repr(a["integerattr"]))546 547        # CHECK: stringattr: StringAttr("string")548        print("stringattr:", repr(a["stringattr"]))549 550        # CHECK: True551        print("stringattr" in a)552 553        # CHECK: False554        print("not_in_dict" in a)555 556        # Check that exceptions are raised as expected.557        try:558            _ = a["does_not_exist"]559        except KeyError:560            pass561        else:562            assert False, "Exception not produced"563 564        try:565            _ = a[42]566        except IndexError:567            pass568        else:569            assert False, "expected IndexError on accessing an out-of-bounds attribute"570 571        # CHECK: empty: {}572        print("empty: ", DictAttr.get())573 574 575# CHECK-LABEL: TEST: testTypeAttr576@run577def testTypeAttr():578    with Context():579        raw = Attribute.parse("vector<4xf32>")580        # CHECK: attr: vector<4xf32>581        print("attr:", raw)582        type_attr = TypeAttr(raw)583        # CHECK: f32584        print(ShapedType(type_attr.value).element_type)585 586 587# CHECK-LABEL: TEST: testArrayAttr588@run589def testArrayAttr():590    with Context():591        arr = Attribute.parse("[42, true, vector<4xf32>]")592    # CHECK: arr: [42, true, vector<4xf32>]593    print("arr:", arr)594    # CHECK: - IntegerAttr(42 : i64)595    # CHECK: - BoolAttr(true)596    # CHECK: - TypeAttr(vector<4xf32>)597    for attr in arr:598        print("- ", repr(attr))599 600    with Context():601        intAttr = Attribute.parse("42")602        vecAttr = Attribute.parse("vector<4xf32>")603        boolAttr = BoolAttr.get(True)604        raw = ArrayAttr.get([vecAttr, boolAttr, intAttr])605    # CHECK: attr: [vector<4xf32>, true, 42]606    print("raw attr:", raw)607    # CHECK: - TypeAttr(vector<4xf32>)608    # CHECK: - BoolAttr(true609    # CHECK: - IntegerAttr(42 : i64)610    arr = raw611    for attr in arr:612        print("- ", repr(attr))613    # CHECK: attr[0]: TypeAttr(vector<4xf32>)614    print("attr[0]:", repr(arr[0]))615    # CHECK: attr[1]: BoolAttr(true)616    print("attr[1]:", repr(arr[1]))617    # CHECK: attr[2]: IntegerAttr(42 : i64)618    print("attr[2]:", repr(arr[2]))619    try:620        print("attr[3]:", arr[3])621    except IndexError as e:622        # CHECK: Error: ArrayAttribute index out of range623        print("Error: ", e)624    with Context():625        try:626            ArrayAttr.get([None])627        except RuntimeError as e:628            # CHECK: Error: Invalid attribute (None?) when attempting to create an ArrayAttribute629            print("Error: ", e)630        try:631            ArrayAttr.get([42])632        except RuntimeError as e:633            # CHECK: Error: Invalid attribute when attempting to create an ArrayAttribute634            print("Error: ", e)635 636    with Context():637        array = ArrayAttr.get([StringAttr.get("a"), StringAttr.get("b")])638        array = array + [StringAttr.get("c")]639        # CHECK: concat: ["a", "b", "c"]640        print("concat: ", array)641 642 643# CHECK-LABEL: TEST: testStridedLayoutAttr644@run645def testStridedLayoutAttr():646    with Context():647        attr = StridedLayoutAttr.get(42, [5, 7, 13])648        # CHECK: strided<[5, 7, 13], offset: 42>649        print(attr)650        # CHECK: 42651        print(attr.offset)652        # CHECK: 3653        print(len(attr.strides))654        # CHECK: 5655        print(attr.strides[0])656        # CHECK: 7657        print(attr.strides[1])658        # CHECK: 13659        print(attr.strides[2])660 661        attr = StridedLayoutAttr.get_fully_dynamic(3)662        dynamic = ShapedType.get_dynamic_stride_or_offset()663        # CHECK: strided<[?, ?, ?], offset: ?>664        print(attr)665        # CHECK: offset is dynamic: True666        print(f"offset is dynamic: {attr.offset == dynamic}")667        # CHECK: rank: 3668        print(f"rank: {len(attr.strides)}")669        # CHECK: strides are dynamic: [True, True, True]670        print(f"strides are dynamic: {[s == dynamic for s in attr.strides]}")671 672 673# CHECK-LABEL: TEST: testConcreteTypesRoundTrip674@run675def testConcreteTypesRoundTrip():676    with Context(), Location.unknown():677 678        def print_item(attr):679            print(repr(attr.type))680 681        # CHECK: F32Type(f32)682        print_item(Attribute.parse("42.0 : f32"))683        # CHECK: F32Type(f32)684        print_item(FloatAttr.get_f32(42.0))685        # CHECK: IntegerType(i64)686        print_item(IntegerAttr.get(IntegerType.get_signless(64), 42))687 688        def print_container_item(attr_asm):689            attr = DenseElementsAttr(Attribute.parse(attr_asm))690            print(repr(attr.type))691            print(repr(attr.type.element_type))692 693        # CHECK: RankedTensorType(tensor<i16>)694        # CHECK: IntegerType(i16)695        print_container_item("dense<123> : tensor<i16>")696 697        # CHECK: RankedTensorType(tensor<f64>)698        # CHECK: F64Type(f64)699        print_container_item("dense<1.0> : tensor<f64>")700 701        raw = Attribute.parse("vector<4xf32>")702        # CHECK: attr: vector<4xf32>703        print("attr:", raw)704        type_attr = TypeAttr(raw)705 706        # CHECK: VectorType(vector<4xf32>)707        print(repr(type_attr.value))708        # CHECK: F32Type(f32)709        print(repr(type_attr.value.element_type))710 711 712# CHECK-LABEL: TEST: testConcreteAttributesRoundTrip713@run714def testConcreteAttributesRoundTrip():715    with Context(), Location.unknown():716        # CHECK: FloatAttr(4.200000e+01 : f32)717        print(repr(Attribute.parse("42.0 : f32")))718 719        assert IntegerAttr.static_typeid is not None720