khj809 opened a new pull request, #348:
URL: https://github.com/apache/tvm-ffi/pull/348

   This PR introduces a Rust implementation of the `Array` container.
   
   ### Key Features
   * **Memory Safety**: Correctly handles reference counting for `ObjectRef` 
elements. It ensures `inc_ref` is called during retrieval (`get`) and `dec_ref` 
is called when elements are removed or the array is cleared.
   * **Dynamic Mutation**: Implements `push`, `pop`, `insert`, `remove`, and 
`clear`. It handles internal growth and reallocation while maintaining 
compatibility with the underlying C++ memory layout.
   * **FFI Compatibility**: Explicitly manages the `data` pointer within 
`ArrayObj` to allow C++ TVM functions to traverse the array using standard 
pointer arithmetic.
   * **Type System Integration**:
       * Implements `AnyCompatible`, allowing `Array<T>` to be erased into 
`Any` and `AnyView` and recovered via `TryFrom`.
       * Implements `FromIterator` and `Extend`, enabling seamless integration 
with Rust's iterator ecosystem.
   
   ## Tests
   Verified with a comprehensive test suite in `tvm-ffi/tests/test_array.rs` 
covering:
   - [x] Basic creation and iteration.
   - [x] Out-of-bounds safety.
   - [x] Dynamic growth and reallocation (push/insert).
   - [x] Memory integrity after element shifting (remove/insert).
   - [x] Roundtrip conversions through `Any` and `AnyView`.
   - [x] Parametric support for both `Tensor` and `Shape` types.


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