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

Unknown builtin op: torch_scatter::scatter_max #147

Closed
ryan2x opened this issue Jul 14, 2020 · 7 comments
Closed

Unknown builtin op: torch_scatter::scatter_max #147

ryan2x opened this issue Jul 14, 2020 · 7 comments
Labels

Comments

@ryan2x
Copy link

ryan2x commented Jul 14, 2020

When I tried to load TorchScript module from C++, I got the error

terminate called after throwing an instance of 'torch::jit::ErrorReport' what(): Unknown builtin op: torch_scatter::scatter_max. Could not find any similar ops to torch_scatter::scatter_max. This op may not exist or may not be currently supported in TorchScript. : File "/opt/conda/lib/python3.7/site-packages/torch_scatter/scatter.py", line 72

The model is trained using PyTorch 1.5.0 and latest pytorch geometric, and torch scatter 2.0.5, and I converted the trained model to TorchScript. I noted the document from https://pytorch-geometric.readthedocs.io/en/latest/notes/jit.html. But it did not mention how to load the custom operators such as torch_scatter::scatter_max. The serving environment is C++, and that's a separate environment from the training environment.

How can I resolve this error for TorchScript serving using C++?

@rusty1s
Copy link
Owner

rusty1s commented Jul 15, 2020

That's correct. This information is currently missing in the tutorial. You need to also build the torch-scatter C++ API, see here. You can find a complete example of serving a model here.

@ryan2x
Copy link
Author

ryan2x commented Jul 15, 2020

Thanks for your prompt response. After installing torch-scatter C++ API, that is libtorchscatter.so, I can get TorchScript serving using C++ working.

@bs1119
Copy link

bs1119 commented Apr 22, 2021

Thanks for your prompt response. After installing torch-scatter C++ API, that is libtorchscatter.so, I can get TorchScript serving using C++ working.

can you explain how to "installing torch-scatter C++ API" exactly? I want to do a similar thing in windows using VS2017.

@rusty1s
Copy link
Owner

rusty1s commented Apr 22, 2021

@github-actions
Copy link

This issue had no activity for 6 months. It will be closed in 2 weeks unless there is some new activity. Is this issue already resolved?

@zdwmeta
Copy link

zdwmeta commented Dec 7, 2022

Hi @rusty1s, I am able to compile and run the following code:

#include <iostream>
#include <torch/torch.h>
#include <torchsparse/sparse.h>

int main() {
  torch::Tensor src = torch::tensor({0.5, 0.4, 0.1, 0.6});
  torch::Tensor index = torch::tensor({0, 0, 1, 1});
  std::cout << src << std::endl;
  std::cout << index << std::endl;
  std::cout << std::get<0>(
                   scatter_min(src, index, 0, torch::nullopt, torch::nullopt))
            << std::endl;
}

However, when running inference with PyG script module, I am still getting the error: Unknown builtin op: torch_scatter::scatter_min. Do you have any idea why this could still happen?

@rusty1s
Copy link
Owner

rusty1s commented Dec 7, 2022

Did you take a look at https://github.com/pyg-team/pytorch_geometric/tree/master/examples/cpp? Does it work for you?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants