GY-Bai opened a new pull request, #20101:
URL: https://github.com/apache/tvm/pull/20101

   ## What this fixes
   
   1. Metal pointer aliases produced by `tirx.ptr_byte_offset` and 
`tirx.handle_add_byte_offset` were emitted through the generic C codegen path.
   
   2. Those casts did not preserve the pointer storage scope. An alias derived 
from shared memory could therefore lose its Metal `threadgroup` address space 
and produce an invalid pointer conversion.
   
   ## What changed
   
   1. Handle pointer-valued `Bind` nodes in `CodeGenMetal` and emit the storage 
scope recorded in their `PointerType`.
   
   2. Lower typed and untyped byte-offset operations with the same address 
space on both the result pointer and the intermediate `char*` cast.
   
   3. Keep the existing generic C behavior for pointers without an explicit 
storage scope.
   
   ## Validation
   
   1. Added a source-generation regression covering both typed and untyped 
aliases derived from a `float16` shared allocation.
   
   2. Added an end-to-end Metal test using the standard compilation pipeline. 
The generated source contains the expected `threadgroup` allocation, typed 
alias, void alias, and byte-offset casts.
   
   3. Ran the end-to-end test on an Apple M2 GPU. The kernel returned `[10.0, 
11.0, 12.0]`, matching the expected output.
   
   4. The two focused tests pass.
   
   5. The two non-GPU tests in `test_target_codegen_metal.py` pass.
   
   6. Pre-commit passes for all three changed files.
   
   ## Scope
   
   1. This change only affects Metal pointer code generation when the TIR 
pointer type carries an explicit storage scope.
   
   2. It does not change allocation placement, compilation pipelines, runtime 
workspace handling, or kernel scheduling.
   


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


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to