Skip to content

v0.9.0

Latest

Choose a tag to compare

@barakugav barakugav released this 14 Feb 13:22
3b57f80

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.
    - 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 (pytorch/executorch#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.
      // 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: v0.8.1...v0.9.0