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

Method while_loop

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

Source from the content-addressed store, hash-verified

220 def main(x: R.Tensor((2, 3), "float32")) -> R.Tensor:
221 @R.function
222 def while_loop(i: R.Tensor((), "int32"), s: R.Tensor((2, 3), "float32")) -> R.Tensor(
223 (2, 3), "float32"
224 ):
225 cond: R.Tensor((), "bool") = R.call_pure_packed(
226 "test.vm.less", i, R.const(10), sinfo_args=(R.Tensor((), dtype="bool"))
227 )
228 c: R.Tensor((), "int32") = R.const(1, dtype="int32")
229 if cond:
230 new_i: R.Tensor((), "int32") = R.add(i, c)
231 new_s: R.Tensor((2, 3), "float32") = R.add(s, x)
232 r: R.Tensor((2, 3), "float32") = while_loop(new_i, new_s)
233 else:
234 r: R.Tensor((2, 3), "float32") = s
235 return r
236
237 gv: R.Tensor((2, 3), "float32") = while_loop(R.const(0), x)
238 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