In this fork from QPyTorch, I am experimenting with updating the quantization operations implemented for CPU such that they are registered for TrochScript according to the official PyTorch documentation for extending TorchScript with custom C++ operators instead of using PYBIND11
.
This fork also includes an experiment on creating a basic Torch module and compiling it down using Torch-MLIR (details can be found here).
In addition to the basic requirements for QPyTorch, packages below are needed to run the experiment:
- wheel
- numpy
- An installation of Torch-MLIR
First make sure you have the changes similar to this PR, and then
- Build the custom operators for
qtorch_ops
by creating some directory namedbuild
and running the CMake commandcmake -DCMAKE_PREFIX_PATH="$(python -c 'import torch.utils; print(torch.utils.cmake_prefix_path)')" $PATH_TO_QUANT-CPU_DIR
in it. WherePATH_TO_QUANT-CPU_DIR
is the path toQPyTorch/qtroch/quant/quant_cpu
. - Run
make
to create the shared librarylibqtorch_ops.so
. - Build
qtorch
package usingpip install .
command from the top-level directory in QPyTorch. - Setup Python environment for Torch-MLIR using the command below:
export PYTHONPATH=`pwd`/build/tools/torch-mlir/python_packages/torch_mlir:`pwd`/examples
- Run the Torch-MLIR experiment script in
examples/torch-mlir_experiment.py