Skip to content
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

Question: how to handle input model not containing tensor shapes? #12

Closed
radu-matei opened this issue Jun 23, 2021 · 2 comments · Fixed by #21
Closed

Question: how to handle input model not containing tensor shapes? #12

radu-matei opened this issue Jun 23, 2021 · 2 comments · Fixed by #21
Assignees

Comments

@radu-matei
Copy link
Member

radu-matei commented Jun 23, 2021

When using the ONNX C API through the Rust bindings, in more than one place we rely on the input model containing the shape for input and output tensors - this is fine in set_input, where the guest provides the shape of the input tensor (if the model doesn't contain it, just use the one supplied by the guest) - but is prone to failing in compute and get_output, when we have to store the output tensors and then return them to the guest into a unidimensional buffer, without any information about its shape.

Currently, in compute, we have to unwrap on the output's dimensions(), which could very well be None.

let shape = outputs
    .get(index)
    .unwrap()
    .dimensions()
    .map(|d| d.unwrap())
    .collect::<Vec<usize>>();
@radu-matei
Copy link
Member Author

Update: we can handle this gracefully within the Tract runtime, still need some more experimentation on how to do it properly when using the native ONNX runtime.

@radu-matei
Copy link
Member Author

Update: I think I managed to fix this for the native ONNX runtime as well, PR incoming.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
1 participant