Lunderberg commented on issue #17322: URL: https://github.com/apache/tvm/issues/17322#issuecomment-2326946938
Reading through the function, the out-of-bounds access would occur any time the input array is larger than 16, and is caught during the call to `R.memory.alloc_storage`. If this were written using `R.call_tir`, then the dynamic shape of the output would be used to generate a dynamic size for `R.memory.alloc_storage`. However, the static size in `R.memory.alloc_storage` implicitly assumes that `m <= 16`. (Also, the error first occurs at 1025 rather than 17, because 1025 is the first time that the 4kB page size defined by `PooledAllocated::kDefaultPageSize` would be exceeded. The `R.memory.alloc_storage` may return a larger size than requested, in order to re-use similarly sized allocations. The validation done by `R.memory.alloc_tensor` is then based on the actual size rather than the requested size.) > If the given Relax IR is illegal, do we have a corresponding legality-checking mechanism to alert early? I think the Relax IR is legal, even though the error can be triggered. In general, the Relax validation tries to categorize IR as either (a) provably incorrect for all possible values, (b) provably correct for all possible values, or (c) neither of the above. If something falls into category (a), then a compile-time error can be thrown. If something falls into category (b), then a runtime check may be omitted. If something falls into (c), then we need to wait until runtime to perform validation. In this case, because the runtime value of `m` may be 16 or less, we cannot raise a compile-time error for this IR, and catching the error at runtime is the best option. -- 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]
