You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tvm.apache.org by "Johnson9009 (via GitHub)" <gi...@apache.org> on 2024/03/20 07:47:33 UTC

[I] [Bug] NDArray::IsAligned Can't Work for OpenCL, Vulkan Device API, should it is removed? [tvm]

Johnson9009 opened a new issue, #16753:
URL: https://github.com/apache/tvm/issues/16753

   When using OpenCL + Graph Executor + set_input_zero_copy, we found below code will raise exception, actually we know the NDArray is allocated by the OpenCL device API, it should satisfy the alignment requirement.
   ![image](https://github.com/apache/tvm/assets/19802523/5d277aed-b3ce-47fb-b5ae-7b7034513e4d)
   
   After browsing some code of OpenCL device API, we found that OpenCL device API finally will return a pointer of host structure `BufferDescriptor`,  and this pointer is convert to `void*`, and store in the `data` field of `DLTensor`.
   ![image](https://github.com/apache/tvm/assets/19802523/a7cdc791-6de8-4892-b8c3-6256254e6941)
   This is the reason why the 1st figure alignment check failed, the vulkan device API use the same mechanism, so it have the same problem.
   
   Why Relay VM haven't meet this failed check?
   ![image](https://github.com/apache/tvm/assets/19802523/2490c964-f34b-40c5-9351-036c9d9338b6)
   ![image](https://github.com/apache/tvm/assets/19802523/6b055194-d794-4bd6-a1ff-0a3d31cbe9f7)
   Acturally Relay VM is impacted by this issue too, the different is Relay VM won't raise exception, but do a non-need copy.
   
   Even through we will pass the aligement argument to the interface ` virtual void* AllocDataSpace(Device dev, size_t nbytes, size_t alignment,  DLDataType type_hint) = 0;` of class `DeviceAPI`, but I found except CPU, it seems all of other device can't avoid to specify aligment when alloc data through their runtime API.
   So why we need this alignment? can we deleted these checks?


-- 
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: commits-unsubscribe@tvm.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] [Bug] NDArray::IsAligned Can't Work for OpenCL, Vulkan Device API, should it is removed? [tvm]

Posted by "Johnson9009 (via GitHub)" <gi...@apache.org>.
Johnson9009 commented on issue #16753:
URL: https://github.com/apache/tvm/issues/16753#issuecomment-2008974991

   @jwfromm @tqchen @junrushao It seems previous discussion in https://github.com/apache/tvm/pull/12564 is relevant.


-- 
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: commits-unsubscribe@tvm.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] [Bug] NDArray::IsAligned Can't Work for OpenCL, Vulkan Device API, should it is removed? [tvm]

Posted by "tqchen (via GitHub)" <gi...@apache.org>.
tqchen commented on issue #16753:
URL: https://github.com/apache/tvm/issues/16753#issuecomment-2032447980

   I think main issue is that the user might slice the memory in zero copy mode, but we could update IsAligned to ensure that we always return true for Tensors in OpenCL VK backend assuming the byte_offset is 0


-- 
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: commits-unsubscribe@tvm.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] [Bug] NDArray::IsAligned Can't Work for OpenCL, Vulkan Device API, should it is removed? [tvm]

Posted by "tqchen (via GitHub)" <gi...@apache.org>.
tqchen closed issue #16753: [Bug] NDArray::IsAligned Can't Work for OpenCL, Vulkan Device API, should it is removed?
URL: https://github.com/apache/tvm/issues/16753


-- 
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: commits-unsubscribe@tvm.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org