Skip to content

[jit] round not equivalent between python and torchscript #40771

@fmassa

Description

@fmassa

🐛 Bug

Originally reported by @vfdev-5 in pytorch/vision#2342 (comment)

The behavior of round is not the same between torchscript and Python.

import torch

def foo():    
    return round(2.5)

sfoo = torch.jit.script(foo)
print(foo(), sfoo())
# gives
# 2, 3.0

There are two differences: the value is different, but the returned type as well (float instead of int).

I'm using PyTorch version '1.6.0.dev20200617'

cc @suo @gmagogsfm

Metadata

Metadata

Assignees

No one assigned

    Labels

    oncall: jitAdd this issue/PR to JIT oncall triage queue

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions