When I try to use a graph that uses the Gather operator, I get the error: Failed to compile shader: ERROR: 0:87: '' : array size must be greater than zero.
I used the following PyTorch code to generate the ONNX model:
import torch
import torch.nn as nn
class Model(nn.Module):
def forward(self, x):
x = x[:, 0]
return x
def main():
model = Model()
dummy_input = torch.zeros(1, 2)
torch.onnx.export(model, dummy_input, 'model.onnx', verbose=True)
if __name__ == '__main__':
main()
This creates the model.onnx file and prints out the following graph information:
And I got the following error in the browser's console:
Uncaught (in promise) Error: Failed to compile shader: ERROR: 0:87: '' : array size must be greater than zero
at t.compileShader (webgl-context.ts:174)
at t.compile (program-manager.ts:97)
at program-manager.ts:67
at t.event (instrument.ts:294)
at t.build (program-manager.ts:64)
at t.run (inference-handler.ts:26)
at e.run (gather.ts:10)
at t.<anonymous> (execution-plan.ts:104)
at backend.ts:102
at Object.next (backend.ts:102)
When I try to use a graph that uses the Gather operator, I get the error:
Failed to compile shader: ERROR: 0:87: '' : array size must be greater than zero
.I am not sure if this is an issue with PyTorch or ONNX.js, so I opened an issue with PyTorch as well here: https://github.com/pytorch/pytorch/issues/32956
Does the graph generated by PyTorch look valid?
To Reproduce
I used the following PyTorch code to generate the ONNX model:
This creates the
model.onnx
file and prints out the following graph information:I then used the following ONNX.js code to try to run data through the model:
And I got the following error in the browser's console: