Upgrade to v2.0.0-rc.10#46
Conversation
mortont
left a comment
There was a problem hiding this comment.
A few questions/nits but overall looks good
|
|
||
| /// A faster (unsafe) way of creating an Array from an Erlang binary | ||
| fn initialize_from_raw_ptr<T>(ptr: *const T, shape: &[Ix]) -> ArrayViewMut<T, IxDyn> { | ||
| fn initialize_from_raw_ptr<T>(ptr: *const T, shape: &[Ix]) -> ArrayViewMut<'_, T, IxDyn> { |
There was a problem hiding this comment.
This lifetime looks unnecessary?
There was a problem hiding this comment.
This was suggested by the compiler so I implemented the suggestion.
Would you rather we explicitly define the lifetime for Ix ?
| ($tensors:expr, $axis:expr, $typ:ty, $ort_tensor_kind:ident) => {{ | ||
| type ArrayType<'a> = ArrayBase<ViewRepr<&'a $typ>, Dim<IxDynImpl>>; | ||
| fn filter(tensor: &OrtexTensor) -> Option<ArrayType> { | ||
| fn filter<'a>(tensor: &'a OrtexTensor) -> Option<ArrayType<'a>> { |
There was a problem hiding this comment.
These lifetimes can be removed, this is elided at compile time
| let tensor = match ty { | ||
| ort::TensorElementType::Bfloat16 => { | ||
| OrtexTensor::bf16(e.try_extract_tensor::<half::bf16>()?.into_owned()) | ||
| ort::tensor::TensorElementType::Bfloat16 => { |
There was a problem hiding this comment.
Lots of repetition here, may be worth putting this in a function with a generic. Either way it works fine, just a thought.
There was a problem hiding this comment.
Sounds like a good idea, but I am not that provisioned in Rust to to that I think :)
| // for output_descriptor in &session.outputs { | ||
| // let output_name: &str = &output_descriptor.name; | ||
| // let val = outputs.get(output_name).expect( | ||
| // &format!( | ||
| // "Expected {} to be in the outputs, but didn't find it", | ||
| // output_name | ||
| // )[..], | ||
| // ); | ||
|
|
||
| // let ortextensor: OrtexTensor = val.try_into()?; | ||
| // let shape = ortextensor.shape(); | ||
| // let (dtype, bits) = ortextensor.dtype(); | ||
|
|
||
| // let collected_output = (ResourceArc::new(ortextensor), shape, dtype, bits); | ||
| // collected_outputs.push(collected_output); | ||
| // } | ||
|
|
Hi!
This is my attempt to upgrade the deps and be able to use the latest Ort and ONNX version.
Hopefully my approach does not affect performance, my own tests suggest its still as fast.
Would be nice if someone with actual rust competence can verify my approaches :)
But at least it works :)