Convolutional neural network model inference on processing units

End-to-end optimization techniques for CNN models on CPUs, focusing on data layout management and multi-threading, address the inefficiencies of existing frameworks, achieving significant performance improvements.

US12817622B1Active Publication Date: 2026-12-01AMAZON TECH INC
View PDF 9 Cites 0 Cited by

Patent Information

Application Number
US16/054152
Authority / Receiving Office
US · United States
Patent Type
Patents(United States)
Current Assignee / Owner
Filing Date
2018-08-03
Publication Date
2026-12-01
Estimated Expiration
2041-12-18

AI Technical Summary

Technical Problem

Existing deep learning frameworks face challenges in optimizing Convolutional Neural Network (CNN) model workloads across various hardware targets due to the need for non-trivial engineering efforts and incompatibility issues with chip vendor libraries, leading to suboptimal computational resource utilization.

Method used

Implementing end-to-end optimization techniques for CNN models on CPUs, including operation-level and model-level optimizations such as data layout management, multi-threading parallelization, and global search schemes to minimize execution time and resource contention.

Benefits of technology

Improves CNN model inference performance by up to 2.1 times compared to existing methods, enhancing computational throughput and efficiency on CPUs.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure US12817622-D00000_ABST
    Figure US12817622-D00000_ABST
Patent Text Reader

Abstract

A framework providing end-to-end optimization for deep learning, utilizing one or more of the following techniques: managing the data layout of computationally-intensive operations such as convolution (CONV) to run efficiently on processors such as computer processing units (CPUs); determining an efficient data layout in different operations to improve operation performance and minimize data layout transformation overhead; and implementing a scalable thread pool to statically schedule multi-thread parallelization.
Need to check novelty before this filing date? Find Prior Art

Description

BACKGROUND

[0001] As convolutional neural network (CNN) becomes a widespread machine learning approach for many real-world applications, there is a greater need to deploy CNN models across various types of computer hardware targets for inference use. However, CNN model workloads are often computationally demanding and difficult to optimize over a wide range of use cases. Existing deep learning frameworks typically rely on chip vendors to produce software such as Intel® Math Kernel Library for Deep Neural Networks (MKLDNN) to optimize performance. However, this approach has several drawbacks—first, incorporating a chip vendor library to a deep learning framework may require non-trivial engineering efforts that are error-prone, and second, libraries provided by chip vendors may not be compatible with existing settings, making it even more difficult to optimize the use of computational resource in deep learning.BRIEF DESCRIPTION OF THE DRAWINGS

[0002] Various techniques will be described with reference to the drawings, in which:

[0003] FIG. 1 illustrates a system in which one embodiment may be practiced;

[0004] FIG. 2 illustrates a system for end-to-end optimization for CNN model inference, in accordance with an embodiment;

[0005] FIG. 3 illustrates a diagram in which graph level layout optimizations are utilized to improve the end-to-end computational performance of CNN model inference, in accordance with an embodiment;

[0006] FIG. 4 illustrates a system for an optimization scheme search, in accordance with one embodiment;

[0007] FIG. 5 is a diagram illustrating end-to-end performance of optimization techniques described herein compared with a baseline obtained from MXNet with MKLDNN enabled, in accordance with one embodiment;

[0008] FIG. 6 shows an illustrative example of a process for generating a machine learning model, in accordance with an embodiment; and

[0009] FIG. 7 illustrates a system in which various embodiments can be implemented.DETAILED DESCRIPTION

[0010] In an embodiment, techniques described herein are utilized to implement systems and methods for end-to-end optimization of Convolutional Neural Network (CNN) models for efficient inference on central processing units (CPUs). In an embodiment, the optimization includes operation-level and model-level optimizations—operation-level optimizations include optimizations of the most computationally intensive operations such as convolution (CONV) by arranging the data layout to be computing-friendly on the CPU architecture in use and implementing multi-threading parallelization with minimal overhead and contention for resources between different threads.

[0011] In an embodiment, the performance of running a Convolutional Neural Network (CNN) model is improved by using various techniques described herein to: manage the data layout of the computationally-intensive operations in the CNN models, namely CONV operations, to run efficiently on CPUs; utilize local and / or global search schemes to determine data layout combinations in different operations that reduces the overall execution time, accounting for overhead from data layout transformations; utilize scalable thread pool to statically schedule multi-thread parallelization of computational work with minimal overhead; and combinations thereof.

[0012] In an embodiment, the performance of CONV operations is affected by the data layout used for the CONV operation. The data layout, in an embodiment, is selected based on a memory management scheme, as described in greater detail below. In an embodiment, a CONV operation takes, as inputs, a multi-dimensional tensor and a number of multi-dimensional kernels as inputs to convolve, thereby generating, as an output another multi-dimensional tensor having the same dimensions as the input tensor. In an embodiment, the CONV operation takes as inputs a 3D tensor and a number of 3D kernels to convolve to output a 3D tensor. In an embodiment, a CONV operation comprises an ordered sequence of multiplication and accumulation operations. In an embodiment, the notation NCHW is used to describe the default data layout, which means the input and output are 4-D tensors of (batch_size N, number of channels C, feature map height H, feature map width W). In an embodiment, the related layout of kernel is OIHW, in which O and I stand for the output and input channels, respectively, feature map height H, feature map width W.

[0013] In an embodiment, the CPU supports the vectorized FMA operation. In an embodiment, to generate consecutive in-register FMA instructions, the out_width dimension is split out to two loops (ow_outer and ow_inner), unroll ow_inner, and explicitly load data to local variables. In an embodiment, the unrolled multiply-accumulate operations in ow_outer are loop-invariant, and compilers (e.g., LLVM) can safely promote them into registers. In an embodiment, the calculation requires one extra register for storing related kernel data. In an embodiment according to AVX-512, 31 ZMM registers are used for input data and the size of ow_inner is less than or equal to 31. In an embodiment, the kernel layout is re-arranged to a six-dimensional tensor OIHW[x]i[y]o, in which i with split size x is the sub-dimension of input channel I, and o with split size y is the sub-dimension of output channel O. In an embodiment, with input data layout NCHW32c and output data layout NCHW16c, the related kernel data layout will be OIHW32i16o. Accordingly, in an embodiment, the input and output data layout is optimized by one or more of: splitting one or more reduction axes (e.g., in_channel) to accelerate memory access; and applying SIMD vectorization over one or more sub-dimension (e.g., out_channel) to accelerate multiply-accumulate operations.

[0014] In an embodiment, as part of a local search optimization, candidate data layouts for the individual computationally-intensive operations are determined, and in the second stage, a global optimization scheme is selected to combine the individual candidate schemes for the optimal end-to-end results. In an embodiment, the first stage is referred to as a local search optimization and the second stage is referred to as a global search optimization.

[0015] In an embodiment, the local search optimization comprises determining schedules (i.e., data layouts) for some or all operations of a CNN model inference. In an embodiment, schedules are determined for each operation. In an embodiment, schedules are determined for each computationally-intensive operations (e.g., CONVs) in a CNN model. In an embodiment, a set of parameters [ic_bn, oc_bn, reg_n, unroll_kw] represent a convolution schedule, wherein ic_bn and oc_bn stand for the splitting factor for input and output channels (e.g., x in the NCHW[x]c notation), reg_n is the number of SIMD registers to be used, unroll_kw is a boolean deciding whether to unroll the convolution kernel width for loop computation. In an embodiment, as part of the local search optimization, different combinations of parameters values are evaluated to determine their respective CONV execution times.

[0016] In an embodiment, the local search optimization can determine, for each operation, the minimum execution time for an individual operation, thereby minimizing the local cost of performing a particular operation. However, greedily adopting the local optimal of every operation (e.g., a greedy algorithm) may not result in the global optimal solution. Consider two consecutive CONV operations CONV0 and CONV1, if the output splitting factor (oc_bn) of CONV0 is different from the input splitting factor (ic_bn) of CONV1, a LayoutTransform node needs to be inserted to the graph due to the data layouts between CONV0 and CONV1 being different. As a result of this transformation overhead, it can be too expensive to take advantage of the benefit brought by the local optimal, especially when the input size of the network is large. On the other hand, if the same splitting factor is maintained throughout the entire network, then some CONV layers may not be optimized. In an embodiment, a global search optimization is performed to determine the minimum end-to-end execution time by formalizing the problem (e.g., minimizing execution time for a set of candidate data layouts for each operation of a set of operations for a CNN model inference) into Markov Decision Process (MDP) and solved using the Bellman optimality equation. Minimizing the end-to-end execution time may be referred to as minimizing the cost of the operations of a CNN model inference. The cost, in an embodiment, refers to the computational cost or execution time for performing one or more operations, which may include performing a layout transformation between incompatible data formats.

[0017] In an embodiment, multi-threaded work is allocated and executed using a custom thread pool that uses C++ 11 atomics to coordinate threads during fork / join and uses a lock-free queue to manage assigning tasks to the worker threads. In an embodiment, the custom thread pool guarantees that active threads run on disjoint physical cores via thread binding to minimize hardware contention. In an embodiment, no hyper-threading is used by the thread pool to allocate worker threads.

[0018] In the preceding and following description, various techniques are described. For purposes of explanation, specific configurations and details are set forth in order to provide a thorough understanding of possible ways of implementing the techniques. However, it will also be apparent that the techniques described below may be practiced in different configurations without the specific details. Furthermore, well-known features may be omitted or simplified to avoid obscuring the techniques being described.

[0019] As one skilled in the art will appreciate in light of this disclosure, certain embodiments may be capable of achieving certain advantages, including some or all of the following: improving the operation of a computer system by increasing efficiency and / or computational throughput for generating machine learning models such as CNN models.

[0020] In an embodiment, FIG. 1 illustrates a diagram of a system 100 in which an embodiment in accordance with this disclosure can be implemented. In an embodiment, the system 100 includes a computing system 102 comprising a central processing unit (CPU) for running a machine learning model such as a convolutional neural network (CNN) model inference. In an embodiment, the computing system 102 comprises a CPU 104, registers 106 (e.g., vector registers for SIMD instructions). In an embodiment, the computer system 102 includes additional components not illustrated in FIG. 1 such as main memory (e.g., DRAM). Convolutional Neural Network (CNN) is a machine learning approach to real-world applications such as image recognition. In an embodiment, a modern central processing unit uses thread-level parallelism via multi-core to improve the overall processor performance given the diminishing increasing of transistor budgets to build larger and more complex uniprocessor. In an embodiment, a CPU incorporates multiple physical cores that share a last level cache (LLC) and access the main memory symmetrically. In an embodiment, techniques to improve the efficiency of CPUs include reducing interference among threads running on the same processor and minimize their synchronization cost in order to have improved scalable performance on multi-core processors.

[0021] In an embodiment, a single physical core achieves the peak performance using a single-instruction-multiple-data (SIMD) technique that comprises loads multiple values into a wide vector register to process together. In an embodiment, each core of a CPU 104 has two vector processing units (VPUs) which support the 512-bit Advanced Vector Extension instruction set (AVX-512) that is capable of handling up to 16 32-bit single precision floating point numbers (totally 512 bits) per CPU cycle. In addition, it can utilize the Fused-Multiply-Add (FMA) instruction which executes one vectorized multiplication and then accumulates the results to another vector register in the same CPU cycle, in an embodiment.

[0022] In an embodiment, the CPU supports hyper-threading via the simultaneous multithreading (SMT) technique, in which the system could assign two virtual cores (e.g., two threads) to one physical core, aiming at improving the parallelization. In an embodiment, performance improvements of hyper-threading may be application-dependent. In an embodiment, a CPU described herein supports hyper-threading but does not use hyper-threading to perform CNN model inferences. In an embodiment, a CPU described herein fully utilizes its physical core resource, obviating various benefits of hyper-threading at least because adding one more thread to the same physical core could decrease computational performance due to additional context switches. In an embodiment, techniques described herein may be utilized with CPUs according to both x86 and ARM architectures.

[0023] Convolutional neural networks (CNNs) are used in computer vision workloads. In an embodiment, a CNN model is abstracted as a directed acyclic graph (DAG), in which a node represents an operation and a directed edge pointing from node A to B represents that the output of operation A serves as (part of) the input of operation B (i.e., B cannot be executed before A). In an embodiment, a model inference execution is to flow the input data through the graph to get the output. In an embodiment, performing optimization on the graph (e.g. prune unnecessary nodes and edges, pre-compute constant values) results in better model inference performance.

[0024] The most computationally-intensive nodes in a CNN model graph are convolution (CONV) and general-purpose matrix multiplication (GEMM), which consumes ~90% of total floating point operations per second (FLOPs), in an embodiment. Both operations include a series of multiplication and accumulation, which, in an embodiment, fully utilize the parallelization, vectorization and FMA features of modern CPUs.

[0025] In an embodiment, FIG. 1 illustrates a default 108 data layout for generating a CNN model. In an embodiment, the default data layout is determined based on the input data format (e.g., as provided by a data source) and is propagated through downstream operations. In an embodiment, FIG. 1 illustrates an altered 110 data layout that is determined by changing the data layout of operator nodes according to various techniques such as those described elsewhere in connection with FIG. 6. In an embodiment, the system performs a two-step process to change the input and / or output data formats some or all operations. In an embodiment, FIG. 1 illustrates an altered data layout that is optimized by determining, for each operation, a plurality of candidate data layouts and selecting a corresponding data layout for each operation such that the overall execution time is minimized, accounting for additional overhead introduced by layout transformations. In an embodiment, a layout transformation refers to one or more operations that convert data (e.g., input or output data) from one format to another. In an embodiment, the format refers to a multi-dimensional tensors and converting data from one format to another includes splitting a dimension of the original data format. In an embodiment, the original data format is a 4D tensor defined as a data layout NHWC and NCHW[x]c defines an altered data layout in which c is a split sub-dimension of channel C, and the number x indicates the size of the sub-dimension.

[0026] In an embodiment, a data layout is chosen for the input data of these operations to achieve improved computational performance. In an embodiment, other operations of the CNN workloads are memory-bound operations (e.g. batch normalization, pooling, activation, element-wise addition, etc.) This would, in an embodiment, increase the overall throughput (e.g., arithmetic intensity) of the workload so as to boost the performance. In an embodiment, techniques described herein are used to fuse the operations in a data layout optimized for CONV and GEMM so that at least those operations can be kept in a common data layout throughout the entire inference or a substantial portion thereof.

[0027] In an embodiment, FIG. 2 illustrates a system 200 for end-to-end optimization for CNN model inference, in accordance with an embodiment. In an embodiment, one or more optimizations described herein are applicable to Intel CPU as well as to other CPUs. In an embodiment, one or more of the principles are used to guide the optimization(s): first, arranging the data layout for computation to reduce the cache misses, thereby allowing for continuous memory access and facilitate vectorization; second, making use of vectorized registers (e.g. AVX-512 and AVX2 registers) for vectorization to improve computational throughput; third, reducing or eliminating contentions between different threads on computing resource, thread-shared data, etc.; and fourth, reducing or minimizing the overhead brought by any proposed optimization ideas.

[0028] In an embodiment, a Neural Network Virtual Machine / TVM (NNVM / TVM) framework is used as a starting point and optimizations are implemented by adding a number of new features to the compiling pass, operation scheduling and runtime components. The original NNVM / TVM framework has general graph-level optimizations including operation fusion, pre-computing, simplifying inference for batch-norm and dropout, which, in an embodiment, is inherited to various implementations described in this disclosure.

[0029] As discussed above, in an embodiment, a substantial portion (e.g., greater than 90%) of the computation in a CNN workload is attributable to CONV and GEMM operations. Therefore, having them optimized, in an embodiment, is to the overall performance.

[0030] In an embodiment, a CONV operation is optimized using a layout transformation, as illustrated and discussed in connection with FIG. 2 and in accordance with at least one embodiment. In an embodiment, the operation optimization is applied to a GEMM operation using the techniques described.

[0031] In an embodiment, the performance of CONV operations is affected by the data layout used for the CONV operation. The data layout, in an embodiment, is selected based on a memory management scheme, as described in greater detail below. In an embodiment, a CONV operation takes, as inputs, a multi-dimensional tensor and a number of multi-dimensional kernels as inputs to convolve, thereby generating, as an output another multi-dimensional tensor having the same dimensions as the input tensor. In an embodiment, the CONV operation takes as inputs a 3D tensor and a number of 3D kernels to convolve to output a 3D tensor. In an embodiment, a CONV operation comprises an ordered sequence of multiplication and accumulation operations. FIG. 2 illustrates, in an embodiment, a calculation, which implies loops of 6 dimensions: in_channel, kernel_height, kernel_width, out_channel, out height and out_width. In an embodiment, each kernel slides over the input tensor, does elementwise product and accumulates them to produce the corresponding element in the output tensor. In an embodiment, the number of kernels forms the out_channel. In an embodiment, one or more of the dimensions (e.g., in_channel, kernel_height and kernel_width) are reduction axes that cannot be parallelized.

[0032] In an embodiment, the notation NCHW is used to describe the default data layout, which means the input and output are 4-D tensors of (batch_size N, number of channels C, feature map height H, feature map width W). In an embodiment, the related layout of kernel is OIHW, in which O and I stand for the output and input channels, respectively, feature map height H, feature map width W.

[0033] In an embodiment, a CONV operation requires accumulation across the input channel, one way of doing so is to have this loop at the innermost so that no extra memory access takes place. In an embodiment, a NHWC data layout can leverage memory locality of L1 / L2 cache of the CPU.

[0034] In an embodiment, the input channel of a NHWC data lay out is too large to fit into a cache line. In an embodiment, the cache line of a CPU has a size of 32 or 64 bytes. In an embodiment, NCHW[x]c defines a data layout in which c is a split sub-dimension of channel C, and the number x indicates the size of the sub-dimension. In an embodiment, x is chosen from 32, 16 and 8, which can be divided by most convolution neural network workloads with channel size of 64, 128, 256, etc. In an embodiment, the number of kernels is a multiple of 64. In an embodiment, other sizes can be used, the sizes being determined based on different factors such as the specific workload.

[0035] In an embodiment, the output has the same layout NCHW[y]c as the input, while the split size can be different. Unlike the input channel, the output channel is no longer a reduction axis and, in an embodiment, can be parallelized. Therefore, in an embodiment, out_channel is split based on the width of the single-instruction-multiple-data (SIMD) register. In an embodiment, SIMD registers have a width of 512 bits (e.g., 16 float32) for AVX-512 and 256 bits (e.g., 8 float32) for AVX2. In an embodiment, a loop is reorder to the innermost and explicitly do vectorization.

[0036] In an embodiment, the CPU supports the vectorized FMA operation. In an embodiment, Intel AVX-512 supports 32 512-bit width ZMM vector registers. In an embodiment, other than loading into one register, doing FMA and storing back to DRAM for every 16 output channels, an alternative techniques is to load data into these 32 ZMM registers in a batch so that with consecutive 32 FMA instructions-accordingly, the CPU avoids wasting cycles to access cache / memory during the calculation.

[0037] In an embodiment, to generate consecutive in-register FMA instructions, the out_width dimension is split out to two loops (ow_outer and ow_inner), unroll ow_inner, and explicitly load data to local variables. In an embodiment, the unrolled multiply-accumulate operations in ow_outer are loop-invariant, and compilers (e.g., LLVM) can safely promote them into registers. In an embodiment, the calculation requires one extra register for storing related kernel data. In an embodiment according to AVX-512, 31 ZMM registers are used for input data and the size of ow_inner is less than or equal to 31.

[0038] In an embodiment, the kernel layout is re-arranged to a six-dimensional tensor OIHW[x]i[y]o, in which i with split size x is the sub-dimension of input channel I, and o with split size y is the sub-dimension of output channel O. In an embodiment, with input data layout NCHW32c and output data layout NCHW16c, the related kernel data layout will be OIHW32i16o.

[0039] Accordingly, in an embodiment, the input and output data layout is optimized by one or more of: splitting one or more reduction axes (e.g., in_channel) to accelerate memory access; and applying SIMD vectorization over one or more sub-dimension (e.g., out_channel) to accelerate multiply-accumulate operations.

[0040] In an embodiment, optimizations are made within operations performed in a single thread as well as to parallelization of work across multiple threads (e.g., operations are parallelized across multiple CPU cores). In principle, an ideal N-way parallelization should partition work into independent N pieces and have each of them finished at the same time, making the total execution time 1 / N of the sequential case.

[0041] In an embodiment, work within an operation is parallelized. In a system of N physical cores, according to one embodiment, the outer-most loop of the operation is divided into N pieces to assign to N threads and a fork-join mechanism is used to coordinate the threads. It should be noted that this type of parallelization is non-trivial to implement efficiently. For example, introducing OpenMP pragmas before the for loop could easily parallelize it, but the resulting scalability is not so desirable according based on empirical data collected.

[0042] In an embodiment, multi-threaded work is allocated and executed using a custom thread pool that uses C++ 11 atomics to coordinate threads during fork / join and uses a lock-free queue to manage assigning tasks to the worker threads. In an embodiment, the custom thread pool guarantees that active threads run on disjoint physical cores via thread binding to minimize hardware contention. In an embodiment, no hyper-threading is used, as discussed above in connection with FIG. 1. In an embodiment, different working threads perform computations on different portions of the data, thereby limiting or eliminating data contention. For the global data structure accessed by multiple threads such as the local-free queue, we inserted cache line padding as needed to avoid false sharing between threads.

[0043] FIG. 3 illustrates a diagram 300 in which graph level layout optimizations are utilized to improve the end-to-end computational performance of CNN model inference, in an embodiment. In an embodiment, during an inference, a user inputs data in a default format (e.g., NCHW or NHWC) and expects the output to be returned in the same format. Thus, while NCHW[x]c is efficient for CONV operations, in an embodiment, there is an associated layout transformation overhead that is considered in determining how to optimize the CNN model inference. Accordingly, a naive implementation in which each CONV operator first transforms the layouts of input data and transforms back at the end so that the next layer can receive the input in the expected data layout actually results in degraded performance, in an embodiment, at least because the overhead of the layout transformation operations negates any benefit realized from the more efficient data layout for CONV operations.

[0044] In an embodiment, end-to-end optimization for CNN model inference includes determining one or more appropriate data layout that reduces overall execution time. In an embodiment, the data layout definition is composed of upper cases, lower cases and numbers, where upper case indicates a (super-) dimension and the corresponding lower case with factor size indicates the split (sub-) dimension. In an embodiment, NCHW16c describes a 5-D tensor of (batch_size, channel, height, width, channel_block), in which sub-dimension channel block=16 is the split of super-dimension C (channel). Given the layout convention, in an embodiment, techniques described in greater detail below can be used to transform between two arbitrary layouts as long as they have a same set of super-dimensions. In an embodiment, NCHW, NCHW16c, NCHW7c, NHWC, etc., can be transformed between each other.

[0045] In an embodiment, a computation graph of a CNN model is processed in multiple rounds. In an embodiment, multiple graph-traversing passes are applied to the graph, each of which brings a specific optimization. In an embodiment, to infer and correct the data layouts, a CorrectLayout pass visits graph nodes in Depth-First-Search (DFS) order and checks the data layout produced by its ancestor—if it is different from what the current node requests, a layout-transformer node is inserted. After the pass, the input and output data layout of each node is obtained, in an embodiment. The left portion of FIG. 3 illustrates, according to an embodiment, the inferred layouts of a simplified convolutional neural network.

[0046] In an embodiment, a second pass called AlterOpLayout is used to change the data layout of operator nodes. In an embodiment, users can register a callback function for each node. In an embodiment, the optimal layout differs by different data shapes and types, which is discussed in greater detail in connection with FIG. 6.

[0047] In an embodiment, operations are classified into one of three categories according to how they react to altered data layouts as follows:

[0048] Layout-mutable operators: These operators produce the same output layout as the input without being aware of the layout. Unary operators like ReLU, Soft-max, etc., fall in this category.

[0049] Layout-semimutable operators: Implementations of these operators can handle a class of input layouts, while it has to know what the layout is to choose the right implement. For example, CONV, in our case, can deal with NCHW, NHWC and NCHW[x]c layouts. Other operators like Batch Norm, Pooling, etc., fall in this category as well.

