Skip to content

[SCHEDULE] Generate Lower Bound Conditions #1014

@derisavi-huawei

Description

@derisavi-huawei

given the following algorithm and schedule

import tvm
A = tvm.placeholder((64,), name='A', dtype="float32")
Apad = tvm.compute((66,), lambda i: tvm.select(tvm.all(i>0, i < 65), A[i-1], tvm.const(0.)), name='Apad')
Apad2 = tvm.compute((66,), lambda i: Apad[i]*2, name='Apad2')
s = tvm.create_schedule(Apad2.op)
AL1 = s.cache_read(A,"local",[Apad])
print(tvm.lower(s, [A, Apad2], simple_mode=True))

I get the following lowered code. The stage that produces A.local seems incorrect since it accesses element A[-1] in the first iteration. Is there a solution or a workaround?

// attr [A.local] storage_scope = "local"
allocate A.local[float32 * 66]
// attr [Apad] storage_scope = "global"
allocate Apad[float32 * 66]
produce A.local {
  for (ax0, 0, 66) {
    if (likely((ax0 < 65))) {
      A.local[ax0] = A[(ax0 + -1)]
    }
  }
}
produce Apad {
  for (i, 0, 66) {
    Apad[i] = tvm_if_then_else(((0 < i) && (i < 65)), A.local[i], 0.000000f)
  }
}
produce Apad2 {
  for (i, 0, 66) {
    Apad2[i] = (Apad[i]*2.000000f)
  }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions