intel / intel-extension-for-pytorch

A Python package for extending the official PyTorch that can easily obtain performance on Intel platform
Apache License 2.0
1.58k stars 242 forks source link

[Feature] Improve error messages for IPEXConv #241

Open robogast opened 2 years ago

robogast commented 2 years ago

I was playing around with a debug model with some convolutions, but got the input shapes of some intermediate layer wrong (in my case a Conv after a Linear, i.e. no channel dim). In plain PyTorch, this gives me a reasonable error message:

$ nn.Conv2d(in_channels=2, out_channels=2, kernel_size=1)(x)
*** RuntimeError: Given groups=1, weight of size [2, 2, 1, 1], expected input[1, 1, 2, 2] to have 2 channels, but got 1 channels instead

However, in IPEX I get the following undescriptive error message:

$ torch.ops.torch_ipex.convolution_forward(x, self.weight, self.bias, self.ctx.get_data_handle())
*** RuntimeError: could not create a descriptor for a dilated convolution forward propagation primitive

Is it possible to shadow the error messages of the original nn modules?

EikanWang commented 2 years ago

Your comment is appreciated. We will have an internal discussion first and keep you posted. Seems like we need to build a more elegant exception capture mechanism.

robogast commented 2 years ago

Thanks for your response :)

Another one I encountered (just logging for completeness):

  File "/gpfs/home5/robertsc/2D-VQ-AE-2/.venv/2D-VQ-AE-2-LDjtrq15-py39-cpu/lib/python3.9/site-packages/torch/_ops.py", line 143, in __call__
    return self._op(*args, **kwargs or {})
RuntimeError: could not create a primitive descriptor iterator

meant in my case that ipex.optimize(..., dtype=x) and pytorch_lightning.trainer(..., precision=y) x != y