I made a custom build of Torch to link into an existing c++ application. This is the simplest build of torch that I could manage. To give you background, this is for a POS model that has already been trained but only needs to be implemented in the c++ program. When loading the model into the program I get the following error …
Unknown builtin op: aten::mul.
Could not find any similar ops to aten::mul. This op may not exist or may not be currently supported in TorchScript.
:
File “”, line 3
def mul(a : float, b : Tensor) → Tensor:
return b * a
~~~~~ <— HERE
def add(a : float, b : Tensor) → Tensor:
return b + a
‘mul’ is being compiled since it was called from ‘gelu_0_9’
File “”, line 3
def gelu_0_9(self: Tensor) → Tensor:
return torch.gelu(self, approximate=‘none’)
~~~~~~ <— HERE
As far as I can tell what this means I need to force the entire object file to be linked into my binary. That isn’t a problem. The problem is I don’t know which library has the aten::mul (and other)_operators in it. The compile I options I am using are as follows…
cmake ../ -DUSE_CUDA=OFF -DUSE_FBGEMM=OFF -DUSE_KINETO=OFF -DUSE_CUPTI_SO=OFF -DUSE_OPENMP=OFF -DUSE_NUMPY=OFF -DB UILD_SHARED_LIBS=OFF -DBUILD_CUSTOM_PROTOBUF=ON -DUSE_NNPACK=ON -DUSE_QNNPACK=OFF -DUSE_PYTORCH_QNNPACK=OFF -DUSE_ XNNPACK=OFF -DUSE_DISTRIBUTED=OFF -DUSE_MKLDNN=OFF -DBUILD_PYTHON=OFF -DBUILD_CAFFE2=OFF -DUSE_NCCL=OFF -DUSE_VALG RIND=OFF -DONNX_ML=OFF -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=../../install
So everything is off. There maybe something I have turned off I need to support torchscript but for the life of me I can’t find figure out what it is. Any help with either the compile or which libraries are necessary to make this work would be very helpful. Thank you.