Lunderberg opened a new pull request, #14771:
URL: https://github.com/apache/tvm/pull/14771

   Prior to this commit, any use of `tvm.nd.from_dlpack` to create a strided 
`NDArray`, or a `NDArray` whose alignment was less than 
`tvm::runtime::kAllocAlignment` would raise an error.  As a result, views into 
larger arrays, which are unlikely to be aligned and compact, could only be 
shared when copied into an aligned and compact buffer.
   
   This commit moves the compact/aligned check from the `NDArray` class into 
the generated TIR code as part of DLTensor unpacking.  These checks were 
initially introduced in https://github.com/apache/tvm/pull/11391, to avoid 
segfaults caused by use of non-aligned buffers in code intended for aligned 
buffers.  The new checks will provide the same safeguard as the alignment is 
checked prior to use, but allows the alignment requirement to be relaxed on a 
per-buffer basis.
   
   This approach also removes a potential bug resulting from compile-time 
configuration of `tvm::runtime::kAllocAlignment`, first introduced in 
https://github.com/apache/tvm/pull/13307.  Since TVM supports cross-compiling, 
the installation of TVM used to compile a kernel may assume a larger value of 
`kAllocAlignment` than is provided by the runtime installation of TVM.  By 
validating the alignment within the generated kernel, rather than as part of 
the runtime, this potential inconsistency would be caught.


-- 
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]

Reply via email to