Okay, I have a version of stylegan2-ada-pytorch that can be imported into TVM.
I include a script that can be used to convert existing models to to TVM. It can be found on the my fork of the stylegan2-ada repo.
I found that I can only export to TVM in a number of very specific circumstances, namely if I import via ONNX, using the freeze_params=True
option in the Relay frontend.
I’ll include some notes on what went wrong, so in future people can search for their error messages.
ONNX importer
I only way I have been able to import the model to TVM is by exporting the model to ONNX and then importing from there.
However, I had an issue I had to figure out with this. I found that I got the following error with relay.frontend.from_onnx()
.
ValueError: Cannot use and / or / not operator to Expr, hint: use tvm.tir.all / tvm.tir.any instead
Within the ONNX frontend, the function which triggers the error is expand_shape()
in the Expand
converter.
Namely, the result of in_dims = infer_shape(in_shape)[0]
is 3, whereas the result of new_dims = infer_shape(shape)[0]
is ?
, at
least that’s what I get from printing them.
I found that setting the variable freeze_params=True
in relay.frontend.from_onnx
avoids the problem.
This post about dyn.strided_slice
, appears to be related, perhaps this is a stop-gap solution to this problem generally?
Using the PyTorch importer
As discussed earlier in this thread, I was not able to get the PyTorch importer working.
Using the pure PyTorch implementation, we no longer have unsupported prim::PythonOp
s, however we still have ops for ['aten::square', 'aten::randn']
.
I have initial implementation of each in my convert script, but square
does not yet work, and I got a workable solution with ONNX.