jittor与torch在相同输入下,sum与exp函数的输出结果不一致

如果您使用 Jittor 时遇到了安装问题、运行错误、输出错误等问题,您可以在 “问答” 区提问。
为了更好地定位您的问题,建议包含以下内容:

  1. 错误信息、
    jittor与torch在相同输入下,sum与exp函数的输出结果不一致,在部分数据上小数点靠后几位的数据不一致。
  2. Jittor 运行的完整 log(建议复制粘贴运行输出,如果可能请不要使用截图)、
    [i 0604 15:34:12.077456 08 compiler.py:955] Jittor(1.3.7.13) src: /home/yzy/anaconda3/envs/p37-10/lib/python3.7/site-packages/jittor
    [i 0604 15:34:12.086599 08 compiler.py:956] g++ at /usr/bin/g++(7.5.0)
    [i 0604 15:34:12.086693 08 compiler.py:957] cache_path: /home/yzy/.cache/jittor/jt1.3.7/g++7.5.0/py3.7.11/Linux-5.4.0-42xb7/IntelRXeonRCPUx00/default
    [i 0604 15:34:12.096740 08 __init__.py:411] Found nvcc(11.3.109) at /usr/local/cuda/bin/nvcc.
    [i 0604 15:34:12.181845 08 __init__.py:411] Found gdb(8.1.1) at /usr/bin/gdb.
    [i 0604 15:34:12.194274 08 __init__.py:411] Found addr2line(2.30) at /usr/bin/addr2line.
    [i 0604 15:34:12.395292 08 compiler.py:1010] cuda key:cu11.3.109_sm_86
    [i 0604 15:34:12.616238 08 __init__.py:227] Total mem: 31.24GB, using 10 procs for compiling.
    [i 0604 15:34:12.738403 08 jit_compiler.cc:28] Load cc_path: /usr/bin/g++
    [i 0604 15:34:15.879090 08 init.cc:62] Found cuda archs: [86,]
    [i 0604 15:34:16.041677 08 __init__.py:411] Found mpicc(2.1.1) at /usr/bin/mpicc.
    [w 0604 15:34:16.442339 08 compile_extern.py:203] CUDA related path found in LD_LIBRARY_PATH or PATH([‘’, ‘/usr/local/cuda/lib64’, ‘/home/yzy/anaconda3/envs/p37-10/bin’, ‘/home/yzy/anaconda3/condabin’, ‘/home/yzy/.local/bin’, ‘/home/yzy/anaconda3/envs/p37-10/bin’, ‘/usr/local/sbin’, ‘/usr/local/bin’, ‘/usr/sbin’, ‘/usr/bin’, ‘/sbin’, ‘/bin’, ‘/usr/games’, ‘/usr/local/games’, ‘/snap/bin’, ‘/usr/local/cuda/bin’]), This path may cause jittor found the wrong libs, please unset LD_LIBRARY_PATH and remove cuda lib path in Path.
    Or you can let jittor install cuda for you: python3.x -m jittor_utils.install_cuda
    [i 0604 15:34:18.520174 08 cuda_flags.cc:39] CUDA enabled.
    float32
    torch.float32
    15584
    32493
  3. 复现此问题的代码或者描述、
    测试数据下载链接:
    链接: 百度网盘 请输入提取码 提取码: mqb8 复制这段内容后打开百度网盘手机App,操作更方便哦
    code如下:

import os.path as osp
import torch
import torch.utils.data
import numpy as np
import jittor as jt

jt.flags.use_cuda = 1

match_score=np.load(‘match_score.npz’)
matching_scores=match_score[‘matching_scores’]
match_score_jt=jt.Var(matching_scores)
match_score_torch=torch.from_numpy(matching_scores).float().cuda()

print(match_score_jt.dtype)
print(match_score_torch.dtype)

match_score_jt_sum=jt.sum(match_score_jt, dim=1, keepdims=True).cpu().numpy()
match_score_torch_sum=torch.sum(match_score_torch, dim=1, keepdim=True) .cpu().numpy()

match_score_jt_exp=jt.exp(match_score_jt).cpu().numpy()
match_score_torch_exp=torch.exp(match_score_torch).cpu().numpy()

print(np.count_nonzero(match_score_jt_sum-match_score_torch_sum))
print(np.count_nonzero(match_score_jt_exp-match_score_torch_exp))

  1. 您认为正确结果应当如何、
    count_nonzero的结果输出应该为0
  2. 其他必要信息

这有一个 参考模板