Closed johns10 closed 2 months ago
By all accounts, this code "works"
input = Nx.from_binary(audio, :f32) |> Nx.new_axis(0)
sr = Nx.tensor(@sample_rate)
# {output, new_h, new_c} = Ortex.run(model, {input, sr, h, c})
{a, b, c} = Ortex.run(model, {input, sr, h, c})
{output, new_h, new_c} =
case [Nx.shape(a), Nx.shape(b), Nx.shape(c)] do
[{1, 1}, {2, 1, 64}, {2, 1, 64}] -> {a, b, c}
[{2, 1, 64}, {2, 1, 64}, {1, 1}] -> {c, a, b}
[{2, 1, 64}, {1, 1}, {2, 1, 64}] -> {b, c, a}
end
prob = output |> Nx.squeeze() |> Nx.to_number()
{prob, new_h, new_c}
end
I'm locating the output based on the shape, and then assuming hn and cn come in the same order. The code runs, and the integration test I have locally "works."
The ordering is a known issue (https://github.com/elixir-nx/ortex/issues/26), we're waiting on upstream ort
to have a 2.0 non-rc release before updating main to match. Unfortunately until then, I'd recommend using 0.1.9.
Is there a specific feature you're looking for in main that's not in the 0.1.9 release?
I've been trying to load up the model exported from
https://github.com/pengzhendong/pyannote-onnx/blob/master/pyannote_onnx/pyannote_onnx.py
I keep getting opset errors, no matter what version I try to export from there.
Makes sense. I'm going to close this issue since the ordering of output is already tracked in #26.
In the meantime, I've noticed pytorch sometimes has coupling between its version and supported exportable opset versions so you may have luck trying to downgrade there. Also, this may be helpful for tracking the opset/IR compatibility matrix. Ortex 0.1.9 is on onnxruntime 1.14.1
I'm using this code for VAD:
On 0.1.9, I would consistently get tensors with shape: output: {1, 1} cn: {2, 1, 64} hn: {2, 1, 64}
After upgrading to main, the order of the return values is inconsistent. Logging the shapes over multiple iterations yeilds: