Ejemplo n.º 1
0
 def test_vselect_vsplits_vconcats(self):
     # type: () -> None
     r = Rtl(
             self.v3 << vselect(self.v0, self.v1, self.v2),
             (self.v4, self.v5) << vsplit(self.v3),
             (self.v6, self.v7) << vsplit(self.v4),
             self.v8 << vconcat(self.v3, self.v3),
             self.v9 << vconcat(self.v8, self.v8),
     )
     ti = TypeEnv()
     typing = ti_rtl(r, ti)
     t = TypeVar("t", "", ints=True, bools=True, floats=True,
                 simd=(4, 64))
     check_typing(typing, ({
         self.v0: t.as_bool(),
         self.v1: t,
         self.v2: t,
         self.v3: t,
         self.v4: t.half_vector(),
         self.v5: t.half_vector(),
         self.v6: t.half_vector().half_vector(),
         self.v7: t.half_vector().half_vector(),
         self.v8: t.double_vector(),
         self.v9: t.double_vector().double_vector(),
     }, []))
Ejemplo n.º 2
0
 def test_vselect_vsplits_vconcats(self):
     # type: () -> None
     r = Rtl(
             self.v3 << vselect(self.v0, self.v1, self.v2),
             (self.v4, self.v5) << vsplit(self.v3),
             (self.v6, self.v7) << vsplit(self.v4),
             self.v8 << vconcat(self.v3, self.v3),
             self.v9 << vconcat(self.v8, self.v8),
     )
     ti = TypeEnv()
     typing = ti_rtl(r, ti)
     t = TypeVar("t", "", ints=True, bools=True, floats=True,
                 simd=(4, 64))
     check_typing(typing, ({
         self.v0: t.as_bool(),
         self.v1: t,
         self.v2: t,
         self.v3: t,
         self.v4: t.half_vector(),
         self.v5: t.half_vector(),
         self.v6: t.half_vector().half_vector(),
         self.v7: t.half_vector().half_vector(),
         self.v8: t.double_vector(),
         self.v9: t.double_vector().double_vector(),
     }, []))
Ejemplo n.º 3
0
    def test_lanes_check(self):
        # type: () -> None
        x = XForm(Rtl(self.v0 << copy(self.v1)),
                  Rtl((self.v2, self.v3) << vsplit(self.v1),
                      self.v0 << vconcat(self.v2, self.v3)))

        WideVec = TypeSet(lanes=(2, 256), ints=(8, 64), floats=(32, 64),
                          bools=(1, 64))
        self.check_yo_check(x, typeset_check(self.v1, WideVec))
Ejemplo n.º 4
0
 def test_bad_rtl1(self):
     # type: () -> None
     r = Rtl(
             (self.v0, self.v1) << vsplit(self.v2),
             self.v3 << vconcat(self.v0, self.v2),
     )
     ti = TypeEnv()
     self.assertEqual(ti_rtl(r, ti),
                      "On line 1: fail ti on `typeof_v2` <: `1`: " +
                      "Error: empty type created when unifying " +
                      "`typeof_v2` and `half_vector(typeof_v2)`")
Ejemplo n.º 5
0
 def test_bad_rtl1(self):
     # type: () -> None
     r = Rtl(
         (self.v0, self.v1) << vsplit(self.v2),
         self.v3 << vconcat(self.v0, self.v2),
     )
     ti = TypeEnv()
     self.assertEqual(
         ti_rtl(r, ti), "On line 1: fail ti on `typeof_v2` <: `1`: " +
         "Error: empty type created when unifying " +
         "`typeof_v2` and `half_vector(typeof_v2)`")
Ejemplo n.º 6
0
    def test_cleanup_concrete_rtl_fail(self):
        # type: () -> None
        x = Var('x')
        lo = Var('lo')
        hi = Var('hi')
        r = Rtl(
                (lo, hi) << vsplit(x),
        )

        with self.assertRaises(AssertionError):
            r.cleanup_concrete_rtl()
Ejemplo n.º 7
0
    def test_lanes_check(self):
        # type: () -> None
        x = XForm(
            Rtl(self.v0 << copy(self.v1)),
            Rtl((self.v2, self.v3) << vsplit(self.v1),
                self.v0 << vconcat(self.v2, self.v3)))

        WideVec = TypeSet(lanes=(2, 256),
                          ints=(8, 64),
                          floats=(32, 64),
                          bools=(1, 64))
        self.check_yo_check(x, typeset_check(self.v1, WideVec))
Ejemplo n.º 8
0
    def test_cleanup_concrete_rtl(self):
        # type: () -> None
        typ = i64.by(4)
        x = Var('x')
        lo = Var('lo')
        hi = Var('hi')

        r = Rtl(
                (lo, hi) << vsplit(x),
        )
        r1 = r.copy({})
        s = r.substitution(r1, {})

        s[x].set_typevar(TypeVar.singleton(typ))
        r1.cleanup_concrete_rtl()
        assert s is not None
        assert s[x].get_typevar().singleton_type() == typ
        assert s[lo].get_typevar().singleton_type() == i64.by(2)
        assert s[hi].get_typevar().singleton_type() == i64.by(2)