Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

import oneflow as torch #128

Closed
wants to merge 4 commits into from
Closed

import oneflow as torch #128

wants to merge 4 commits into from

Conversation

CPFLAME
Copy link
Contributor

@CPFLAME CPFLAME commented Aug 25, 2021

这个pr要解决的:测试直接将import toch as oneflow后,常见的分类网络结构是否能正常运行。
torch版本代码参考自 此处

  • alexnet
  • densenet
  • googlenet
  • inception
  • mnasnet
  • mobilenetv2
  • mobilenetv3
  • resnet
  • shufflenetv2
  • squeezenet
  • vgg

@L1aoXingyu
Copy link
Contributor

我验证的网络中有如下的 api 兼容性问题:

  • densenet
    • torch.utils.checkpoint 在 oneflow 下没有对应接口
    • torch.jit 在 oneflow 下没有对应接口
    • nn.ModuleDict 跑不通,报错信息 RuntimeError: ParameterDict should not be called. ,不支持在 forward 里面调用 self.items()
  • googlenet
    • module 'oneflow.nn.init' has no attribute 'trunc_normal_'
  • inception
    • module 'oneflow.nn.functional' has no attribute 'avg_pool2d'
    • module 'oneflow.nn.functional' has no attribute 'max_pool2d'

@CPFLAME
Copy link
Contributor Author

CPFLAME commented Aug 25, 2021

我验证的网络中有如下的 api 兼容性问题:

  • mobilenetv2
    • 无报错,但有warningwarnings.warn("ReLU6 module do not support inplace now")
  • mobilenetv3
    • 接口未对齐 TypeError: adaptive_avg_pool2d(): argument 'output_size' must be int64 list, not int
    • mobilenetv3中函数为F.adaptive_avg_pool2d(input, 1)会报错,但在mobilenetv2中函数为nn.functional.adaptive_avg_pool2d(x, (1, 1))没有问题
  • shufflenetv2
    • 在channel shuffle时报错
       File "shufflenetv2.py", line 33, in channel_shuffle 
              x = torch.transpose(x, 1, 2).contiguous() 
       AttributeError: 'oneflow._oneflow_internal.Tensor' object has no attribute 'contiguous'
      

@BBuf
Copy link
Contributor

BBuf commented Aug 25, 2021

此表格记录OneFlow和Pytorch没有兼容的接口

接口名 详细报错信息 兼容优先级 开发负责人 来源
torch.utils.checkpoint 还没有开发这个接口 DenseNet
torch.jit 暂时没有开发计划 DenseNet
torch.nn.ModuleDict RuntimeError: ParameterDict should not be called.,不支持在 forward 里面调用 self.items() 赵露阳 DenseNet
oneflow.nn.init 没有trunc_normal_方法 张晓雨 GoogleNet
oneflow.nn.functional.avg_pool2d 没有注册这个接口 赵露阳 Inception
oneflow.nn.functional.max_pool2d 没有注册这个接口 赵露阳 Inception
oneflow.nn.ReLU6 警告:warnings.warn("ReLU6 module do not support inplace now") 张晓雨 MobileNetV2
oneflow.nn.functional.adaptive_avg_pool2d argument 'output_size' must be int64 list, not int 郑泽康 MobileNetV3
oneflow.F.adaptive_avg_pool2d F.adaptive_avg_pool2d(input, 1)报错,1改成(1, 1)正常 郑泽康 MobileNetV3
Tensor.contiguous 没有注册这个接口 迎港他们在做 ShuffuleNetV2
F.hardsigmoid() hardsigmoid(): got an unexpected keyword argument 'inplace' 已解决 MobilenetV3
oneflow.as_tensor() 没有这个方法 已解决 Inception
GoogleNet

@rentainhe
Copy link
Contributor

我验证的网络中有如下的 api 兼容性问题:

  • densenet

    • torch.utils.checkpoint 在 oneflow 下没有对应接口
    • torch.jit 在 oneflow 下没有对应接口
    • nn.ModuleDict 跑不通,报错信息 RuntimeError: ParameterDict should not be called. ,不支持在 forward 里面调用 self.items()
  • googlenet

    • module 'oneflow.nn.init' has no attribute 'trunc_normal_'
  • inception

    • module 'oneflow.nn.functional' has no attribute 'avg_pool2d'
    • module 'oneflow.nn.functional' has no attribute 'max_pool2d'

trunc_normal_是不是在pytorch-image-models里有一版实现,我记得谷歌大佬好像是自己写的,ModuleDict那个bug好像在合了

@Flowingsun007
Copy link
Contributor

我验证的网络中有如下的 api 兼容性问题:

  • mobilenetv2

    • 无报错,但有warningwarnings.warn("ReLU6 module do not support inplace now")
  • mobilenetv3

    • 接口未对齐 TypeError: adaptive_avg_pool2d(): argument 'output_size' must be int64 list, not int
    • mobilenetv3中函数为F.adaptive_avg_pool2d(input, 1)会报错,但在mobilenetv2中函数为nn.functional.adaptive_avg_pool2d(x, (1, 1))没有问题
  • shufflenetv2

    • 在channel shuffle时报错
       File "shufflenetv2.py", line 33, in channel_shuffle 
              x = torch.transpose(x, 1, 2).contiguous() 
       AttributeError: 'oneflow._oneflow_internal.Tensor' object has no attribute 'contiguous'
      

@BBuf
Copy link
Contributor

BBuf commented Aug 26, 2021

我验证的网络中有如下的 api 兼容性问题:

  • densenet

    • torch.utils.checkpoint 在 oneflow 下没有对应接口
    • torch.jit 在 oneflow 下没有对应接口
    • nn.ModuleDict 跑不通,报错信息 RuntimeError: ParameterDict should not be called. ,不支持在 forward 里面调用 self.items()
  • googlenet

    • module 'oneflow.nn.init' has no attribute 'trunc_normal_'
  • inception

    • module 'oneflow.nn.functional' has no attribute 'avg_pool2d'
    • module 'oneflow.nn.functional' has no attribute 'max_pool2d'

trunc_normal_是不是在pytorch-image-models里有一版实现,我记得谷歌大佬好像是自己写的,ModuleDict那个bug好像在合了

已支持:Oneflow-Inc/oneflow#6051

@rentainhe
Copy link
Contributor

如果可以的话,能载入一下torch的pretrained权重再在imagenet的val上测试一下结果吗,我之前复现的时候可能模型载入权重部分会有问题,如果没有问题的话在一致输入的情况下准确率是一致的,可以参考mnasnet的复现 #119

相关的权重载入问题的issue我已经提交了,似乎确实是发现了一些问题 #133

mnasnet我这边结果都验证过了是没有问题的

@BBuf
Copy link
Contributor

BBuf commented Aug 26, 2021

如果可以的话,能载入一下torch的pretrained权重再在imagenet的val上测试一下结果吗,我之前复现的时候可能模型载入权重部分会有问题,如果没有问题的话在一致输入的情况下准确率是一致的,可以参考mnasnet的复现 #119

相关的权重载入问题的issue我已经提交了,似乎确实是发现了一些问题 #133

mnasnet我这边结果都验证过了是没有问题的

好的

@rentainhe
Copy link
Contributor

rentainhe commented Aug 26, 2021

如果可以的话,能载入一下torch的pretrained权重再在imagenet的val上测试一下结果吗,我之前复现的时候可能模型载入权重部分会有问题,如果没有问题的话在一致输入的情况下准确率是一致的,可以参考mnasnet的复现 #119
相关的权重载入问题的issue我已经提交了,似乎确实是发现了一些问题 #133
mnasnet我这边结果都验证过了是没有问题的

好的

这个测试我来弄吧,之前已经有写好的脚本了,我后续整理到一个PR里,晚上弄,有时间的话可以关注一下这个权重载入的问题:)

@BBuf
Copy link
Contributor

BBuf commented Aug 27, 2021

开发了一个兼容性对齐的测试脚本 Oneflow-Inc/oneflow#6076 ,自动检查import oneflow as torch是否可行,已经测试了ResNet和AlexNet,这个ISSUE下面的其它网络兼容性测试可以对应添加。 @rentainhe

@BBuf
Copy link
Contributor

BBuf commented Sep 1, 2021

此表格记录import oneflow as torch没有兼容的接口

接口名 详细报错信息 兼容优先级 开发负责人 来源 进度
torch.utils.checkpoint 还没有开发这个接口 DenseNet
torch.jit 暂时没有开发计划 DenseNet
torch.nn.ModuleDict RuntimeError: ParameterDict should not be called.,不支持在 forward 里面调用 self.items() 赵露阳 DenseNet 已完成
oneflow.nn.init 没有trunc_normal_方法 张晓雨 GoogleNet 已完成
oneflow.nn.functional.avg_pool2d 没有注册这个接口 赵露阳 Inception 已完成
oneflow.nn.functional.max_pool2d 没有注册这个接口 赵露阳 Inception 已完成
oneflow.nn.ReLU6 警告:warnings.warn("ReLU6 module do not support inplace now") 张晓雨 MobileNetV2 已完成
oneflow.nn.functional.adaptive_avg_pool2d argument 'output_size' must be int64 list, not int 郑泽康 MobileNetV3 已完成
oneflow.F.adaptive_avg_pool2d F.adaptive_avg_pool2d(input, 1)报错,1改成(1, 1)正常 郑泽康 MobileNetV3 已完成
Tensor.contiguous 没有注册这个接口 张晓雨 ShuffuleNetV2 注册了假接口,已完成
F.hardsigmoid() hardsigmoid(): got an unexpected keyword argument 'inplace' 姚迟 MobilenetV3
oneflow.as_tensor() 没有这个方法 张晓雨 Inception GoogleNet 注册了假接口,已完成

@Ldpe2G Ldpe2G closed this Nov 5, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants