MCPcopy Index your code
hub / github.com/apache/tvm / while_loop

Method while_loop

tests/python/relax/test_transform_dead_code_elimination.py:594–607  ·  view source on GitHub ↗
(i: R.Tensor((), "int32"), s: R.Tensor((2, 3), "float32"))

Source from the content-addressed store, hash-verified

592 def main(x: R.Tensor((2, 3), "float32")) -> R.Tensor:
593 @R.function
594 def while_loop(i: R.Tensor((), "int32"), s: R.Tensor((2, 3), "float32")) -> R.Tensor(
595 (2, 3), "float32"
596 ):
597 cond = R.call_pure_packed(
598 "test.vm.less", i, R.const(10), sinfo_args=R.Tensor((), dtype="bool")
599 )
600 c = R.const(1, dtype="int32")
601 if cond:
602 new_i = R.add(i, c)
603 new_s = R.add(s, x)
604 r = while_loop(new_i, new_s)
605 else:
606 r = s
607 return r
608
609 gv = while_loop(R.const(0), x)
610 return gv

Callers

nothing calls this directly

Calls 3

while_loopFunction · 0.85
TensorMethod · 0.80
addMethod · 0.45

Tested by

no test coverage detected