Using Specialized Libraries
local graph
Chapter 04: Using Specialized Libraries
Section titled “Chapter 04: Using Specialized Libraries”OpenMP for multithreading, IPEX for Intel CPU optimization.
Nobody needs to do all things by themselves. Neither does PyTorch! We already know PyTorch is one of the most powerful frameworks for building deep learning models. However, as many other tasks are involved in the model-building process, PyTorch relies on specialized libraries and tools to get the job done.
In this chapter, we will learn how to install, use, and configure libraries to optimize CPU-based training and multithreading.
More important than learning the technical nuances presented in this chapter is catching the message it brings: we can improve performance by using and configuring third-party libraries specialized in tasks that PyTorch relies on. In this sense, we can search for many other options than the ones described in this book.
Here is what you will learn as part of this chapter:
- Understanding the concept of multithreading with OpenMP
- Learning how to use and configure OpenMP
- Understanding IPEX – an API for optimizing the usage of PyTorch on Intel processors
- Understanding how to install and use IPEX
Multithreading with OpenMP
Section titled “Multithreading with OpenMP”OpenMP is a library used for parallelizing tasks by harnessing all the power of multicore processors by using the multithreading technique. In the context of PyTorch, OpenMP is employed to parallelize operations executed in the training phase and to accelerate preprocessing tasks related to data augmentation, normalization, and so forth.
As multithreading is a key concept here, to see how OpenMP works, follow me to the next section to understand this technique.
What is multithreading?
Section titled “What is multithreading?”Multithreading is a technique to parallelize tasks in a multicore system, which, in turn, is a computer system endowed with multicore processors. Nowadays, any computing system has multicore processors; smartphones, notebooks, and even TVs have CPUs with more than one processing core.
As an example, let’s look at the notebook that I’m using right now to write this book. My notebook possesses one Intel i5-8265U processor, which has eight cores, as illustrated in Figure 4*.1*:

Figure 4.1 – Physical and logical cores
Modern processors have physical and logical cores. A physical core is a complete and individual processing unit able to perform any computation. A logical core is a processing entity instantiated from the idle resources of physical cores. Therefore, physical cores deliver better performance than logical cores. Thus, we should always prefer to use physical units rather than logical ones.
Nevertheless, from the operating system’s point of view, there is no difference between physical and logical cores (i.e., the operating system sees the total number of cores, regardless of whether they are physical or logical).
Important note
The technology responsible for providing logical cores is called simultaneous multithreading. Each vendor has a commercial name for this technology. Intel calls it hyperthreading, for example. Details about this topic are out of the scope of this book.
We can inspect details about the processor by using the lscpu command for Linux:
[root@laptop] lscpuArchitecture: x86_64
CPU op-mode(s): 32-bit, 64-bit Address sizes: 39 bits physical, 48 bits virtual Byte Order: Little EndianCPU(s): 8 On-line CPU(s) list: 0-7 Vendor ID: GenuineIntel
BIOS Vendor ID: Intel(R) Corporation Model name: Intel(R) Core(TM) i5-8265U CPU @ 1.60GHz BIOS CPU family: 205 CPU family: 6 Model: 142 Thread(s) per core: 2 Core(s) per socket: 4 Socket(s): 1 Stepping: 12 CPU(s) scaling MHz: 79% CPU max MHz: 3900,0000 CPU min MHz: 400,0000 BogoMIPS: 3600.00The output shows a bunch of information about the processor, such as the number of cores and sockets, frequency, architecture, vendor name, and so on. Let’s examine the most relevant fields to our case:
- CPU(s): The total number of physical and logical cores available on the system. “CPU” is used here as a synonym for “core.”
- On-line CPU(s) list: The identification of cores available on the system.
- Socket(s): The number of multicore processors installed on the system. In this example, we have just one multicore processor; hence, the number of sockets is
1. - Thread(s) per core: This indicates whether logical cores are enabled in the system. If it has the number
1, there are only physical cores on the system. Otherwise, the system has both physical and logical cores. - Core(s) per socket: The number of physical cores available on each multicore processor.
Important note
We can use lscpu to get the number of physical and logical cores available on the hardware that we are running on. As you will see in the next sections, this information is essential to optimize the usage of OpenMP.
Modern servers have hundreds of cores. With such computing power on the table, we must find a way to use it properly. Here is where multithreading comes in!
The multithreading technique concerns creating and controlling a set of threads to co-operate and accomplish a given task. These threads are spread out on processor cores so that the running program can use different cores to treat distinct pieces of the computing task. As a result, multiple cores work simultaneously on the same task to accelerate its completion.
A thread is an operating system entity created by processes. A set of threads created by a given process share the same memory address space. Consequently, threads can communicate with themselves much more easily than processes; they just need to read or write the content of some memory address. On the other hand, processes must resort to more complicated methods such as message exchanging, signals, queues, and so on. This is the reason why we prefer to use threads to parallelize a task instead of processes:

Figure 4.2 – Threads and processes
However, the benefits of using threads come at a price: we must take care of our threads. As threads communicate with themselves through shared memory, they can fall under race conditions when multiple threads intend to write on the same memory region. In addition, the programmer must keep threads synchronized to prevent a thread from waiting indefinitely for some result or action of another thread.
Important note
If the concept of threads and processes is new to you, take a break and watch the following video on YouTube before moving on to the next section: https://youtu.be/Dhf-DYO1K78. If you require more profound material, you can read the article written by Roderick Bauer, available at https://medium.com/@rodbauer/understanding-programs-processes-and-threads-fd9fdede4d88.
In short, it is hard work to program threads manually (i.e., on our own). However, luckily, OpenMP is here to help. So, let’s learn how to use it, along with PyTorch, to accelerate the training phase of our machine learning models.
Using and configuring OpenMP
Section titled “Using and configuring OpenMP”OpenMP is a framework that is able to encapsulate and abstract many drawbacks related to programming multiple threads. With this framework, we can parallelize our sequential code by employing a set of functions and primitives. When talking about multithreading, OpenMP is the de facto standard. This explains why PyTorch relies on OpenMP as the default backend to parallelize tasks.
Strictly speaking, we do not need to change anything in PyTorch’s code to use OpenMP. Nevertheless, there are some configuration tricks that can increase the performance of the training process. Let’s see it in practice!
Important note
The complete code shown in this section is available at https://github.com/PacktPublishing/Accelerate-Model-Training-with-PyTorch-2.X/blob/main/code/chapter04/baseline-cnn_cifar10.ipynb and https://github.com/PacktPublishing/Accelerate-Model-Training-with-PyTorch-2.X/blob/main/code/chapter04/gomp-cnn_cifar10.ipynb.
At first, we will run the same code presented in Chapter 2, Training Models Faster, to train the CNN model with the CIFAR-10 dataset. The environment is configured with GNU OpenMP 4.5 and possesses an Intel processor with 32 cores in total, half physical and half logical.
To check the OpenMP version and number of threads used in the current environment, we can execute the torch.__config__.parallel_info() function:
ATen/Parallel: at::get_num_threads() : 16 at::get_num_interop_threads() : 16 OpenMP 201511 (a.k.a. OpenMP 4.5) omp_get_max_threads() : 16 Intel(R) oneAPI Math Kernel Library Version 2022.2 mkl_get_max_threads() : 16 Intel(R) MKL-DNN v2.7.3 std::thread::hardware_concurrency() : 32 Environment variables:
OMP_NUM_THREADS : [not set] MKL_NUM_THREADS : [not set]ATen parallel backend: OpenMP
The last line of the output confirms that OpenMP is the parallel backend configured in the environment. We can also see it is OpenMP version 4.5, as well as the number of threads set and values configured for two environment variables. The hardware_concurrency() field shows a value of 32, indicating that the environment is able to run up to 32 threads since the system has 32 cores at maximum.
In addition, the output provides information on the get_num_threads() field, which is the number of threads used by OpenMP. The default behavior of OpenMP is to use a number of threads equivalent to the number of physical cores. So, in this case, the default number of threads is 16.
The training phase took 178 seconds to run 10 epochs. During the training process, we can use the htop command to verify how OpenMP binds threads to cores. In our experiment, PyTorch/OpenMP has made a configuration that is pictorially described in Figure 4*.3*:

