版本发布 8
## What's Changed * Bump Cpp lib to 1.1.0 * Split Module creation to simple `Module::new(path)` and a new `ModuleBuilder` that support all customization and arguments, including new `memory_allocator` and `temp_allocator` args introduced in the new Cpp version. ```diff - let module = Module::from_file_path(path); + let module = Module::new(path); - let module = Module::new( - pte_path, - &[data1_path, data2_path], - Some(LoadMode::File), - /* event_tracer */ None); + let module = ModuleBuilder::new(ptr_path) + .data_files(&[data1_path, data2_path]), + .load_mode(LoadMode::File) + .build(); ``` * Change list EValue constructors to accept pointer to ArrayRef/BoxedEvalueList rather than a slice/BoxedEvalueList-value. The new API comes from an optimization in the Cpp side (https://github.com/pytorch/executorch/pull/13013), which added another indirection but reduced the size of EValue struct. Constructing an EValue from `&str` or `&CStr` directly is no longer possible, as `ArrayRef` must be allocated somewhere and borrowed to the EValue. Use `ArrayRef::from_cstr` or `ArrayRef::from_chars` and construct the value using the array ref instead. ```diff // lists of f64, bool and std::ffi::c_char are simply slices within EValue let list = [42.0, 17.0, 6.0]; - let evalue = EValue::new(list.as_slice()); + let list_ref = ArrayRef::from_slice(list.as_slice); + let evalue = EValue::new(&list); - let evalue = EValue::new(c"hello world!"); + let chars = ArrayRef::from_cstr(c"hello world!"); + let evalue = EValue::new(&chars); // lists of i64, Tensor and optional Tensor are stored in BoxedEvalueList within EValue let (evalue1, evalue2, evalue3) = (EValue::new(42), EValue::new(17), EValue::new(6)); let wrapped_vals = EValuePtrList::new([&evalue1, &evalue2, &evalue3]); let mut unwrapped_vals = storage!(i64, (3)); let list = BoxedEvalueList::new(&wrapped_vals, unwrapped_vals.as_mut()).unwrap(); - let evalue = EValue::new(list); + let evalue = EValue::new(&list); ``` * Make `DataLoader`, `MemoryAllocator` and `NamedDataMap` traits instead of structs. In the Cpp side these are all base classes, and classes extending them used to implement `AsRef<BaseClass>` on the Rust side. Traits are more flexible, and allow for functions that consume `self`. This change is reverting the opposite change introduced in `v0.8.0`. * Add `TensorPtr::copy_of` **Full Changelog**: https://github.com/barakugav/executorch-rs/compare/v0.8.1...v0.9.0
## What's Changed * Bump Cpp lib to 1.0.1, a bug fix release. Linking with 1.0.0 is still possible, but not recommended. In this new version of the Cpp library, negative indexing was fixed, fixing the `nano-gpt` example which was broken in 1.0.0. **Full Changelog**: https://github.com/barakugav/executorch-rs/compare/v0.8.0...v0.8.1
## What's Changed * Bump the Cpp executorch lib to 1.0.0, as part of it a few building and linking breaking changes are included * `flatcc` static lib moved from `{build-dir}/third-party/flatcc_external_project/lib` to `{build-dir}/third-party/flatcc_ep/lib` * `EXECUTORCH_BUILD_EXTENSION_NAMED_DATA_MAP=ON` is required if `EXECUTORCH_BUILD_EXTENSION_MODULE=ON` * Add `NamedDataMap` struct, support reading `.ptd` files * Add `FlatTensorDataMap` under `flat-tensor` feature, an implementation for `NamedDataMap`, see `examples/data_map` * Use more fine grained generics bounds for functions and structs * Rename `Tensor.as_ptr()` -> `Tensor.as_data_ptr()` * Merge `Error` and `CError` into a simpler flat enum * Mark `executorch::platform::pal_init` unsafe, it access global variables without synchronization * Make`DataLoader` a struct instead of trait, implement `AsRef<DataLoader>` for impls, matches underlying Cpp polymorphism * Support overriding platform abstraction level (PAL) of executorch. Can be used to log executorch inner logs to external loggers, for example by using the `log` crate. Also useful for embedded systems * Flatten the sys crate, removing the dedicated module of the cxx bridge * Add `TensorLayout` struct * Add a few minor new functions to existing structs, matching the Cpp API **Full Changelog**: https://github.com/barakugav/executorch-rs/compare/v0.7.4...v0.8.0
Quick release to fix docs build failure on docsrs. ## What's Changed * Replace doc_auto_cfg with doc_auto **Full Changelog**: https://github.com/barakugav/executorch-rs/compare/v0.7.1...v0.7.2
## What's Changed * Bump Cpp executorch to 0.6.0 and add bindings to new functions and arguments * Add RawTensor for low level users, avoiding code size overhead of regular Tensor generics * Add `TensorAccessor`, supporting more efficient indexing into a Tensor * Require mut self for get_mut Tensor methods * Add EXECUTORCH_CPP_VERSION const str to executorch-sys * Bump bindgen from 0.71.1 to 0.72.0 **Full Changelog**: https://github.com/barakugav/executorch-rs/compare/v0.5.0...v0.6.0
## What's Changed * Bump CPP lib to 0.4.0 * Add 'ndarray' feature flag, enabled by default, see `examples/no_ndarray` * Typed and type-erased Tensor variants * New allocate_pinned method in memory allocator, alternative to stack allocations for non-trivially moveable objects * Remove templates from Rust<->Cpp bridge, safer **Full Changelog**: https://github.com/barakugav/executorch-rs/compare/v0.3.0...v0.4.0
## Release `0.3.0` of Rust ExecuTorch A release that address some bugs around non-trivially moveable Cpp objects, causes a change in API. For most structs it has no effect as most Cpp structs of executorch are trivially moveable. For those who are not, such as `Tensor` and `EValue`, the default constructor method, aka `new`, will allocate the underlying Cpp object on the heap using a `Box`. On systems were allocations are not available, a new `Storage` struct is introduced allowing pinned allocations on the stack. ## What's Changed * Update ndarray requirement from 0.15.6 to 0.16.0 * Enforce Cpp objects are not moved for non-trivially movable structs * Remove some deps for real `no_std` by, still not fully supported due to the Cpp lib requiring the Cpp standard library. See https://github.com/pytorch/executorch/issues/4561 * The library is now tested on both Ubuntu and MacOS. Windows is not supported.
## Release `0.2.0` of Rust ExecuTorch The crate will now compile with C++ ExecuTorch version `0.3.0`, bumped from `0.2.1`. ### Added - `f16` feature flag, support input/output Tensors of half precision floating points using the [`half`](https://docs.rs/half/latest/half/) crate. Note that if half precision floats are used in the inner calculations of your model, the feature is not required, only if they are used as input or output Tensors. In the future the crate may use the [standard `f16`](https://doc.rust-lang.org/nightly/std/primitive.f16.html) once its stable, and the feature may be removed. - `complex` feature flag, support input/output Tensors of complex floating points (`f32`, `f64`, or `half::f16` if `f16` is enabled) using the [`num-complex`](https://docs.rs/num-complex/latest/num_complex/) crate. Note that if complex floats are used in the inner calculations of your model, the feature is not required, only if they are used as input or output Tensors. - `std` feature flag, enabled by default, that can be disabled to use the crate without the Rust standard library. Unfortunately, the C++ underlying library still require the C++ standard library, but hopefully that will change in the near future. - `alloc` feature flag, enabled by the `std` feature flag that is enabled by default. If the feature is disabled, all methods and structs requiring allocations will not be compiled. If `std` is enabled, allocations are performed regularly using the standard library. When disabling the `std` flag and enabling `alloc`, the crate will use the [`alloc`](https://doc.rust-lang.org/alloc/) API to allocate objects, requiring a global allocator to be set by the user beforehand.