-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
wasi-nn: update openvino backend to v0.7.2, use API 2.0 #8790
wasi-nn: update openvino backend to v0.7.2, use API 2.0 #8790
Conversation
Converting this to draft temporarily, plan to bump openvino crate to a newer version than 0.7.1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this makes complete sense. We still need to rebase so that CI runs (remember that one of these PRs should have prtest:full
in it if that is not already the case?).
2b82183
to
c098e32
Compare
0fa3445
to
f515afe
Compare
@abrown I pushed some changes to fix failures due to some incompatibilities with |
I already did... where did that commit go? |
@@ -157,24 +148,51 @@ impl From<SetupError> for BackendError { | |||
|
|||
/// Return the execution target string expected by OpenVINO from the | |||
/// `ExecutionTarget` enum provided by wasi-nn. | |||
fn map_execution_target_to_string(target: ExecutionTarget) -> &'static str { | |||
fn map_execution_target_to_string(target: ExecutionTarget) -> DeviceType<'static> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If possible, let's rewrite this as impl From<ExecutionTarget> for DeviceType<'static>
. If not possible then at least change the function name and documentation.
ExecutionTarget::Tpu => unimplemented!("OpenVINO does not support TPU execution targets"), | ||
} | ||
} | ||
|
||
/// Return OpenVINO's precision type for the `TensorType` enum provided by | ||
/// wasi-nn. | ||
fn map_tensor_type_to_precision(tensor_type: TensorType) -> openvino::Precision { | ||
fn map_tensor_type_to_precision(tensor_type: TensorType) -> openvino::ElementType { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Similarly, this could be impl From<TensorType> for ElementType
.
} | ||
|
||
/// Return the `TensorType` enum provided by wasi-nn for OpenVINO's precision type | ||
fn map_precision_to_tensor_type(element_type: openvino::ElementType) -> TensorType { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This can be a TryFrom
since it is more useful to return an error to the user than crash Wasmtime with todo!
.
ElementType::I32 => TensorType::I32, | ||
ElementType::I64 => TensorType::I64, | ||
ElementType::Bf16 => TensorType::Bf16, | ||
ElementType::Undefined => todo!("not yet supported in wasi-nn `TensorType`"), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this could get cleaned up to something like: ElementType::Undefined | ElementType::Dynamic | ... => Err(BackendError::SomeNewVariant("{:?} is not yet supported in the openvino backend", element_type))
self.1.set_blob(&input_name, &blob)?; | ||
let shape = Shape::new(&dimensions)?; | ||
let mut new_tensor = OvTensor::new(precision, &shape)?; | ||
let buffer = new_tensor.get_raw_data_mut()?; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If no need to specify layout (of input tensor), and there is no PrePostProcessing in the whole file, Does it mean wasm code has to make sure the input tensor matches the requirement of model input? (I assume openvino models requires "NHWC" input)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi Liang, yes this requires input tensor layout match the expected layout for model input.
openvino.rs
.