diff --git a/python/nano/tutorial/notebook/inference/pytorch/accelerate_pytorch_inference_onnx.ipynb b/python/nano/tutorial/notebook/inference/pytorch/accelerate_pytorch_inference_onnx.ipynb index 9f39c132aa2..294e40fcd01 100644 --- a/python/nano/tutorial/notebook/inference/pytorch/accelerate_pytorch_inference_onnx.ipynb +++ b/python/nano/tutorial/notebook/inference/pytorch/accelerate_pytorch_inference_onnx.ipynb @@ -32,7 +32,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "You can use ``Trainer.trace(..., accelerator='onnxruntime')`` API to enable the ONNXRuntime acceleration for PyTorch inference. It only takes a few lines." + "You can use ``InferenceOptimizer.trace(..., accelerator='onnxruntime')`` API to enable the ONNXRuntime acceleration for PyTorch inference. It only takes a few lines." ] }, { @@ -109,7 +109,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "To enable ONNXRuntime acceleration for your PyTorch inference pipeline, **the only change you need to made is to import BigDL-Nano Trainer, and trace your PyTorch model to convert it into an ONNXRuntime accelerated module for inference**:" + "To enable ONNXRuntime acceleration for your PyTorch inference pipeline, **the only change you need to made is to import BigDL-Nano** `InferenceOptimizer`**, and trace your PyTorch model to convert it into an ONNXRuntime accelerated module for inference**:" ] }, { @@ -119,11 +119,11 @@ "outputs": [], "source": [ "import torch\n", - "from bigdl.nano.pytorch import Trainer\n", + "from bigdl.nano.pytorch import InferenceOptimizer\n", "\n", - "ort_model = Trainer.trace(model_ft,\n", - " accelerator=\"onnxruntime\",\n", - " input_sample=torch.rand(1, 3, 224, 224))" + "ort_model = InferenceOptimizer.trace(model_ft,\n", + " accelerator=\"onnxruntime\",\n", + " input_sample=torch.rand(1, 3, 224, 224))" ] }, { @@ -134,7 +134,7 @@ "> \n", "> `input_sample` is the parameter for ONNXRuntime accelerator to know the **shape** of the model input. So both the batch size and the specific values are not important to `input_sample`. If we want our test dataset to consist of images with $224 \\times 224$ pixels, we could use `torch.rand(1, 3, 224, 224)` for `input_sample` here. \n", "> \n", - "> Please refer to [API documentation](https://bigdl.readthedocs.io/en/latest/doc/PythonAPI/Nano/pytorch.html#bigdl.nano.pytorch.Trainer.trace) for more information on `Trainer.trace`." + "> Please refer to [API documentation](https://bigdl.readthedocs.io/en/latest/doc/PythonAPI/Nano/pytorch.html#bigdl.nano.pytorch.InferenceOptimizer.trace) for more information on `InferenceOptimizer.trace`." ] }, { diff --git a/python/nano/tutorial/notebook/inference/pytorch/accelerate_pytorch_inference_openvino.ipynb b/python/nano/tutorial/notebook/inference/pytorch/accelerate_pytorch_inference_openvino.ipynb index c5460527101..c66f13a0622 100644 --- a/python/nano/tutorial/notebook/inference/pytorch/accelerate_pytorch_inference_openvino.ipynb +++ b/python/nano/tutorial/notebook/inference/pytorch/accelerate_pytorch_inference_openvino.ipynb @@ -32,7 +32,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "You can use `Trainer.trace(..., accelerator='openvino')` API to enable the OpenVINO acceleration for PyTorch inference. It only takes a few lines." + "You can use `InferenceOptimizer.trace(..., accelerator='openvino')` API to enable the OpenVINO acceleration for PyTorch inference. It only takes a few lines." ] }, { @@ -79,7 +79,7 @@ "source": [ "> ⚠️ **Warning**\n", ">\n", - "> Errors may occur when using `Trainer.trace(accelerator='openvino')` API in CentOS, becuase the latest version of `openvino-dev` is not supported in CentOS." + "> Errors may occur when using `InferenceOptimizer.trace(..., accelerator='openvino')` API in CentOS, becuase the latest version of `openvino-dev` is not supported in CentOS." ] }, { @@ -120,7 +120,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "To enable OpenVINO acceleration for your PyTorch inference pipeline, **the only change you need to made is to import BigDL-Nano Trainer, and trace your PyTorch model to convert it into an OpenVINO accelerated module for inference**:" + "To enable OpenVINO acceleration for your PyTorch inference pipeline, **the only change you need to made is to import BigDL-Nano** `InferenceOptimizer`**, and trace your PyTorch model to convert it into an OpenVINO accelerated module for inference**:" ] }, { @@ -130,9 +130,9 @@ "outputs": [], "source": [ "import torch\n", - "from bigdl.nano.pytorch import Trainer\n", + "from bigdl.nano.pytorch import InferenceOptimizer\n", "\n", - "ov_model = Trainer.trace(model_ft,\n", + "ov_model = InferenceOptimizer.trace(model_ft,\n", " accelerator=\"openvino\",\n", " input_sample=torch.rand(1, 3, 224, 224))" ] @@ -145,7 +145,7 @@ "> \n", "> `input_sample` is the parameter for OpenVINO accelerator to know the **shape** of the model input. So both the batch size and the specific values are not important to `input_sample`. If we want our test dataset to consist of images with $224 \\times 224$ pixels, we could use `torch.rand(1, 3, 224, 224)` for `input_sample` here.\n", "> \n", - "> Please refer to [API documentation](https://bigdl.readthedocs.io/en/latest/doc/PythonAPI/Nano/pytorch.html#bigdl.nano.pytorch.Trainer.trace) for more information on `Trainer.trace`." + "> Please refer to [API documentation](https://bigdl.readthedocs.io/en/latest/doc/PythonAPI/Nano/pytorch.html#bigdl.nano.pytorch.InferenceOptimizer.trace) for more information on `InferenceOptimizer.trace`." ] }, { diff --git a/python/nano/tutorial/notebook/inference/pytorch/quantize_pytorch_inference_inc.ipynb b/python/nano/tutorial/notebook/inference/pytorch/quantize_pytorch_inference_inc.ipynb index dcc94cfddea..3955fcfdb0b 100644 --- a/python/nano/tutorial/notebook/inference/pytorch/quantize_pytorch_inference_inc.ipynb +++ b/python/nano/tutorial/notebook/inference/pytorch/quantize_pytorch_inference_inc.ipynb @@ -32,7 +32,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "With Intel Neural Compressor (INC) as quantization engine, you can apply `Trainer.quantize` API to realize post-training quantization on your PyTorch `nn.Module`. `Trainer.quantize` also supports ONNXRuntime acceleration at the meantime through specifying `accelerator='onnxruntime'`. All acceleration takes only a few lines." + "With Intel Neural Compressor (INC) as quantization engine, you can apply `InferenceOptimizer.quantize` API to realize post-training quantization on your PyTorch `nn.Module`. `InferenceOptimizer.quantize` also supports ONNXRuntime acceleration at the meantime through specifying `accelerator='onnxruntime'`. All acceleration takes only a few lines." ] }, { @@ -201,7 +201,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "To enable quantization using INC for inference, you could simply **import BigDL-Nano Trainer, and use Trainer to quantize your PyTorch model**:" + "To enable quantization using INC for inference, you could simply **import BigDL-Nano** `InferenceOptimizer`**, and use** `InferenceOptimizer` **to quantize your PyTorch model**:" ] }, { @@ -210,10 +210,10 @@ "metadata": {}, "outputs": [], "source": [ - "from bigdl.nano.pytorch import Trainer\n", + "from bigdl.nano.pytorch import InferenceOptimizer\n", "\n", - "q_model = Trainer.quantize(model, \n", - " calib_dataloader=DataLoader(train_dataset, batch_size=32))" + "q_model = InferenceOptimizer.quantize(model, \n", + " calib_dataloader=DataLoader(train_dataset, batch_size=32))" ] }, { @@ -229,11 +229,11 @@ "metadata": {}, "outputs": [], "source": [ - "from bigdl.nano.pytorch import Trainer\n", + "from bigdl.nano.pytorch import InferenceOptimizer\n", "\n", - "q_model = Trainer.quantize(model,\n", - " accelerator='onnxruntime',\n", - " calib_dataloader=DataLoader(train_dataset, batch_size=32))" + "q_model = InferenceOptimizer.quantize(model,\n", + " accelerator='onnxruntime',\n", + " calib_dataloader=DataLoader(train_dataset, batch_size=32))" ] }, { @@ -242,11 +242,11 @@ "source": [ "> 📝 **Note**\n", "> \n", - "> `Trainer` will by default quantize your PyTorch `nn.Module` through **static** post-training quantization. For this case, `calib_dataloader` (for calibration data) is required. Batch size is not important to ``calib_dataloader``, as it intends to read 100 samples. And there could be no label in calibration data.\n", + "> `InferenceOptimizer` will by default quantize your PyTorch `nn.Module` through **static** post-training quantization. For this case, `calib_dataloader` (for calibration data) is required. Batch size is not important to ``calib_dataloader``, as it intends to read 100 samples. And there could be no label in calibration data.\n", "> \n", "> If you would like to implement dynamic post-training quantization, you could set parameter `approach='dynamic'`. In this case, `calib_dataloader` should be `None`. Compared to dynamic quantization, static quantization could lead to faster inference as it eliminates the data conversion costs between layers.\n", "> \n", - "> Please refer to [API documentation](https://bigdl.readthedocs.io/en/latest/doc/PythonAPI/Nano/pytorch.html#bigdl.nano.pytorch.Trainer.quantize) for more information on `Trainer.quantize`." + "> Please refer to [API documentation](https://bigdl.readthedocs.io/en/latest/doc/PythonAPI/Nano/pytorch.html#bigdl.nano.pytorch.InferenceOptimizer.quantize) for more information on `InferenceOptimizer.quantize`." ] }, { diff --git a/python/nano/tutorial/notebook/inference/pytorch/quantize_pytorch_inference_pot.ipynb b/python/nano/tutorial/notebook/inference/pytorch/quantize_pytorch_inference_pot.ipynb index c011c39b84b..0ab1a4c4a7a 100644 --- a/python/nano/tutorial/notebook/inference/pytorch/quantize_pytorch_inference_pot.ipynb +++ b/python/nano/tutorial/notebook/inference/pytorch/quantize_pytorch_inference_pot.ipynb @@ -32,7 +32,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "As Post-training Optimization Tools (POT) is provided by OpenVINO toolkit, OpenVINO acceleration will be enabled in the meantime when using POT for quantization. You can call `Trainer.quantize` API with `accelerator='openvino'` to use POT for your PyTorch `nn.Module`. It only takes a few lines." + "As Post-training Optimization Tools (POT) is provided by OpenVINO toolkit, OpenVINO acceleration will be enabled in the meantime when using POT for quantization. You can call `InferenceOptimizer.quantize` API with `accelerator='openvino'` to use POT for your PyTorch `nn.Module`. It only takes a few lines." ] }, { @@ -79,7 +79,7 @@ "source": [ "> ⚠️ **Warning**\n", ">\n", - "> Errors may occur when using `Trainer.quantize(..., accelerator='openvino')` API in CentOS, becuase the latest version of `openvino-dev` is not supported in CentOS." + "> Errors may occur when using `InferenceOptimizer.quantize(..., accelerator='openvino')` API in CentOS, becuase the latest version of `openvino-dev` is not supported in CentOS." ] }, { @@ -193,7 +193,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "To enable quantization using POT for inference, you could simply **import BigDL-Nano Trainer, and use Trainer to quantize your PyTorch model**:" + "To enable quantization using POT for inference, you could simply **import BigDL-Nano** `InferenceOptimizer`**, and use** `InferenceOptimizer` **to quantize your PyTorch model**:" ] }, { @@ -202,11 +202,11 @@ "metadata": {}, "outputs": [], "source": [ - "from bigdl.nano.pytorch import Trainer\n", + "from bigdl.nano.pytorch import InferenceOptimizer\n", "\n", - "q_model = Trainer.quantize(model,\n", - " accelerator='openvino',\n", - " calib_dataloader=DataLoader(train_dataset, batch_size=32))" + "q_model = InferenceOptimizer.quantize(model,\n", + " accelerator='openvino',\n", + " calib_dataloader=DataLoader(train_dataset, batch_size=32))" ] }, { @@ -219,7 +219,7 @@ "> \n", "> For `calib_dataloader`, batch size is not important as it intends to read 100 samples. And there could be no label in calibration data.\n", "> \n", - "> Please refer to [API documentation](https://bigdl.readthedocs.io/en/latest/doc/PythonAPI/Nano/pytorch.html#bigdl.nano.pytorch.Trainer.quantize) for more information on `Trainer.quantize`." + "> Please refer to [API documentation](https://bigdl.readthedocs.io/en/latest/doc/PythonAPI/Nano/pytorch.html#bigdl.nano.pytorch.InferenceOptimizer.quantize) for more information on `InferenceOptimizer.quantize`." ] }, {