Skip to content

inconsistent behavior of nn.functional.interpolate api between oneflow and torch #9107

Closed
@clackhan

Description

@clackhan

pytorch version: 1.12.1+cu102
oneflow:

version: 0.8.1+cu112.git.c0811b327a
git_commit: c0811b327a
cmake_build_type: Debug
rdma: False
mlir: False

pytorch 正常运行

import torch
import numpy as np

mode="bicubic"
x = torch.Tensor(8, 32, 64)
x = x.to("cuda")

window = 16
t = x.shape[2]
x = x[:, None]


np_center = np.random.randint(window, t - window, (1,))[0]
np_warped = np.random.randint(np_center - window, np_center + window, (1,))[0] + 1

center = torch.tensor(np_center)
warped = torch.tensor(np_warped)

left = torch.nn.functional.interpolate(
    x[:, :, :center], (warped, x.shape[3]), mode=mode, align_corners=False
)

oneflow 报错:

import  oneflow as torch
import numpy as np

mode="bicubic"
x = torch.Tensor(8, 32, 64)
x = x.to("cuda")

window = 16
t = x.shape[2]
x = x[:, None]


np_center = np.random.randint(window, t - window, (1,))[0]
np_warped = np.random.randint(np_center - window, np_center + window, (1,))[0] + 1

center = torch.tensor(np_center)
warped = torch.tensor(np_warped)

left = torch.nn.functional.interpolate(
    x[:, :, :center], (warped, x.shape[3]), mode=mode, align_corners=False
)

报错信息

Traceback (most recent call last):
  File "test1.py", line 19, in <module>
    left = torch.nn.functional.interpolate(
  File "/home/hanbinbin/oneflow/python/oneflow/nn/modules/interpolate.py", line 309, in interpolate
    return Interpolate(
  File "/home/hanbinbin/oneflow/python/oneflow/nn/module.py", line 146, in __call__
    res = self.forward(*args, **kwargs)
  File "/home/hanbinbin/oneflow/python/oneflow/nn/modules/interpolate.py", line 193, in forward
    return flow._C.upsample_bicubic_2d(
TypeError: upsample_bicubic_2d(): argument 'height_scale' must be double, not <class 'oneflow.Tensor'>

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions