Torch._C has no attribute _BUILD_NAMEDTENSOR

1. Problems Description

环境:Ubuntu16.04, Torch1.4, Torchvision0.5, Pytorch1.4, caffe2
笔者本意想把pytorch训练好的模型通过ONNX转换caffe2上部署,谁知在torch.save()函数时报了这个错误。
Through the investigation by Google and Pytorch offical website. NamedTensor functionality had been added from pytorch1.3, so if use pytorch1.2. this error will be dismissed, but I don’t want to go back to lower version.
So I reedit the _namedtensor_internals.py according to the following rules:

Step 1

#import torch
from torch._six import PY2
from collections import OrderedDict

Step 2

Disable the following function

#def assert_namedtensor_build(api_name):
#    if not torch._C._BUILD_NAMEDTENSOR:
#        raise RuntimeError('NYI: {} is experimental and a part '
#                           'of our named tensors project.'.format(api_name))

Step 3

#if torch._C._BUILD_NAMEDTENSOR and tensor.has_names():
if tensor.has_names():

Step 4

Disable the following row code

#assert_namedtensor_build(namer_api_name(inplace))

Then I got it.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值