wrongtest edited a comment on pull request #10582:
URL: https://github.com/apache/tvm/pull/10582#issuecomment-1069820229


   Hi, @vinx13, many thanks for the notes:)
   
   > it is added to the buffer indices
   
   I think why we may still need `elem_offset` is that if we only add the 
indices, the alias buffer shape accesses may become not well-formed, assume a 
buffer `A[8]` is aliased to `B` + 8, than if we add offset to the access index, 
 it comes to
    
   ```python
   B = T.allocate([16], dtype="float32)
   A = T.buffer_decl([8], dtype="float32", data=B.data)
   for i in range(8):
       T.evaluate(A[i + 8])  # index out of bound form
   ```
   
   Also note that the USMP use the form like
   ```python
   with T.let(A.data, T.address_of(B[8], dtype="handle")):
       for i in range(128):
           T.evaluate(A[i])
   ```
   
   However, use let binding and `addrees_of` seems definitely increase the 
complexity if we want subsequent analyses on aliasing. 
   
   All three alternatives try to represent gep semantics since we can not 
directly add a buffer var of handle dtype. From my understanding, they all have 
some pro and cons:
   - add offset to access index
       - pro: cleanest
       - cons: the IR maybe in somewhat strange and ill form
       
   - bind a new buffer var 
      - pro: the buffer access semantic is correct
      - cons: complexity for alias analyzing
   
   - use elem_offset field
      - pro: the buffer access semantic is correct
      - cons:  handling the field is adhoc


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