()
| 1655 | |
| 1656 | |
| 1657 | def test_arith_operators(): |
| 1658 | @R.function |
| 1659 | def foo(x: R.Tensor(("m", "n"), "float32"), y: R.Tensor(("m", "n"), "float32")): |
| 1660 | a0 = -x |
| 1661 | a1 = x + y |
| 1662 | a2 = x - y |
| 1663 | a3 = x * y |
| 1664 | a4 = x / y |
| 1665 | a5 = x // y |
| 1666 | a6 = x**y |
| 1667 | |
| 1668 | c0 = x > y |
| 1669 | c1 = x < y |
| 1670 | c2 = x >= y |
| 1671 | c3 = x <= y |
| 1672 | |
| 1673 | tuple_expr = ((x, x), y) |
| 1674 | t0 = tuple_expr[0] |
| 1675 | t1 = tuple_expr[1] |
| 1676 | t2 = tuple_expr[0][0] # <= Will normalize to two bindings |
| 1677 | return (a0, a1, a2, a3, a4, a5, a6, c0, c1, c2, c3, t0, t1, t2) |
| 1678 | |
| 1679 | m = tirx.Var("m", "int64") |
| 1680 | n = tirx.Var("n", "int64") |
| 1681 | x = relax.Var("x", relax.TensorStructInfo([m, n], "float32")) |
| 1682 | y = relax.Var("y", relax.TensorStructInfo([m, n], "float32")) |
| 1683 | bb = relax.BlockBuilder() |
| 1684 | with bb.function("foo", (x, y)): |
| 1685 | a0 = bb.emit(relax.op.negative(x)) |
| 1686 | a1 = bb.emit(relax.op.add(x, y)) |
| 1687 | a2 = bb.emit(relax.op.subtract(x, y)) |
| 1688 | a3 = bb.emit(relax.op.multiply(x, y)) |
| 1689 | a4 = bb.emit(relax.op.divide(x, y)) |
| 1690 | a5 = bb.emit(relax.op.floor_divide(x, y)) |
| 1691 | a6 = bb.emit(relax.op.power(x, y)) |
| 1692 | |
| 1693 | c0 = bb.emit(relax.op.greater(x, y)) |
| 1694 | c1 = bb.emit(relax.op.less(x, y)) |
| 1695 | c2 = bb.emit(relax.op.greater_equal(x, y)) |
| 1696 | c3 = bb.emit(relax.op.less_equal(x, y)) |
| 1697 | |
| 1698 | tuple_expr = bb.emit(relax.Tuple((relax.Tuple((x, x)), y))) |
| 1699 | t0 = bb.emit(relax.TupleGetItem(tuple_expr, 0)) |
| 1700 | t1 = bb.emit(relax.TupleGetItem(tuple_expr, 1)) |
| 1701 | tmp = bb.emit(relax.TupleGetItem(tuple_expr, 0)) |
| 1702 | t2 = bb.emit(relax.TupleGetItem(tmp, 0)) |
| 1703 | bb.emit_func_output(relax.Tuple((a0, a1, a2, a3, a4, a5, a6, c0, c1, c2, c3, t0, t1, t2))) |
| 1704 | |
| 1705 | _check(foo, bb.get()["foo"]) |
| 1706 | |
| 1707 | |
| 1708 | def test_memory_ops(): |
nothing calls this directly
no test coverage detected
searching dependent graphs…