Skip to content

RuntimeError: isTensor() ASSERT FAILED when torch.jit.trace with torch.jit.script #21009

@One-sixth

Description

@One-sixth

🐛 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    module: windowsWindows support for PyTorchoncall: jitAdd this issue/PR to JIT oncall triage queuetriagedThis issue has been looked at a team member, and triaged and prioritized into an appropriate module

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions