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

Pytorch not support half on cpu #7

Open
MHGL opened this issue Feb 22, 2021 · 0 comments
Open

Pytorch not support half on cpu #7

MHGL opened this issue Feb 22, 2021 · 0 comments

Comments

@MHGL
Copy link
Contributor

MHGL commented Feb 22, 2021

pytorch half op in python on cpu

Traceback (most recent call last):
  File "test.py", line 182, in <module>
    det()
  File "/opt/conda/lib/python3.8/site-packages/deepvac/syszux_deepvac.py", line 456, in __call__
    self.smokeTestForExport3rd(input)
  File "/opt/conda/lib/python3.8/site-packages/deepvac/syszux_annotation.py", line 6, in wrapper
    return f(*args, **kwargs)
  File "/opt/conda/lib/python3.8/site-packages/deepvac/syszux_deepvac.py", line 606, in smokeTestForExport3rd
    self.exportTorchViaScript()
  File "/opt/conda/lib/python3.8/site-packages/deepvac/syszux_deepvac.py", line 504, in exportTorchViaScript
    save_model.saveByInputOrNot()
  File "/opt/conda/lib/python3.8/site-packages/deepvac/syszux_deepvac.py", line 137, in saveByInputOrNot
    freeze_ts = torch.jit.freeze(self.ts)
  File "/opt/conda/lib/python3.8/site-packages/torch/jit/_freeze.py", line 106, in freeze
    optimize_frozen_module(out)
  File "/opt/conda/lib/python3.8/site-packages/torch/jit/_freeze.py", line 143, in optimize_frozen_module
    torch._C._jit_pass_optimize_frozen_graph(mod.graph)
RuntimeError: "rsqrt_cpu" not implemented for 'Half'

pytorch half op in c++ on cpu (torch.jit.script after model.half())

Traceback of TorchScript, original code (most recent call last):
  File "/opt/conda/lib/python3.8/site-packages/torch/nn/modules/container.py", line 119, in forward
    def forward(self, input):
        for module in self:
            input = module(input)
                    ~~~~~~ <--- HERE
        return input
  File "/home/liyang/Test/yolov5-1/modules/model.py", line 19, in forward
        xcpu = x.cpu()
        xnew = torch.cat([xcpu[..., ::2, ::2], xcpu[..., 1::2, ::2], xcpu[..., ::2, 1::2], xcpu[..., 1::2, 1::2]], 1)
        return self.conv(xnew.to(x.device))
               ~~~~~~~~~ <--- HERE
  File "/opt/conda/lib/python3.8/site-packages/torch/nn/modules/container.py", line 119, in forward
    def forward(self, input):
        for module in self:
            input = module(input)
                    ~~~~~~ <--- HERE
        return input
  File "/opt/conda/lib/python3.8/site-packages/torch/nn/modules/conv.py", line 396, in forward
    def forward(self, input: Tensor) -> Tensor:
        return self._conv_forward(input, self.weight, self.bias)
               ~~~~~~~~~~~~~~~~~~ <--- HERE
  File "/opt/conda/lib/python3.8/site-packages/torch/nn/modules/conv.py", line 392, in _conv_forward
                            weight, bias, self.stride,
                            _pair(0), self.dilation, self.groups)
        return F.conv2d(input, weight, bias, self.stride,
               ~~~~~~~~ <--- HERE
                        self.padding, self.dilation, self.groups)
RuntimeError: "unfolded2d_copy" not implemented for 'Half'

Aborted (core dumped)
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

No branches or pull requests

1 participant