Figure 4.3 – Default OpenMP threads allocation
OpenMP has allocated the set of 16 threads to 8 physical cores and 8 logical cores. As stated in the previous section, physical cores provide better performance than logical ones. Even with physical cores available, OpenMP has used logical cores to execute half of PyTorch’s threads.
At first sight, the decision to use logical cores, even when having physical ones available, may sound silly. However, we should remember that processors are used by the entire computing system – that is, they are used for other tasks besides our training process. Therefore, the operating system, together with OpenMP, should try to be fair enough with all demanding tasks – that is, they should also offer the chance to use physical cores.
Despite the default behavior of OpenMP, we can set up a couple of environment variables to change the way OpenMP allocates, controls, and governs threads. The following piece of code, appended to the beginning of our CNN/CIFAR-10 code, modifies OpenMP operations to improve performance:
os.environ[‘OMP_NUM_THREADS’] = “16”os.environ[‘OMP_PROC_BIND’] = “TRUE” os.environ[‘OMP_SCHEDULE’] = “STATIC” os.environ[‘GOMP_CPU_AFFINITY’] = “0-15”
These lines set up four environment variables directly from Python code. Before explaining what these variables mean, let’s first see the performance improvement they have provided.
The training time of the CNN model using the CIFAR-10 dataset was reduced from 178 seconds to 114 seconds, revealing a performance improvement of 56%! Nothing else was changed in the code! In this execution, OpenMP has created the threads assignment pictorially described in Figure 4*.4*:

Figure 4.4 – Optimized OpenMP thread allocation
As you can see in Figure 4*.4*, OpenMP has used all 16 physical cores, leaving out the logical cores. We can say that binding threads to physical cores is the primary reason for such an increase in performance.
Let’s break down the set of environment variables configured in this experiment to understand how they contribute to improving the performance of our training process:
OMP_NUM_THREADS: This defines the number of threads used by OpenMP. We have set the number of threads to16, which is exactly the same value set as the default by OpenMP. Although this configuration did not bring any changes to our scenario, it is essential to know this option to control the number of threads used by OpenMP. This is especially important when running more than one training process simultaneously on the same server.OMP_PROC_BIND: This determines the thread affinity policy. When set toTRUE, this configuration tells OpenMP to keep threads running on the same core during the entire execution. This configuration prevents threads from being moved from cores, thus minimizing performance issues, such as cache missing.OMP_SCHEDULE: This defines the scheduling policy. As we want to statically bind threads to cores, we should set this variable to a static policy.GOMP_CPU_AFFINITY: This indicates the cores or processors to be used by OpenMP to execute threads. In order to only use physical cores, we should indicate processor identifications corresponding to the physical cores in the system.
The combination of those variables has greatly accelerated the training process of our CNN model. In short, we forced OpenMP to use only physical cores and keep threads running on the same core they were initially assigned. As a result, we have harnessed all the computing power of the physical cores while minimizing the performance pitfalls from the overhead caused by frequent context switching.
Important note
Essentially, context switching occurs when the operating system decides to interrupt the execution of a process to give the opportunity of using a CPU to another process.
OpenMP has a couple more variables to control its behavior besides the ones presented in this chapter. To check the current OpenMP configuration, we can set the OMP_DISPLAY_ENV environment variable to TRUE when running our PyTorch code:
OPENMP DISPLAY ENVIRONMENT BEGIN _OPENMP = ‘201511’
OMP_DYNAMIC = 'FALSE' OMP_NESTED = 'FALSE' OMP_NUM_THREADS = '16' OMP_SCHEDULE = 'STATIC' OMP_PROC_BIND = 'TRUE' OMP_PLACES = '{0},{1},{2},{3},{4},{5},{6},{7},{8},{9},{10},{11},{12} ,{13},{14},{15}' OMP_STACKSIZE = '36668818' OMP_WAIT_POLICY = 'PASSIVE' OMP_THREAD_LIMIT = '4294967295' OMP_MAX_ACTIVE_LEVELS = '2147483647' OMP_CANCELLATION = 'FALSE' OMP_DEFAULT_DEVICE = '0' OMP_MAX_TASK_PRIORITY = '0'OPENMP DISPLAY ENVIRONMENT END
It is interesting to learn how each of those environment variable changes OpenMP operation; thus, we can fine-tune for particular scenarios. This output is also useful to verify whether changes to the environment variables did indeed take place.
The experiments described in this section used GNU OpenMP since it is the default parallel backend adopted by PyTorch. However, as OpenMP is actually a framework, we have other implementations of OpenMP besides the one provided by GNU. One of those implementations is Intel OpenMP, which is suitable for Intel processor environments.
However, does Intel OpenMP bring relevant improvements? Is it worth using it in place of GNU implementation? See for yourself in the next section!
Using and configuring Intel OpenMP
Section titled “Using and configuring Intel OpenMP”Intel has its own OpenMP implementation, which promises to deliver better performance in Intel-based environments. As PyTorch comes with GNU implementation by default, we need to take three steps in order to use Intel OpenMP in place of the GNU version:
- Install Intel OpenMP.
- Load the Intel OpenMP libraries.
- Set up specific environment variables for Intel OpenMP.
Important note
The complete code shown in this section is available at https://github.com/PacktPublishing/Accelerate-Model-Training-with-PyTorch-2.X/blob/main/code/chapter04/iomp-cnn_cifar10.ipynb.
The first step is the easiest one. When considering a Python environment based on Anaconda or supporting PIP, we just need to execute one of these commands to install Intel OpenMP:
pip install intel-openmpconda install intel-openmpAfter installation, we should prioritize loading Intel OpenMP libraries instead of implementing GNU. Otherwise, PyTorch will keep using the libraries of the default OpenMP installation, even with Intel OpenMP installed on the system.
Important note
If we do not use a PIP or Anaconda-based environment, we can install it on our own. This process requires compiling Intel OpenMP to further install it in the environment.
We enact this configuration by setting the LD_PRELOAD environment variable before running our code:
export LD_PRELOAD=/opt/conda/lib/libiomp5.so:$LD_PRELOAD
In the environment used for these experiments, the Intel OpenMP library is located at /opt/conda/lib/libiomp5.so. The LD_PRELOAD environment variable allows for forcing the operating system to load libraries before loading the ones configured by default.
At last, we need to set up some environment variables related to Intel OpenMP:
import osos.environ['OMP_NUM_THREADS'] = "16"os.environ[‘KMP_AFFINITY’] = “granularity=fine,compact,1,0” os.environ[‘KMP_BLOCKTIME’] = “0”
OMP_NUM_THREADS has the same meaning as the GNU version, whereas KMP_AFFINITY and KMP_BLOCKTIME are exclusive to Intel OpenMP:
KMP_AFFINITY: This defines the threads allocation policy. When set togranularity=fine,compact,1,0, Intel OpenMP binds threads to physical cores, besides trying to keep it that way for the entire execution. Thus, in the case of Intel OpenMP, we do not need to pass a list of physical cores to force the usage of physical processors, as we do in GNU implementation.KMP_BLOCKTIME: This determines the time that a thread should wait to sleep after completing a task. When set to zero, threads go to sleep immediately after doing their job, thus minimizing the wastage of processor cycles just to wait for another task.
Similar to the GNU version, Intel OpenMP also outputs the current configuration when the OMP_DISPLAY_ENV variable is set to TRUE (shortened output example):
OPENMP DISPLAY ENVIRONMENT BEGIN _OPENMP=‘201611’
[host] OMP_AFFINITY_FORMAT='OMP: pid %P tid %i thread %n bound to OS proc set {%A}' [host] OMP_ALLOCATOR='omp_default_mem_alloc' [host] OMP_CANCELLATION='FALSE' [host] OMP_DEBUG='disabled' [host] OMP_DEFAULT_DEVICE='0' [host] OMP_DISPLAY_AFFINITY='FALSE' [host] OMP_DISPLAY_ENV='TRUE' [host] OMP_DYNAMIC='FALSE' [host] OMP_MAX_ACTIVE_LEVELS='1' [host] OMP_MAX_TASK_PRIORITY='0' [host] OMP_NESTED: deprecated; max-active-levels-var=1 [host] OMP_NUM_TEAMS='0' [host] OMP_NUM_THREADS='16'OPENMP DISPLAY ENVIRONMENT END
To compare the performance brought by Intel OpenMP, we take the result provided by the GNU implementation as a baseline. The training time of the CNN model using the CIFAR-10 dataset was reduced from 114 seconds to 102 seconds, resulting in a performance improvement of around 11%. Even though this is not as impressive as the first experiment, the performance gain is still interesting. In addition, note that we can get better results by using other models, datasets, and computing environments.
To summarize, we executed the training process almost 1.7 times faster with the configurations shown in this section. No code modification was necessary to achieve such improvement; only direct configurations were applied at the environment level.
In the next section, we will learn how to install and use an API provided by Intel to accelerate PyTorch’s execution on its processors.
Bookmark
Optimizing Intel CPU with IPEX
Section titled “Optimizing Intel CPU with IPEX”IPEX stands for Intel extension for PyTorch and is a set of libraries and tools provided by Intel to accelerate the training and inference of machine learning models.
IPEX is a clear sign by Intel of highlighting the relevance of PyTorch among machine learning frameworks. After all, Intel has invested a lot of energy and resources in designing and maintaining an API specially created for PyTorch.
It is interesting to say that IPEX strongly relies on libraries provided by the Intel oneAPI toolset. oneAPI contains libraries and tools specific for machine learning applications, such as oneDNN, and other ones to accelerate applications, such as oneTBB, in general.
Important note
The complete code shown in this section is available at https://github.com/PacktPublishing/Accelerate-Model-Training-with-PyTorch-2.X/blob/main/code/chapter04/baseline-densenet121_cifar10.ipynb and https://github.com/PacktPublishing/Accelerate-Model-Training-with-PyTorch-2.X/blob/main/code/chapter04/ipex-densenet121_cifar10.ipynb.
Let’s learn how to install and use IPEX on our PyTorch code.
Using IPEX
Section titled “Using IPEX”IPEX does not come with PyTorch by default; we need to install it. The easiest way to install IPEX is by using PIP along the same lines we followed for OpenMP in the last section. So, to install IPEX on a PIP environment, we just need to execute the following command:
pip install intel_extension_for_pytorchAfter installing IPEX, we can proceed to the default installation of PyTorch. Once IPEX is available, we are ready to incorporate it into our PyTorch code. The first step concerns importing the IPEX module:
import intel_extension_for_pytorch as ipexUsing IPEX is very simple. We just need to wrap our model and optimizer with the ipex.optimize function and let IPEX do the rest. The ipex.optimize function returns an optimized version of the model and optimizer (SGD, Adam, and so on) used to train the model.
To see the performance improvement provided by IPEX, let’s test it with the DenseNet121 model and the CIFAR-10 dataset (we introduced both of these in previous chapters).
Our baseline execution concerns training DenseNet121 with the CIFAR-10 dataset over 10 epochs. For the sake of fairness, we have used Intel OpenMP since we are using an Intel-based environment. However, in this case, we do not change the KMP_BLOCKTIME parameter:
import osos.environ['OMP_NUM_THREADS'] = "16"os.environ[‘KMP_AFFINITY’] = “granularity=fine,compact,1,0”
The baseline execution took 1,318 seconds to complete 10 epochs, and the resultant model obtained an accuracy of approximately 70%.
As stated before, using IPEX is very simple; we just need to add one single line to the baseline code:
model, optimizer = ipex.optimize(model, optimizer=optimizer)
Although ipex.optimize accepts other parameters, calling it in this way is usually enough to get what we need.
Our IPEX code took 946 seconds to execute the training process of the DenseNet121 model, representing a performance improvement of nearly 40%. Except for the environment variables configured at the beginning of the code and the usage of that single line, nothing else was changed in the original code. Thus, IPEX accelerated the training process with just one simple modification.
At first sight, IPEX seems similar to the Compile API that we learned about in Chapter 3, Compiling the Model. Both of them require adding a single line of code and using the concept of code wrapping. However, the similarities stop there! Unlike the Compile API, IPEX does not compile the model; it replaces some default PyTorch operations with its own implementation.
Follow me to the next section to understand how IPEX works under the hood.
How does IPEX work under the hood?
Section titled “How does IPEX work under the hood?”To understand how IPEX works under the hood, let’s profile the baseline code to check which operations the training process has used. The following output shows the 10 most consuming operations executed by the training process:
aten::convolution_backward: 27.01%aten::mkldnn_convolution: 12.44% aten::native_batch_norm_backward: 8.85% aten::native_batch_norm: 7.06% Optimizer.step#Adam.step: 6.80% aten::add_: 3.75% aten::threshold_backward: 3.21% aten::add: 2.75% aten::mul_: 2.45% aten::div: 2.19%
Our baseline code for DenseNet121 and CIFAR-10 executed those operations commonly employed on convolutional neural networks, such as convolution_backward. No surprise here.
Let’s see the profiling output of the IPEX code to verify what changes IPEX has made to our baseline code:
torch_ipex::convolution_backward: 32.76%torch_ipex::convolution_forward_impl: 13.22% aten::native_batch_norm: 7.98% aten::native_batch_norm_backward: 7.08% aten::threshold_backward: 4.40% aten::add_: 3.92% torch_ipex::adam_fused_step: 3.14% torch_ipex::cat_out_cpu: 2.39% aten::empty: 2.18% aten::clamp_min_: 1.48%
The first thing to notice is the new prefix used on some operations. Besides aten, which denotes the default PyTorch operations library, we also have the torch_ipex prefix. The torch_ipex prefix indicates the operations provided by IPEX. For example, the baseline code used the convolution_backward operation provided by aten, whereas the optimized code used the operation provided by IPEX.
As you can observe, IPEX did not replace every single operation since it does not have an optimized version of all aten operations. This behavior is expected because some operations are already in their most optimized form. In this case, it does not make any sense to try to optimize what is already optimized.
Figure 4*.5* summarizes the difference between the default PyTorch code and the optimized versions by IPEX and the Compile API:

Figure 4.5 – Differences between the default and optimized code generated by IPEX and the Compile API
Unlike the Compile API, IPEX does not create a monolithic piece of compiled code. As a result, the optimization process via ipex.optimize execution is much faster. On the other hand, the compiled code tends to deliver better performance, as we discussed in detail in Chapter 3, Compiling the Model.
Important note
It is interesting to say that we can use IPEX as a compiler backend for the Compile API. In doing this, the torch.compile function will rely on IPEX to compile the model.
As IPEX shows the great gamble made by Intel on PyTorch, it is constantly evolving and receiving frequent updates. Therefore, it is important to use the latest version of this tool to get the newest improvements.
The next section provides some questions to help you retain what you have learned in this chapter.
Bookmark
Quiz time!
Section titled “Quiz time!”Let’s review what we have learned in this chapter by answering a few questions. At first, try to answer these questions without consulting the material.
Important note
The answers to all these questions are available at https://github.com/PacktPublishing/Accelerate-Model-Training-with-PyTorch-2.X/blob/main/quiz/chapter04-answers.md.
Before starting the quiz, remember that it is not a test at all! This section aims to complement your learning process by revising and consolidating the content covered in this chapter.
Choose the correct option for the following questions.
- A multicore system can have the following two types of computing cores:
- Physical and active. 2. Physical and digital. 3. Physical and logical. 4. Physical and vectorial.
- A set of threads created by the same process…
- May share the same memory address space. 2. Do not share the same memory address space. 3. Is impossible in modern systems. 4. Do share the same memory address space.
- Which of the following environment variables can be used to set the number of threads used by OpenMP?
OMP_NUM_PROCS. 2.OMP_NUM_THREADS. 3.OMP_NUMBER_OF_THREADS. 4.OMP_N_THREADS.
- In a multicore system, the usage of OpenMP is able to improve the performance of the training process because it can…
- Allocate the process to the main memory. 2. Bind threads to logical cores. 3. Bind threads to physical cores. 4. Avoid the usage of cache memory.
- Concerning the implementation of OpenMP through Intel and GNU, we can assert that…
- There is no difference between the performance obtained by both versions. 2. The Intel version can outperform GNU’s implementation when running on Intel platforms. 3. The Intel version never outperforms GNU’s implementation when running on Intel platforms. 4. The GNU version is always faster than Intel OpenMP, regardless of the hardware platform.
- IPEX stands for Intel extension for PyTorch and is defined as…
- A set of low-level hardware instructions. 2. A set of code examples. 3. A set of libraries and tools. 4. A set of documents.
- What is the strategy adopted by IPEX to accelerate the training process?
- IPEX enables the usage of special hardware instructions. 2. IPEX replaces all the training process operations with an optimized version. 3. IPEX fuses all operations of the training process into a monolithic piece of code. 4. IPEX replaces some of the default PyTorch operations of the training process with its own optimized implementations.
- What is necessary to change in our original PyTorch code to use IPEX?
- Nothing at all.
2. We just need to import the IPEX module.
3. We need to import the IPEX module and wrap the model with the
ipex.optimize()method. 4. We just need to use the newest PyTorch version.
- Nothing at all.
2. We just need to import the IPEX module.
3. We need to import the IPEX module and wrap the model with the
Let’s summarize what we’ve covered so far.