Issue 1:
RuntimeError: isTensor() ASSERT FAILED 🐛

We want to provide jitted versions of Kornia functions and by doing so during the tests we found the following issue when tracing a nn.Module that internally calls a scripted version of a simple function of the library:

(base) 1 edgar@edgar-ThinkPad-T460:~$ python test_jit.py
test_jit.py:17: TracerWarning: Converting a tensor to a Python integer might cause the trace to be incorrect. We can't record the data flow of Python values, so this value will be treated as a constant in the future. This means that the trace might not generalize to other inputs!
return op_script(input, height, width)
Traceback (most recent call last):
File "test_jit.py", line 21, in <module>
op_traced = torch.jit.trace(my_test_op, torch.rand(1,2,4,4))
File "/home/edgar/software/kornia/.dev_env/lib/python3.7/site-packages/torch/jit/__init__.py", line 688, in trace
var_lookup_fn, _force_outplace)
File "/home/edgar/software/kornia/.dev_env/lib/python3.7/site-packages/torch/nn/modules/module.py", line 491, in __call__
result = self._slow_forward(*input, **kwargs)
File "/home/edgar/software/kornia/.dev_env/lib/python3.7/site-packages/torch/nn/modules/module.py", line 481, in _slow_forward
result = self.forward(*input, **kwargs)
File "test_jit.py", line 17, in forward
return op_script(input, height, width)
RuntimeError: isTensor() ASSERT FAILED at /opt/conda/conda-bld/pytorch_1556653114079/work/aten/src/ATen/core/ivalue.h:209, please report a bug to PyTorch. (toTensor at /opt/conda/conda-bld/pytorch_1556653114079/work/aten/src/ATen/core/ivalue.h:209)
frame #0: c10::Error::Error(c10::SourceLocation, std::string const&) + 0x45 (0x7f9d9e43ddc5 in /home/edgar/software/kornia/.dev_env/lib/python3.7/site-packages/torch/lib/libc10.so)
frame #1: <unknown function> + 0x96437d (0x7f9d9733137d in /home/edgar/software/kornia/.dev_env/lib/python3.7/site-packages/torch/lib/libtorch.so.1)
frame #2: torch::jit::tracer::getNestedValueTrace(c10::IValue const&) + 0x41 (0x7f9d97593eb1 in /home/edgar/software/kornia/.dev_env/lib/python3.7/site-packages/torch/lib/libtorch.so.1)
frame #3: <unknown function> + 0xa5af9b (0x7f9d97427f9b in /home/edgar/software/kornia/.dev_env/lib/python3.7/site-packages/torch/lib/libtorch.so.1)
frame #4: <unknown function> + 0xa5b15b (0x7f9d9742815b in /home/edgar/software/kornia/.dev_env/lib/python3.7/site-packages/torch/lib/libtorch.so.1)
frame #5: <unknown function> + 0x458bf3 (0x7f9dcd772bf3 in /home/edgar/software/kornia/.dev_env/lib/python3.7/site-packages/torch/lib/libtorch_python.so)
frame #6: <unknown function> + 0x12d07a (0x7f9dcd44707a in /home/edgar/software/kornia/.dev_env/lib/python3.7/site-packages/torch/lib/libtorch_python.so)
<omitting python frames>
frame #28: <unknown function> + 0x3e73e6 (0x7f9dcd7013e6 in /home/edgar/software/kornia/.dev_env/lib/python3.7/site-packages/torch/lib/libtorch_python.so)
frame #29: <unknown function> + 0x44830b (0x7f9dcd76230b in /home/edgar/software/kornia/.dev_env/lib/python3.7/site-packages/torch/lib/libtorch_python.so)
frame #30: <unknown function> + 0x45b1c4 (0x7f9dcd7751c4 in /home/edgar/software/kornia/.dev_env/lib/python3.7/site-packages/torch/lib/libtorch_python.so)
frame #31: <unknown function> + 0x12d07a (0x7f9dcd44707a in /home/edgar/software/kornia/.dev_env/lib/python3.7/site-packages/torch/lib/libtorch_python.so)
frame #46: __libc_start_main + 0xe7 (0x7f9ddaaeab97 in /lib/x86_64-linux-gnu/libc.so.6)

To Reproduce

Steps to reproduce the behavior:

Install kornia: pip install git+https://github.com/arraiyopensource/kornia

Run the following script:

import torch
import torch.nn as nn

import kornia

@torch.jit.script
def op_script(input: torch.Tensor, height: int,
width: int) -> torch.Tensor:
return kornia.normalize_pixel_coordinates(input, height, width)

class MyTestModule(nn.Module):
def __init__(self):
super(MyTestModule, self).__init__()

def forward(self, input):
height, width = input.shape[-2:]
return op_script(input, height, width)

my_test_op = MyTestModule()
op_traced = torch.jit.trace(my_test_op, torch.rand(1,2,4,4))

Expected behavior

Environment

PyTorch version: 1.1.0

Is debug build: No

CUDA used to build PyTorch: 10.0.130

OS: Ubuntu 18.04.2 LTS

GCC version: (Ubuntu 7.4.0-1ubuntu1~18.04) 7.4.0

CMake version: version 3.10.2

Python version: 3.7

Is CUDA available: No

CUDA runtime version: No CUDA

GPU models and configuration: No CUDA

Nvidia driver version: No CUDA

cuDNN version: No CUDA

Versions of relevant libraries:

[pip3] numpy==1.16.2

[pip3] torchgeometry==0.1.0

[conda] mkl 2019.3 199

[conda] mkl_fft 1.0.13 py37h516909a_1 conda-forge

[conda] mkl_random 1.0.4 py37hf2d7682_0 conda-forge

[conda] pytorch 1.1.0 py3.7_cuda10.0.130_cudnn7.5.1_0 pytorch

[conda] torchvision 0.3.0 py37_cu10.0.130_1 pytorch

Additional context

Issue 2:
🐛 Bug

I don't know which caused this problem.

To Reproduce

Steps to reproduce the behavior:

import torch
import torch.nn as nn
import torch.nn.functional as F
import torch.jit

@torch.jit.script
def resize_ref(x, shortpoint, method: str='bilinear', align_corners: bool=True):
"""
:type x: torch.Tensor
:type shortpoint: torch.Tensor
:type method: str
:type align_corners: bool
"""
hw = shortpoint.shape[2:4]
ihw = x.shape[2:4]
if hw != ihw:
x = F.interpolate(x, hw, mode=method, align_corners=align_corners)
return x

class Net(nn.Module):
def __init__(self):
super().__init__()

def forward(self, x):
x2 = F.interpolate(x, scale_factor=2)
y = resize_ref(x, x2)
return y

a = torch.rand(1, 3, 6, 6)
net = Net()
net = torch.jit.trace(net, a)
b = net(a)
print(b.shape)

Expected behavior

Environment

Please copy and paste the output from our

environment collection script

(or fill out the checklist below manually).

You can get the script and run it with:

wget https://raw.githubusercontent.com/pytorch/pytorch/master/torch/utils/collect_env.py
# For security purposes, please check the contents of collect_env.py before running it.
python collect_env.py

PyTorch Version (e.g., 1.0):1.1.0

OS (e.g., Linux):win10

How you installed PyTorch (conda, pip, source):pip

Build command you used (if compiling from source):

Python version:3.7

CUDA/cuDNN version:10

GPU models and configuration:gtx970m

Any other relevant information:

Additional context