Example #1
0
def test_vector_unary_not() -> None:
    result = NpirCodegen().visit(
        npir.VectorUnaryOp(
            expr=FieldSliceFactory(name="a"),
            op=common.UnaryOperator.NOT,
        ))
    assert result == "(np.bitwise_not(a_[i:I, j:J, k_:(k_ + 1)]))"
Example #2
0
def test_vector_unary_not() -> None:
    result = NpirCodegen().visit(
        npir.VectorUnaryOp(
            op=common.UnaryOperator.NOT,
            expr=FieldSliceFactory(name="mask", dtype=common.DataType.BOOL),
        )
    )
    assert result == "(np.bitwise_not(mask[i:I, j:J, k:K]))"
Example #3
0
def test_vector_unary_op() -> None:
    result = NpirCodegen().visit(
        npir.VectorUnaryOp(
            expr=FieldSliceFactory(name="a"),
            op=common.UnaryOperator.NEG,
        ),
        is_serial=False,
    )
    assert result == "(-(a[i:I, j:J, k:K]))"