-
Notifications
You must be signed in to change notification settings - Fork 23
Do you have an example under windows? #3
Comments
cc: @peterjc123 |
Have you experienced any error when using this piece of code? The suggested way is to write a CMake script like this and then |
@peterjc123 Thank you very much for your answer. First, I tried this under the Windows platform. It can be compiled and passed. But the problem is that I want to use torch. jit. script mechanism to export the model, so that it can be easily deployed in c++ end.I couldn't successfully export the model. @torch.jit.script print(compute.graph) The implementation code of the custom warp_perspective function is as follows(warp_perspective .cpp): |
@huang229 So the issue is on the python side, right? What error does it throw? |
@peterjc123 I think the problem is that the warp_perspective function has not been successfully registered in the JIT mechanism.Therefore, the JIT mechanism cannot be used to export the model on the python port.I don't know what to do. |
If you remove |
x= torch::add(y, y) The model can be successfully derived. |
Okay, another question, will |
yes.This is a direct error report. |
There is no save attribute without using the @torch.jit.script model. |
I think there should be something wrong with the jit compiler code. It will be easier to deal with if you could post a full C++ stack trace. |
@peterjc123 Successful compilation of scripts (warp_perspective.cpp).There are no errors displayed.I feel that the following code doesn't work under Windows. The errors completed when exporting the model are as follows: |
cc @ezyang Do you know what might be the reason? I'm not so familiar with the JIT things here. |
Here's all my code: setup.py: setup( script.py: @torch.jit.script print(compute.graph) |
@peterjc123 Thank you very much for taking the time to help me. |
There might be problems with how the static initialization works in Windows, which wouldn't surprise me as we don't do as heavy testing on Windows. Does it work if you move the static initialization to, e.g., a main function? |
@ezyang Thank you very much for your time to help me. As I see in your official documents, using Python interface compiled by python setup.py install under windows, the JIT mechanism of torch does not support exporting models. Only after registration can the model be exported at the python end and deployed at the C + + end. |
The custom layer uses JIT mechanism to invoke on the c++ side, which seems to require registration in scripts, such as:
.# include <torch/script.h>
Torch:: Tensor warp_perspective (torch:: Tensor image, torch:: Tensor warp){
Torch:: Tensor output = torch:: add (image, warp);
Return output. clone ();
}
Static auto registry=
Torch:: jit:: Register Operators ("my_ops:: warp_perspective", & warp_perspective);
This is the application under Ubuntu. Do you have an example under windows?I don't know how to run the example provided in extension-script under Windows.
The text was updated successfully, but these errors were encountered: