iree-org / iree-llvm-sandbox

A sandbox for quick iteration and experimentation on projects related to IREE, MLIR, and LLVM
Apache License 2.0
54 stars 31 forks source link

[Indexing] Implement casting python literals to corresponding `ArithValue`s #738

Closed makslevental closed 1 year ago

makslevental commented 1 year ago

This PR implements casting python vals to corresponding ArithValues;

    one = Scalar(1.0, dtype=f64, fold=False)
    # CHECK: %[[VAL_0:.*]] = arith.constant 1.000000e+00 : f64
    print(one.owner)

    start = one * 100.0

    ten = Tensor(np.array([[1.0, 2.0], [3.0, 4.0]]), dtype=f64, fold=False)
    # CHECK: %[[VAL_13:.*]] = arith.constant dense<{{\[\[}}1.000000e+00, 2.000000e+00], [3.000000e+00, 4.000000e+00]]> : tensor<2x2xf64>
    print(ten.owner)

    two_times_ten = ten * 2.0
    # CHECK: %[[VAL_16:.*]] = arith.constant dense<1.000000e+00> : tensor<2x2xf64>
    print(two_times_ten.owner.operands[1].owner)
    # CHECK: %[[VAL_17:.*]] = arith.mulf %[[VAL_13]], %[[VAL_16]] : tensor<2x2xf64>
    print(two_times_ten.owner)