[0050] Layout-immutable operators: These operators cannot produce correct results with a different layout, which means the layout has to be transformed back to the original one before passing to a layout-immutable operator. Transformation operators like Flatten, Reshape, etc., fall in this category. Note that a layout-immutable operator can always become layout-semimutable by implementing the layout transforming itself.

[0051] In an embodiment, various CNN models—including VGG, Inception, and Resnet—have limited operations between CONV layers. In an embodiment, for NCHW[x]c, we evaluate the data transformation of the operations below, wherein x refers to a split of a super-dimension. In an embodiment, the following operations are considered:

[0052] Pooling calculates the max (MAX_POOL) or average (AVG_POOL) value across the input width and height dimension. If the layout is altered from NCHW to NCHW[x]c, nothing need to be changed except for reducing three dimensions (N, C and c) instead of two (N, C).

[0053] Batch_Norm normalizes across the input channel dimension. If the input layout is altered from NCHW to NCHW[x]c, layouts of its parameters (mean and variance) need to be transformed from C to C[x]c. As we will describe later, this can be pre-computed during compile time, in an embodiment.

[0054] Activation such as ReLU and Softmax is layout-mutable which supports NCHW[x]c automatically.

[0055] Concat and Elementwise_Add are layout-mutable as long as the input layouts are the same, in an embodiment.

[0056] In an embodiment, no operator between any two CONV layers is layout-immutable and the NCHW[x]c data layout can flow from one to another. Layout transforming from NCHW to NCHW[x]c, in an embodiment, only happens at the first CONV later and can flow through each CONV layer. In an embodiment, at the first layout-immutable operator (e.g. Flatten), a layout transformation is inserted to transform NCHW[x]c to NCHW. Thus after the second pass of CorrectLayout, the input and output for the network is still in the NCHW data layout, but the internal data layouts between CONV layers are optimized NCHW[x]c, as illustrated on the right side of FIG. 3.

[0057] In an embodiment, the kernel data layout can be pre-transformed for inference. In an embodiment, the layout transformation from OIHW to OIHW[x]i[y] o can be computed during compile time, so as the mean and variance of Batch Norm.

[0058] In an embodiment one or more optimizations reduce / eliminate kernel layout transforming and keep transformed data layout invariant between CONV layers, thereby improving end-to-end performance.

[0059] FIG. 4 illustrates a system 400 for an optimization scheme search, in accordance with one embodiment. The computer system 400, in an embodiment, is used to implement a process to determine an optimization scheme search that improves end-to-end performance of CNN model inference. In an embodiment, the scheme search is performed in two stages—in the first stage, local optimization scheme candidates for the individual computationally-intensive operations are determined, and in the second stage, a global optimization scheme is selected to combine the individual candidate schemes for the optimal end-to-end results. In an embodiment, the first stage is referred to as a local search optimization and the second stage is referred to as a global search optimization.

[0060] In an embodiment, the local search optimization comprises determining schedules for some or all operations of a CNN model inference. In an embodiment, schedules are determined for each operation. In an embodiment, schedules are determined for each computationally-intensive operations (e.g., CONVs and GEMMs) in a CNN model. In an embodiment, a set of parameters [ic_bn, oc_bn, reg_n, unroll_kw] represent a convolution schedule, wherein ic_bn and oc_bn stand for the splitting factor for input and output channels (e.g., x in the NCHW[x]c notation), reg_n is the number of SIMD registers to be used, unroll_kw is a boolean deciding whether to unroll the convolution kernel width for loop computation. In an embodiment, as part of the local search optimization, different combinations of parameters values are evaluated to determine their respective CONV execution times.

[0061] In an embodiment, a process to perform a local search optimization includes defining candidate lists of ic_bn and oc_bn. To exhaust the searching space, factors of the number of channels are included. If the channel is 64, [32, 16, 8, 4, 2, 1] are listed as the candidate channel values, in an embodiment. The process, in an embodiment, further includes determining the candidate list of reg_n values. In an embodiment, simply utilizing all SIMD registers does not achieve optimal performance (e.g., one or more register are reserved for storing related kernel data). In an embodiment, the reg_n candidate list includes [2, 4, 8, 16, 32] or factors of two up to the total number of SIMD registers.

[0062] In an embodiment, the candidate list of unroll_kw includes [True, False] to indicate whether to unroll the convolution kernel width for loop computation.

[0063] In an embodiment, the process further comprises walking through the space of candidate schedules to find the optimal combination leading to the shortest execution time. In an embodiment, the selection of candidate schedules is determined based on other factors, such as selecting the first candidate schedule having an execution time below a threshold time, selecting the best candidate schedule among N candidate schedules that are evaluated (e.g., as part of a time-bound selection process), and more.

[0064] In an embodiment, the local search optimization can determine, for each operation, the minimum execution time for an individual operation. However, greedily adopting the local optimal of every operation may not result in the global optimal. Consider two consecutive CONV operations CONV0 and CONV1, if the output splitting factor (oc_bn) of CONV0 is different from the input splitting factor (ic_bn) of CONV1, a LayoutTransform node needs to be inserted to the graph due to the data layouts between CONV0 and CONV1 being different. As a result of this transformation overhead, it can be too expensive to take advantage of the benefit brought by the local optimal, especially when the input size of the network is large. On the other hand, if the same splitting factor is maintained throughout the entire network, then some CONV layers may not be optimized. In an embodiment, a global search optimization is performed to determine the minimum end-to-end execution time.

[0065] In an embodiment, a global search optimization comprises determining the minimum execution for each CONV individually by choosing the optimal splitting factor x (e.g., ic_bn and oc_bn), and then take the corresponding data layout transformation time into consideration to determine an end-to-end execution time. In an embodiment, the operations between CONVs are either layout-mutable or layout-semimutable, so an altered data layout selected for a CONV can be propagated through operations between CONVs without additional layout transformations.

[0066] FIG. 4 illustrates a system 400 for global search optimization, in accordance with one embodiment. In an embodiment, FIG. 4 illustrates a portion of a CNN model in FIG. 3 that is to be optimized using data layout transformation techniques. FIG. 4 illustrates, in an embodiment, for a CONV, a number of candidate schemes specified by different parameter (ic_bn and oc_bn) pairs. In an embodiment, the shortest execution time achieved by each pair is obtained in using a local search optimization. The number of pairs depends on the numbers of input and output channels, which, in an embodiment, has an upper-bound limit (e.g., approximately 100). In an embodiment, choosing different schemes introduces different data transformation overheads (denoted in dashed boxes between CONVs) or no transformation (if the oc_bn of the CONV equals the ic_bn of its successor). For simplicity, in the figure the operations which do not impact the global search optimization are omitted, such as ReLU, Batch Norm between two CONVs. However, operations like Elementwise_Add are not omitted since it requires the layout of its two input operands (outputs of CONVj and CONVk in the figure) to be the same, and therefore, may require a layout transformation.

[0067] Naively speaking, if a CNN model consists of n CONVs, each of which has ki candidate data layouts, then the total number of options of the global scheme will be

[0068] ∏ i-1n⁢ki,very easy to become intractable as the number of layers n grows. However, the global search optimization can be solved in a more efficient manner using dynamic programming techniques—in an embodiment, when a candidate scheme is chosen for CONVi, the expected runtime of operations up to and including CONV; can be calculated from the runtime of the CONVi-1 and the data layout of CONV; and the inputs to CONVi (e.g., to determine whether a layout transformation is included between CONVi-1 and CONVi). In other words, in an embodiment, when choosing the scheme for a CONV, one only needs to consider the data layout of it and its direct predecessor(s) but not any other ancestor CONVs (e.g., as defined by a directed acyclic graph mapping that represents the CNN model) provided the so-far globally optimal schemes up to the predecessor(s) are memorized.

[0069] In an embodiment, when a CONV is processed, the intermediate states stored for its predecessor can be safely removed. In an embodiment, for networks with more complex structure like using Elementwise_Add to add two CONV outputs to feed to the next CONV, it is a little trickier since the schemes of a CONV may need to be saved for a future use (e.g., in FIG. 4 CONV1 needs the schemes of CONV; via Elementwise_Add).

