oneflow
oneflow copied to clipboard
RoundOp not align with pytorch result
Summary
Pytorch kernel implements the “round half to even” to break ties when a number is equidistant from two integers (e.g. round(2.5) is 2). ( https://pytorch.org/docs/stable/generated/torch.round.html#torch.round )
Code to reproduce bug
import oneflow as flow
import torch
import numpy as np
arr = [0.5, ]
of_in = flow.tensor(arr)
torch_in = torch.tensor(arr)
of_out = flow.round(of_in)
torch_out = torch.round(torch_in)
if not np.allclose(of_out.numpy(), torch_out.numpy()):
print("Not Equal")
print("of_out: ", of_out.numpy()) # [1. ]
print("torch_out: ", torch_out.numpy()) # [0. ]