Lunderberg commented on code in PR #101:
URL: https://github.com/apache/tvm-rfcs/pull/101#discussion_r1439906356
##########
rfcs/assets/0101/spec.md:
##########
@@ -522,7 +528,7 @@ Unlike `PrimExprs`, statements do not return values.
Instead, they operate by mo
* If `t->strides` is not null, then `len(t->strides)` must match
`len(b->strides)` or else an error is raised. For all `i` from 0 to
`len(b->strides) - 1`, `b->strides[i]` must be an `IntImm` whose value matches
`t->strides[i]` (or else an error is raised), an already bound `Var` whose
bound value is `t->strides[i]` (or else an error is raised), or an unbound
`Var` (in which case, it is bound with the value `t->strides[i]`).
* `len(t->shape)` and `len(b->shape)` must match or else an error
is raised. For all `i` from 0 to `len(b->shape) - 1`, `b->shape[i]` must be an
`IntImm` whose value matches `t->shape[i]` (or else an error is raised), an
already bound `Var` whose bound value is `t->shape[i]` (or else an error is
raised), or an unbound `Var` (in which case, it is bound with the value
`t->shape[i]`).
5. One further condition that `PrimFunc`s expect of their `DLTensor`
arguments: No two `DLTensor` arguments are permitted to alias each other.
- 6. Next, `body` is executed. The `PrimFunc` produces outputs by
mutating values in buffers passed as the inputs; these changes can be observed
by the caller via the `DLTensor` representations passed in step i.
+ 6. Next, `body` is executed. The `PrimFunc` produces outputs by
mutating values in buffers passed as the inputs; these changes can be observed
by the caller via the `DLTensor` representations passed in step i. If a
`tir.ret` builtin was executed, the `PrimFunc` returns the value that was
passed to `tir.ret`; otherwise, the `PrimFunc` returns a void value. Upon
returning (whether after encountering a call to `tir.ret` or the end of
`body`), the current scope is popped and all values allocated within the
`PrimFunc` are freed.
Review Comment:
Looking at it, I'm not sure on the "all values allocated within the PrimFunc
are freed" is true.
If there is an `Allocate` node, it gets lowered to a matched pair of to the
PackedFuncs registered as `"tir.TVMBackendAllocWorkspace"` and
`"tir.TVMBackendFreeWorkspace"`. If the body of the `Allocate` node contains
an explicit return through `T.ret`, or an implicit return through an `Assert`
node, then the free wouldn't occur.
Though, that's probably best considered a bug, and not intended behavior.
--
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]