Closed hchanon closed 3 years ago
Hi,
I spent a little time on the issue and here is what I learned. It seems that the Onnx library and format has evolved a lot since this ELL project has been updated. My understanding is that the Onnx to ELL converter scripts would need some update to support the current opset. On the lastest python updates, the scripts produce a Onnx file that uses opset 9 while it appears the Onnx to ELL was design to handle opset 6. I did try "torch.onnx.export(self, dummy_input, name, verbose=True, opset_version=7)" but still ran into issue. Sadly, the latest Onnx package does not support opset 6 or lower. From there, it could be possible to downgrade python package, ... ... or the Onnx to ELL could be updated. I did some progress on that but stopped after figuring out that the amount of work required was bigger then what I could invest in this project.
If you plan to invest time in this project, be aware of this situation.
This is fixed by this commt.
Hi,
I tried to run the Keyword spotter training tutorial straight from https://github.com/microsoft/ELL/tree/master/docs/tutorials/Training-audio-keyword-spotter-with-pytorch.
I am getting the following error when I reach the onnx import step and GRU128KeywordSpotter.onnx is not created :
Note that I tried the whole procedure under Windows and under Ubuntu 18 LTS, getting the same results.
Also, I did get a warning after the training step:
C:\anaconda3\lib\site-packages\torch\onnx\symbolic_opset9.py:1577: UserWarning: Exporting a model to ONNX with a batch_size other than 1, with a variable length with GRU can cause an error when running the ONNX model with a different batch size. Make sure to save the model with a batch size of 1, or define the initial states (h0/c0) as inputs of the model. "or define the initial states (h0/c0) as inputs of the model. ")
graph(%input.1 : Float(1, 1, 80), %hidden2keyword.weight : Float(31, 128), %hidden2keyword.bias : Float(31), %83 : Long(1), %84 : Long(1), %102 : Float(1, 384, 80), %103 : Float(1, 384, 128), %104 : Float(1, 768), %105 : Long(1), %106 : Long(1), %124 : Float(1, 384, 128), %125 : Float(1, 384, 128), %126 : Float(1, 768)): %11 : Tensor = onnx::Shape(%input.1) %12 : Tensor = onnx::Constant[value={1}]() %13 : Long() = onnx::Gather[axis=0](%11, %12) # C:\anaconda3\lib\site-packages\torch\nn\modules\rnn.py:710:0 %17 : Tensor = onnx::Unsqueezeaxes=[0] %19 : Tensor = onnx::Concat[axis=0](%83, %17, %84) %20 : Float(1, 1, 128) = onnx::ConstantOfShapevalue={0} # C:\anaconda3\lib\site-packages\torch\nn\modules\rnn.py:718:0 %21 : Tensor? = prim::Constant() %42 : Tensor, %43 : Float(1, 1, 128) = onnx::GRU[hidden_size=128, linear_before_reset=1](%input.1, %102, %103, %104, %21, %20) # C:\anaconda3\lib\site-packages\torch\nn\modules\rnn.py:727:0 %44 : Float(1, 1, 128) = onnx::Squeezeaxes=[1] # C:\anaconda3\lib\site-packages\torch\nn\modules\rnn.py:727:0 %45 : Tensor = onnx::Shape(%44) %46 : Tensor = onnx::Constant[value={1}]() %47 : Long() = onnx::Gather[axis=0](%45, %46) # C:\anaconda3\lib\site-packages\torch\nn\modules\rnn.py:710:0 %51 : Tensor = onnx::Unsqueezeaxes=[0] %53 : Tensor = onnx::Concat[axis=0](%105, %51, %106) %54 : Float(1, 1, 128) = onnx::ConstantOfShapevalue={0} # C:\anaconda3\lib\site-packages\torch\nn\modules\rnn.py:718:0 %55 : Tensor? = prim::Constant() %76 : Tensor, %77 : Float(1, 1, 128) = onnx::GRU[hidden_size=128, linear_before_reset=1](%44, %124, %125, %126, %55, %54) # C:\anaconda3\lib\site-packages\torch\nn\modules\rnn.py:727:0 %78 : Float(1, 1, 128) = onnx::Squeezeaxes=[1] # C:\anaconda3\lib\site-packages\torch\nn\modules\rnn.py:727:0 %79 : Tensor = onnx::Sliceaxes=[0], ends=[9223372036854775807], starts=[-1] %80 : Float(1, 128) = onnx::Squeezeaxes=[0] # train_classifier.py:459:0 %81 : Float(1, 31) = onnx::Gemm[alpha=1., beta=1., transB=1](%80, %hidden2keyword.weight, %hidden2keyword.bias) # C:\anaconda3\lib\site-packages\torch\nn\functional.py:1610:0 %82 : Float(1, 31) = onnx::LogSoftmaxaxis=1 # C:\anaconda3\lib\site-packages\torch\nn\functional.py:1535:0 return (%82)
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
Could it be a Pytorch or Onnx version issue?
My modules versions are (freshly updated) : torch =1.5.0 onnx = 1.1.1 bumpy = 1.14.3 Python = 3.6.5