[0070] In an embodiment, arbitrarily complicated networks where a CONV may use arbitrary number of predecessors, the problem can be formalized into Markov Decision Process (MDP) and solved using the Bellman optimality equation.

[0071] In an embodiment, the process relies upon the problem having a mathematical property of memorylessness (e.g., making decision of a CONV only depends on its predecessors but not other ancestors). In an embodiment, a candidate scheme of a CONV is defined to be a state, the data layout transformation as the action, the inverse of the summation of current CONV execution time and the transformation time as the reward (since in MDP the reward is maximized). In an embodiment, setting if a state takes an action, it will transfer to another determined state with probability 1.

[0072] In an embodiment, let Si,j denote the j-th candidate scheme in CONVi, v(s) denote the value function for the state, transform_time(Si<sub2>1< / sub2>,j<sub2>1< / sub2>, Si<sub2>2< / sub2>,j<sub2>2< / sub2>) denote the layout transformation time between two states, and execution_time(Si,j) as the execution time for the state. In an embodiment, the Bellman optimality equation for v can be expressed as:

[0073] v⁡(si,ji)=max⁢{∑i-n≤x≤i-1 (v⁡(sx,jx)+TransformTime⁡(sx,jx,si,ji))}for⁢ jx∈[0,#⁢ of⁢ states⁢ for⁢ ⁢CONVx]

[0074] In an embodiment, the algorithm to solve the Bellman optimality equation comprises performing a breadth-first-search (BFS) traverse to the network starting from all input nodes. In an embodiment, optimal value functions can be obtained directly for no-dependency CONVs, since optimal value is equal to the execution time given a candidate scheme. In an embodiment, for other CONVs, the Bellman optimality equation is followed to get optimal value functions. In an embodiment, the current CONV is checked to determine whether it has multiple output edges. If so, the current CONV is added as a dependency to all of its children. In an embodiment, adding a dependency means that children need to combine with states of dependent CONVs to generate states. In an embodiment, dependencies are eliminated when all of the predecessors is visited to reduce the total number of states. In an embodiment, the network structure can be reduced using various algorithms to approximate a solution to the Bellman optimality equation to reduce time and space (e.g., memory space).

[0075] In an embodiment, the time and memory complexity of the global search optimization process is equal to the number of states. In the worst case, all nodes in network can have large number of input nodes. In this case, total number of states would be O(n·kn), in which k is the number of candidate schemes for each stage and n is the total number of stages. However, this situation rarely happens. In an embodiment, practical neural networks have a small number of nodes can become dependencies for other nodes and, as a result, the number of states would be O(n·km), where m is a small number.

[0076] FIG. 5 is a diagram 500 illustrating end-to-end performance of optimization techniques described herein compared with a baseline obtained from MXNet with MKLDNN enabled, in accordance with one embodiment. Experiments were done on Amazon EC2 C5 instance equipped with Intel® Skylake processors C5 9xlarge nodes, which have 36 virtual cores, essentially 18 physical cores of an entire processor. In an embodiment, the optimization techniques utilized include one or more of: data layout optimization; global search optimization; and multi-threaded parallelization using a custom thread pool. In an embodiment, techniques described herein are incorporated into an end-to-end CNN model inference that has performance profile that is 2.1× faster than known techniques (e.g., MKLDNN).

[0077] FIG. 6 shows an illustrative example of a process 600 for generating a convolutional neural network (CNN) model inference, in accordance with an embodiment. Some or all of the process 600 (or any other processes described herein, or variations and / or combinations thereof) may be performed under the control of one or more computer systems configured with computer-executable instructions and may be implemented as code (e.g., computer-executable instructions, one or more computer programs, or one or more applications) executing collectively on one or more processors, by hardware, software, or combinations thereof. The code may be stored on a computer-readable storage medium, for example, in the form of a computer program comprising a plurality of computer-readable instructions executable by one or more processors. The computer-readable storage medium may be a non-transitory computer-readable medium. In some embodiments, at least some of the computer-readable instructions usable to perform the process 600 are not stored solely using transitory signals (e.g., a propagating transient electric or electromagnetic transmission). A non-transitory computer-readable medium may include non-transitory data storage circuitry (e.g., buffers, caches, and queues) within transceivers of transitory signals. In an embodiment, the process 600 is used to generate a machine learning model such as a deep learning model.

[0078] In an embodiment, a system performing the process determines 602 a set of operations for generating a convolutional neural network (CNN) model inference. In an embodiment, a CNN model is abstracted as a directed acyclic graph (DAG), in which a node represents an operation and a directed edge pointing from node A to B represents that the output of operation A serves as (part of) the input of operation B (i.e., B cannot be executed before A). In an embodiment, a model inference execution is to flow the input data through the graph to get the output. In an embodiment, performing optimization on the graph (e.g. prune unnecessary nodes and edges, pre-compute constant values) results in better model inference performance. In an embodiment, the CNN model comprises layers of CONV operations that are identified as part of the determination of the set of operations. In an embodiment, determining the set of operations includes determining dependencies between different operations (e.g., which outputs of which operations feed into inputs of other operations) which can be used in a global search optimization.

[0079] In an embodiment, the system classifies 604 operations as being layout mutable, layout-semimutable, or layout immutable. In an embodiment, a layout-mutable operation such as ReLU produces the same output data layout as the input data layout without being aware of the layout. In an embodiment, a layout-semimutable operation is implemented to handle various types of input data layouts but needs to know what the layout is to choose the right implementation. In an embodiment, a layout-immutable operation cannot produce the correct results in a different layout, meaning that the input data layout is to be in the original data layout. Data layouts, in an embodiment, can be altered by performing layout transformations.

[0080] In an embodiment, the system determines 606 candidate data layouts. In an embodiment, the system determines a plurality of candidate data layouts for each operation that comprises the CNN model. In an embodiment, the system determines a list of candidate data layouts for each layout-semimutable operation. In an embodiment, the system determines a list of candidate data layouts for each layout-semimutable and layout-mutable operation. In an embodiment, the system determines a list of candidate data layouts for an operation by selecting a set of parameters that affect the execution time for the operation including, but not limited to: a splitting factor the input and / or output channels of a multidimensional tensor; a number of registers (e.g., SIMD) registers to use; and whether to unroll a convolution kernel width for loop computation. In an embodiment, the input and output channels and the kernel width are dimensions of a multidimensional tensor. In an embodiment, candidate values for the input and output channels are factors of the number of channels (e.g., if the channel is 64, [64, 32, 16, 8, 4, 2, 1] are candidate values). In an embodiment, candidate values for the number of registers are factors of the number of SIMD registers. In an embodiment, candidate values for whether to unroll the kernel width are based on a binary value. In an embodiment, the candidate data layouts include some or all permutations of the candidate values described above.

[0081] In an embodiment the system optimizes 608 the global execution time for generating the CNN model inference, such as by utilizing techniques described above. In an embodiment, the system optimizes the execution time by minimizing the cost of generating the CNN model inference by selecting data layouts for the operations that minimizes the global execution time. In an embodiment, local search optimization and / or global search optimization schemes are utilized to optimize the execution time of generating the CNN model inference. In an embodiment, the system models the candidate data layouts of operations (e.g., CONV layers) as states of a Markov Decision Process and layout transformation costs as actions. In an embodiment, the optimization comprises formalizing a Markov Decision Process (MDP) and solving it using the Bellman optimality equation.

[0082] In an embodiment, once the optimized data layout or data layouts have been determined, the system generates 610 the CNN model inference according to the optimized data layout. In an embodiment, generating the model includes performing the set of operations that were determined according to the data layouts that were determined as part of optimizing the execution time. In an embodiment, one or more layout transformations are performed as part of generating the CNN model inference, which, in an embodiment, is required between two operations such as between two layout-semimutable operations that have different data layouts, or between an operation and a layout-immutable operation that have different data layouts.

[0083] FIG. 7 illustrates aspects of an example system 700 for implementing aspects in accordance with an embodiment. As will be appreciated, although a web-based system is used for purposes of explanation, different systems may be used, as appropriate, to implement various embodiments. In an embodiment, the system includes an electronic client device 702, which includes any appropriate device operable to send and / or receive requests, messages, or information over an appropriate network 704 and convey information back to a user of the device. Examples of such client devices include personal computers, cellular or other mobile phones, handheld messaging devices, laptop computers, tablet computers, set-top boxes, personal data assistants, embedded computer systems, electronic book readers, and the like. In an embodiment, the network includes any appropriate network, including an intranet, the Internet, a cellular network, a local area network, a satellite network or any other such network and / or combination thereof and components used for such a system depend at least in part upon the type of network and / or system selected. Many protocols and components for communicating via such a network are well known and will not be discussed herein in detail. In an embodiment, communication over the network is enabled by wired and / or wireless connections and combinations thereof. In an embodiment, the network includes the Internet and / or other publicly-addressable communications network, as the system includes a web server 706 for receiving requests and serving content in response thereto, although for other networks an alternative device serving a similar purpose could be used as would be apparent to one of ordinary skill in the art.

[0084] In an embodiment, the illustrative system includes at least one application server 708 and a data store 710 and it should be understood that there can be several application servers, layers or other elements, processes or components, which may be chained or otherwise configured, which can interact to perform tasks such as obtaining data from an appropriate data store. Servers, in an embodiment, are implemented as hardware devices, virtual computer systems, programming modules being executed on a computer system, and / or other devices configured with hardware and / or software to receive and respond to communications (e.g., web service application programming interface (API) requests) over a network. As used herein, unless otherwise stated or clear from context, the term “data store” refers to any device or combination of devices capable of storing, accessing and retrieving data, which may include any combination and number of data servers, databases, data storage devices and data storage media, in any standard, distributed, virtual or clustered system. Data stores, in an embodiment, communicate with block-level and / or object level interfaces. The application server can include any appropriate hardware, software and firmware for integrating with the data store as needed to execute aspects of one or more applications for the client device, handling some or all of the data access and business logic for an application.

[0085] In an embodiment, the application server provides access control services in cooperation with the data store and generates content including, but not limited to, text, graphics, audio, video and / or other content that is provided to a user associated with the client device by the web server in the form of HyperText Markup Language (“HTML”), Extensible Markup Language (“XML”), JavaScript, Cascading Style Sheets (“CSS”), JavaScript Object Notation (JSON), and / or another appropriate client-side or other structured language. Content transferred to a client device, in an embodiment, is processed by the client device to provide the content in one or more forms including, but not limited to, forms that are perceptible to the user audibly, visually and / or through other senses. The handling of all requests and responses, as well as the delivery of content between the client device 702 and the application server 708, in an embodiment, is handled by the web server using PHP: Hypertext Preprocessor (“PHP”), Python, Ruby, Perl, Java, HTML, XML, JSON, and / or another appropriate server-side structured language in this example. In an embodiment, operations described herein as being performed by a single device are performed collectively by multiple devices that form a distributed and / or virtual system.

[0086] The data store 710, in an embodiment, includes several separate data tables, databases, data documents, dynamic data storage schemes and / or other data storage mechanisms and media for storing data relating to a particular aspect of the present disclosure. In an embodiment, the data store illustrated includes mechanisms for storing production data 712 and user information 716, which are used to serve content for the production side. The data store also is shown to include a mechanism for storing log data 714, which is used, in an embodiment, for reporting, computing resource management, analysis or other such purposes. In an embodiment, other aspects such as page image information and access rights information (e.g., access control policies or other encodings of permissions) are stored in the data store in any of the above listed mechanisms as appropriate or in additional mechanisms in the data store 710.

[0087] The data store 710, in an embodiment, is operable, through logic associated therewith, to receive instructions from the application server 708 and obtain, update or otherwise process data in response thereto and the application server 708 provides static, dynamic, or a combination of static and dynamic data in response to the received instructions. In an embodiment, dynamic data, such as data used in web logs (blogs), shopping applications, news services, and other such applications are generated by server-side structured languages as described herein or are provided by a content management system (“CMS”) operating on, or under the control of, the application server. In an embodiment, a user, through a device operated by the user, submits a search request for a certain type of item. In this example, the data store accesses the user information to verify the identity of the user, accesses the catalog detail information to obtain information about items of that type, and returns the information to the user, such as in a results listing on a web page that the user views via a browser on the user device 702. Continuing with example, information for a particular item of interest is viewed in a dedicated page or window of the browser. It should be noted, however, that embodiments of the present disclosure are not necessarily limited to the context of web pages, but are more generally applicable to processing requests in general, where the requests are not necessarily requests for content. Example requests include requests to manage and / or interact with computing resources hosted by the system 700 and / or another system, such as for launching, terminating, deleting, modifying, reading, and / or otherwise accessing such computing resources.

[0088] In an embodiment, each server typically includes an operating system that provides executable program instructions for the general administration and operation of that server and includes a computer-readable storage medium (e.g., a hard disk, random access memory, read only memory, etc.) storing instructions that, if executed (i.e., as a result of being executed) by a processor of the server, cause or otherwise allow the server to perform its intended functions.

[0089] The system 700, in an embodiment, is a distributed and / or virtual computing system utilizing several computer systems and components that are interconnected via communication links (e.g., transmission control protocol (TCP) connections and / or transport layer security (TLS) or other cryptographically protected communication sessions), using one or more computer networks or direct connections. However, it will be appreciated by those of ordinary skill in the art that such a system could operate in a system having fewer or a greater number of components than are illustrated in FIG. 7. Thus, the depiction of the system 700 in FIG. 7 should be taken as being illustrative in nature and not limiting to the scope of the disclosure.

[0090] The various embodiments further can be implemented in a wide variety of operating environments, which in some cases can include one or more user computers, computing devices or processing devices which can be used to operate any of a number of applications. In an embodiment, user or client devices include any of a number of computers, such as desktop, laptop or tablet computers running a standard operating system, as well as cellular (mobile), wireless and handheld devices running mobile software and capable of supporting a number of networking and messaging protocols and such a system also includes a number of workstations running any of a variety of commercially-available operating systems and other known applications for purposes such as development and database management. In an embodiment, these devices also include other electronic devices, such as dummy terminals, thin-clients, gaming systems and other devices capable of communicating via a network, and virtual devices such as virtual machines, hypervisors, software containers utilizing operating-system level virtualization and other virtual devices or non-virtual devices supporting virtualization capable of communicating via a network.

[0091] In an embodiment, a system utilizes at least one network that would be familiar to those skilled in the art for supporting communications using any of a variety of commercially-available protocols, such as Transmission Control Protocol / Internet Protocol (“TCP / IP”), User Datagram Protocol (“UDP”), protocols operating in various layers of the Open System Interconnection (“OSI”) model, File Transfer Protocol (“FTP”), Universal Plug and Play (“UpnP”), Network File System (“NFS”), Common Internet File System (“CIFS”) and other protocols. The network, in an embodiment, is a local area network, a wide-area network, a virtual private network, the Internet, an intranet, an extranet, a public switched telephone network, an infrared network, a wireless network, a satellite network, and any combination thereof. In an embodiment, a connection-oriented protocol is used to communicate between network endpoints such that the connection-oriented protocol (sometimes called a connection-based protocol) is capable of transmitting data in an ordered stream. In an embodiment, a connection-oriented protocol can be reliable or unreliable. For example, the TCP protocol is a reliable connection-oriented protocol. Asynchronous Transfer Mode (“ATM”) and Frame Relay are unreliable connection-oriented protocols. Connection-oriented protocols are in contrast to packet-oriented protocols such as UDP that transmit packets without a guaranteed ordering.

[0092] In an embodiment, the system utilizes a web server that run one or more of a variety of server or mid-tier applications, including Hypertext Transfer Protocol (“HTTP”) servers, FTP servers, Common Gateway Interface (“CGI”) servers, data servers, Java servers, Apache servers, and business application servers. In an embodiment, the one or more servers are also capable of executing programs or scripts in response to requests from user devices, such as by executing one or more web applications that are implemented as one or more scripts or programs written in any programming language, such as Java®, C, C# or C++, or any scripting language, such as Ruby, PHP, Perl, Python or TCL, as well as combinations thereof. In an embodiment, the one or more servers also include database servers, including without limitation those commercially available from Oracle “, Microsoft”, Sybase “, and IBM” as well as open-source servers such as MySQL, Postgres, SQLite, MongoDB, and any other server capable of storing, retrieving, and accessing structured or unstructured data. In an embodiment, a database server includes table-based servers, document-based servers, unstructured servers, relational servers, non-relational servers, or combinations of these and / or other database servers.

[0093] In an embodiment, the system includes a variety of data stores and other memory and storage media as discussed above which can reside in a variety of locations, such as on a storage medium local to (and / or resident in) one or more of the computers or remote from any or all of the computers across the network. In an embodiment, the information resides in a storage-area network (“SAN”) familiar to those skilled in the art and, similarly, any necessary files for performing the functions attributed to the computers, servers or other network devices are stored locally and / or remotely, as appropriate. In an embodiment where a system includes computerized devices, each such device can include hardware elements that are electrically coupled via a bus, the elements including, for example, at least one central processing unit (“CPU” or “processor”), at least one input device (e.g., a mouse, keyboard, controller, touch screen, or keypad), at least one output device (e.g., a display device, printer, or speaker), at least one storage device such as disk drives, optical storage devices, and solid-state storage devices such as random access memory (“RAM”) or read-only memory (“ROM”), as well as removable media devices, memory cards, flash cards, etc., and various combinations thereof.

[0094] In an embodiment, such a device also includes a computer-readable storage media reader, a communications device (e.g., a modem, a network card (wireless or wired), an infrared communication device, etc.), and working memory as described above where the computer-readable storage media reader is connected with, or configured to receive, a computer-readable storage medium, representing remote, local, fixed, and / or removable storage devices as well as storage media for temporarily and / or more permanently containing, storing, transmitting, and retrieving computer-readable information. In an embodiment, the system and various devices also typically include a number of software applications, modules, services, or other elements located within at least one working memory device, including an operating system and application programs, such as a client application or web browser. In an embodiment, customized hardware is used and / or particular elements are implemented in hardware, software (including portable software, such as applets), or both. In an embodiment, connections to other computing devices such as network input / output devices are employed.

[0095] In an embodiment, storage media and computer readable media for containing code, or portions of code, include any appropriate media known or used in the art, including storage media and communication media, such as, but not limited to, volatile and non-volatile, removable and non-removable media implemented in any method or technology for storage and / or transmission of information such as computer readable instructions, data structures, program modules or other data, including RAM, ROM, Electrically Erasable Programmable Read-Only Memory (“EEPROM”), flash memory or other memory technology, Compact Disc Read-Only Memory (“CD-ROM”), digital versatile disk (DVD) or other optical storage, magnetic cassettes, magnetic tape, magnetic disk storage or other magnetic storage devices or any other medium which can be used to store the desired information and which can be accessed by the system device. Based on the disclosure and teachings provided herein, a person of ordinary skill in the art will appreciate other ways and / or methods to implement the various embodiments.

[0096] The specification and drawings are, accordingly, to be regarded in an illustrative rather than a restrictive sense. It will, however, be evident that various modifications and changes may be made thereunto without departing from the broader spirit and scope of the invention as set forth in the claims.

[0097] Other variations are within the spirit of the present disclosure. Thus, while the disclosed techniques are susceptible to various modifications and alternative constructions, certain illustrated embodiments thereof are shown in the drawings and have been described above in detail. It should be understood, however, that there is no intention to limit the invention to the specific form or forms disclosed, but on the contrary, the intention is to cover all modifications, alternative constructions, and equivalents falling within the spirit and scope of the invention, as defined in the appended claims.

[0098] The use of the terms “a” and “an” and “the” and similar referents in the context of describing the disclosed embodiments (especially in the context of the following claims) are to be construed to cover both the singular and the plural, unless otherwise indicated herein or clearly contradicted by context. Similarly, use of the term “or” is to be construed to mean “and / or” unless contradicted explicitly or by context. The terms “comprising,”“having,”“including,” and “containing” are to be construed as open-ended terms (i.e., meaning “including, but not limited to,”) unless otherwise noted. The term “connected,” when unmodified and referring to physical connections, is to be construed as partly or wholly contained within, attached to, or joined together, even if there is something intervening. Recitation of ranges of values herein are merely intended to serve as a shorthand method of referring individually to each separate value falling within the range, unless otherwise indicated herein and each separate value is incorporated into the specification as if it were individually recited herein. The use of the term “set” (e.g., “a set of items”) or “subset” unless otherwise noted or contradicted by context, is to be construed as a nonempty collection comprising one or more members. Further, unless otherwise noted or contradicted by context, the term “subset” of a corresponding set does not necessarily denote a proper subset of the corresponding set, but the subset and the corresponding set may be equal.

[0099] Conjunctive language, such as phrases of the form “at least one of A, B, and C,” or “at least one of A, B and C,” (i.e., the same phrase with or without the Oxford comma) unless specifically stated otherwise or otherwise clearly contradicted by context, is otherwise understood with the context as used in general to present that an item, term, etc., may be either A or B or C, any nonempty subset of the set of A and B and C, or any set not contradicted by context or otherwise excluded that contains at least one A, at least one B, or at least one C. For instance, in the illustrative example of a set having three members, the conjunctive phrases “at least one of A, B, and C” and “at least one of A, B and C” refer to any of the following sets: {A}, {B}, {C}, {A, B}, {A, C}, {B, C}, {A, B, C}, and, if not contradicted explicitly or by context, any set having {A}, {B}, and / or {C} as a subset (e.g., sets with multiple “A”). Thus, such conjunctive language is not generally intended to imply that certain embodiments require at least one of A, at least one of B and at least one of C each to be present. Similarly, phrases such as “at least one of A, B, or C” and “at least one of A, B or C” refer to the same as “at least one of A, B, and C” and “at least one of A, B and C” refer to any of the following sets: {A}, {B}, {C}, {A, B}, {A, C}, {B, C}, {A, B, C}, unless differing meaning is explicitly stated or clear from context. In addition, unless otherwise noted or contradicted by context, the term “plurality” indicates a state of being plural (e.g., “a plurality of items” indicates multiple items). The number of items in a plurality is at least two, but can be more when so indicated either explicitly or by context. Further, unless stated otherwise or otherwise clear from context, the phrase “based on” means “based at least in part on” and not “based solely on.”

[0100] Operations of processes described herein can be performed in any suitable order unless otherwise indicated herein or otherwise clearly contradicted by context. In an embodiment, a process such as those processes described herein (or variations and / or combinations thereof) is performed under the control of one or more computer systems configured with executable instructions and is implemented as code (e.g., executable instructions, one or more computer programs or one or more applications) executing collectively on one or more processors, by hardware or combinations thereof. In an embodiment, the code is stored on a computer-readable storage medium, for example, in the form of a computer program comprising a plurality of instructions executable by one or more processors. In an embodiment, a computer-readable storage medium is a non-transitory computer-readable storage medium that excludes transitory signals (e.g., a propagating transient electric or electromagnetic transmission) but includes non-transitory data storage circuitry (e.g., buffers, cache, and queues) within transceivers of transitory signals. In an embodiment, code (e.g., executable code or source code) is stored on a set of one or more non-transitory computer-readable storage media having stored thereon executable instructions that, when executed (i.e., as a result of being executed) by one or more processors of a computer system, cause the computer system to perform operations described herein. The set of non-transitory computer-readable storage media, in an embodiment, comprises multiple non-transitory computer-readable storage media and one or more of individual non-transitory storage media of the multiple non-transitory computer-readable storage media lack all of the code while the multiple non-transitory computer-readable storage media collectively store all of the code. In an embodiment, the executable instructions are executed such that different instructions are executed by different processors—for example, a non-transitory computer-readable storage medium store instructions and a main CPU execute some of the instructions while a graphics processor unit executes other instructions. In an embodiment, different components of a computer system have separate processors and different processors execute different subsets of the instructions.

[0101] Accordingly, in an embodiment, computer systems are configured to implement one or more services that singly or collectively perform operations of processes described herein and such computer systems are configured with applicable hardware and / or software that enable the performance of the operations. Further, a computer system that implement an embodiment of the present disclosure is a single device and, in another embodiment, is a distributed computer systems comprising multiple devices that operate differently such that the distributed computer system performs the operations described herein and such that a single device does not perform all operations.

[0102] The use of any and all examples, or exemplary language (e.g., “such as”) provided herein, is intended merely to better illuminate embodiments of the invention and does not pose a limitation on the scope of the invention unless otherwise claimed. No language in the specification should be construed as indicating any non-claimed element as essential to the practice of the invention.

[0103] Embodiments of this disclosure are described herein, including the best mode known to the inventors for carrying out the invention. Variations of those embodiments may become apparent to those of ordinary skill in the art upon reading the foregoing description. The inventors expect skilled artisans to employ such variations as appropriate and the inventors intend for embodiments of the present disclosure to be practiced otherwise than as specifically described herein. Accordingly, the scope of the present disclosure includes all modifications and equivalents of the subject matter recited in the claims appended hereto as permitted by applicable law. Moreover, any combination of the above-described elements in all possible variations thereof is encompassed by the scope of the present disclosure unless otherwise indicated herein or otherwise clearly contradicted by context.

[0104] All references, including publications, patent applications, and patents, cited herein are hereby incorporated by reference to the same extent as if each reference were individually and specifically indicated to be incorporated by reference and were set forth in its entirety herein.

Claims

1. A computer-implemented method, comprising:receiving input data;determining a set of operations of a convolutional neural network performed by a computation graph corresponding to the convolutional neural network in response to the input data;determining a plurality of candidate data layouts of tensors in computer memory for each operation of at least a subset of the set of operations, wherein each candidate data layout defines an input layout for an operation of the set of operations;selecting a data layout from each plurality of candidate data layouts to determine a minimum cost of inference on the convolutional neural network, wherein each candidate data layout, if performed by the computation graph, would cause a different utilization of computer hardware, wherein the minimum cost of inference on the convolutional neural network is based on a memory layout transformation cost between operations of the set of operations having different data layouts, wherein a first operation of the set of operations results in a memory layout transformation that causes a subsequent operation of the set of operations to use a different data layout compared to a selected data layout for the first operation;generating a modified computation graph corresponding to the convolutional neural network at least by passing the input data through the convolutional neural network and executing the set of operations and a set of memory layout transformations according to the selected data layouts to generate an inference at the minimum cost of inference, wherein at least one of the set of memory layout transformations includes operations to split a dimension of a data layout to increase a number of dimensions of the data layout to correspond with one of the selected data layouts; andgenerating an output of the convolutional neural network by performing the modified computation graph.

2. The computer-implemented method of claim 1, wherein a candidate data layout of the plurality of candidate data layouts associated with an operation comprises:a channel splitting factor to split the dimension;a number of registers to utilize for performing the operation; andan indication whether to unroll a result of the operation.

3. The computer-implemented method of claim 2, wherein the registers are single-instruction-multiple-data (SIMD) registers.

4. The computer-implemented method of claim 1, wherein the input layout defines a multi-dimensional tensor.

5. The computer-implemented method of claim 1, further comprising: executing the set of operations according to the selected data layouts by scheduling active threads, from a scalable thread pool, to run on disjoint physical cores of a CPU.

6. A system, comprising non-transitory memory to store instructions that, as a result of execution by one or more processors, cause the system to:receive input data;determine a set of operations of a machine learning model performed by a computation graph corresponding to the machine learning model based at least on using the input data as input to the computation graph;select, based on a transformation between operations of the set of operations, a set of data layouts of tensors in computer memory for the set of operations to determine a cost of inference on the machine learning model lower than a cost of inference on the machine learning model as determined for another set of data layouts, wherein each data layout if performed by the computation graph, would cause a different utilization of computer hardware, wherein a first operation of the set of operations results in a transformation that causes a second operation of the set of operations to use a data layout different from the first operation;modify the computation graph corresponding to the machine learning model at least by passing the input data through the machine learning model and performing the set of operations and a set of memory layout transformations according to the set of data layouts; andgenerate an inference at the determined cost of inference based, at least in part, on performing the modified computation graph, wherein one of the set of memory layout transformations includes operations to modify a dimension of a data layout to increase a number of dimensions of the data layout to match at least one of the set of data layouts.

7. The system of claim 6, wherein the instructions further comprise instructions that, as a result of execution by the one or more processors, cause the system to model the set of operations as a Markov Decision Process, wherein:a data layout of the set of data layouts corresponds to a state of the Markov Decision Process; anda transformation of the set of transformations corresponds to an action of the Markov Decision Process.

8. The system of claim 7, wherein the instructions further comprise instructions that, as a result of execution by the one or more processors, cause the system to solve the Markov Decision Process using a Bellman optimality equation.

9. The system of claim 6, wherein the one or more processors comprise a vector processing unit (VPU) for performing at least a portion of the set of operations.

10. The system of claim 6, wherein the instructions further comprise instructions that, as a result of execution by the one or more processors, cause the system to fuse at least two operations of the set of operations.

11. The system of claim 6, wherein the machine learning model is a neural network.

12. The system of claim 6, wherein the one or more processors support x86 or ARM architectures.

13. A non-transitory computer-readable storage medium having stored thereon executable instructions that, if executed by one or more processors of a computer system, cause the computer system to at least:receive input data;determine a set of operations of a machine learning model performed by a computation graph corresponding to the machine learning model in response to the input data;determine a cost of inference on the machine learning model by selecting different data layouts of tensors in computer memory for at least a portion of the set of operations and inserting layout transformation operations between operations of the set of operations based on the operations having different data layouts, wherein the set of operations comprises a second operation that has a data layout different from a first data layout of a previous operation;modify the computation graph corresponding to the machine learning model at least by passing the input data through the machine learning model and performing the set of operations and a set of computer memory layout transformations according to the different data layouts; andgenerate an inference at the determined cost of inference based, at least in part, on performing the modified computation graph, wherein one or more of the set of computer memory layout transformations includes operations to split a dimension of one or more data layouts to increase a number of dimensions of the one or more data layouts to align with one of the selected data layouts.

14. The non-transitory computer-readable storage medium of claim 13, wherein modifying the machine learning model further comprises causing two or more threads of a thread pool to execute at least a portion of the set of operations in parallel.

15. The non-transitory computer-readable storage medium of claim 14, wherein a first thread of the thread pool executes on a first physical core of the one or more processors and a second thread of the thread pool executes, parallel to the first thread, on a second physical core of the one or more processors.

16. The non-transitory computer-readable storage medium of claim 13, wherein the instructions that, if executed by the one or more processors, cause the computer system to determine the cost of inference on the machine learning model further include instructions that, if executed by the one or more processors, cause the computer system to minimize the cost of inference on the machine learning model according to a plurality of candidate data layouts for each operation of the set of operations.

17. The non-transitory computer-readable storage medium of claim 13, wherein:a processor of the one or more processors supports single-instruction-multiple-data (SIMD) vectorization of data; andperforming the set of operations to modify the machine learning model comprises performing a SIMD vectorization over one or more sub-dimensions of an input to an operation of the set of operations.

18. The non-transitory computer-readable storage medium of claim 13, wherein:a processor of the one or more processors supports a fused-multiply-add (FMA) instruction which executes a vectorized multiplication to generate one or more results and accumulates the one or more results in the same CPU cycle; andthe set of operations comprises one or more FMA instructions.

19. The non-transitory computer-readable storage medium of claim 13, wherein the instructions further include instructions that, if executed by the one or more processors, cause the computer system to:determine, for each operation of the set of operations, a classification for the operation based on whether the operation is layout mutable, layout semi-mutable, or layout immutable; anddetermine whether to perform a transformation between two operations of the set of operations based on the classifications of the two operations.

20. The non-transitory computer-readable storage medium of claim 13, wherein the set of operations comprises a convolution (CONV) operation or a general matrix multiplication (GEMM) operation.

Citation Information

Patent Citations

  • Adaptive network system with online learning and autonomous cross-layer optimization for delay-sensitive applications

    US20110019693A1

  • Pipelined approach to fused kernels for optimization of machine learning workloads on graphical processing units

    US20170032487A1

  • Method for providing data analysis service by a service provider to data owner and related data transformation method for preserving business confidential information of the data owner

    US20170061311A1

  • Method And System For Processing An Input Query

    US20170286401A1

  • Instructions and logic to perform floating-point and integer operations for machine learning

    US20180315398A1