TH3CHARLie opened a new issue, #15911:
URL: https://github.com/apache/tvm/issues/15911

   ### Expected behavior
   program scheduled with `reverse_compute_at` should generate the same answer.
   
   ### Actual behavior
   
   wrong result, seems like some part of array is not computed
   
   ### Environment
   
   ubuntu 20.04, tvm main branch
   
   ### Steps to reproduce
   A program to reproduce:
   
   ```python
   import tvm
   from tvm.ir.module import IRModule
   from tvm.script import tir as T
   import numpy as np
   from tvm import te
   import tvm.testing
   
   # compute reference
   tgt = tvm.target.Target(target="llvm", host="llvm")
   dev = tvm.device(tgt.kind.name, 0)
   n = te.var("n")
   p = te.const(32, "int32")
   A = te.placeholder((n,), dtype="float32", name="A")
   B = te.placeholder((n,), dtype="float32", name="B")
   C = te.compute(A.shape, lambda i: A[i] + B[i], name="C")
   D = te.compute(A.shape, lambda i: C[i] + C[i], name="D")
   E = te.compute(A.shape, lambda i: D[i] + A[i], name="E")
   func = te.create_prim_func([A, B, E])
   ir_mod = IRModule({"main": func})
   mod = tvm.build(ir_mod, tgt)
   n = 1024
   np_a = np.arange(n).astype(A.dtype)
   np_b = np.arange(n).astype(B.dtype)
   ref_a = tvm.nd.array(np_a, dev)
   ref_b = tvm.nd.array(np_b, dev)
   ref_e = tvm.nd.array(np.zeros(n, dtype=E.dtype), dev)
   mod(ref_a, ref_b, ref_e)
   
   # apply the schedule and compute the results
   schedule = tvm.tir.Schedule(ir_mod)
   block_d = schedule.get_block("D")
   i, = schedule.get_loops(block_d)
   i_0, i_1 = schedule.split(i, factors=[None, 16])
   schedule.reorder(i_1, i_0)
   schedule.add_unit_loop(block_d)
   block_c = schedule.get_block("C")
   schedule.compute_inline(block_c)
   block_e = schedule.get_block("E")
   schedule.reverse_compute_at(block_e, i_1)
   ir_mod = schedule.mod
   mod = tvm.build(ir_mod, tgt)
   tgt_e = tvm.nd.array(np.zeros(n, dtype=E.dtype), dev)
   mod(ref_a, ref_b, tgt_e)
   tvm.testing.assert_allclose(ref_e.numpy(), tgt_e.numpy(), rtol=1e-5)
   ```
   Essentially the program computes A+B+A+B+A so we should expect the final 
output being 5 times of A, clearly `tgt_e` is not the case. 
   
   ### Triage
   
   Please refer to the list of label tags 
[here](https://github.com/apache/tvm/wiki/Issue-Triage-Labels) to find the 
relevant tags and add them below in a bullet format (example below).
   
   * needs-triage
   * tir:schedule


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to