<?xml-model href='http://www.tei-c.org/release/xml/tei/custom/schema/relaxng/tei_all.rng' schematypens='http://relaxng.org/ns/structure/1.0'?><TEI xmlns="http://www.tei-c.org/ns/1.0">
	<teiHeader>
		<fileDesc>
			<titleStmt><title level='a'>Vyasa: A High-Performance Vectorizing Compiler for Tensor Convolutions on the Xilinx AI Engine</title></titleStmt>
			<publicationStmt>
				<publisher></publisher>
				<date>09/21/2020</date>
			</publicationStmt>
			<sourceDesc>
				<bibl> 
					<idno type="par_id">10199641</idno>
					<idno type="doi"></idno>
					<title level='j'>2020 IEEE High Performance Extreme Computing Virtual Conference</title>
<idno></idno>
<biblScope unit="volume"></biblScope>
<biblScope unit="issue"></biblScope>					

					<author>Prasanth Chatarasi</author><author>Stephen Neuendorffer</author><author>Samuel Bayliss</author><author>Kees Vissers</author><author>Vivek Sarkar</author>
				</bibl>
			</sourceDesc>
		</fileDesc>
		<profileDesc>
			<abstract><ab><![CDATA[Xilinx’s AI Engine is a recent industry example of energy-efficient vector processing that includes novel support for 2D SIMD datapaths and shuffle interconnection network. The current approach to programming the AI Engine relies on a C/C++ API for vector intrinsics. While an advance over assembly- level programming, it requires the programmer to specify a number of low-level operations based on detailed knowledge of the hardware. To address these challenges, we introduce Vyasa, a new programming system that extends the Halide DSL compiler to automatically generate code for the AI Engine. We evaluated Vyasa on 36 CONV2D workloads, and achieved geometric means of 7.6 and 24.2 MACs/cycle for 32-bit and 16-bit operands (which represent 95.9% and 75.6% of the peak performance respectively).]]></ab></abstract>
		</profileDesc>
	</teiHeader>
	<text><body xmlns="http://www.tei-c.org/ns/1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xlink="http://www.w3.org/1999/xlink">
<div xmlns="http://www.tei-c.org/ns/1.0"><head>I. INTRODUCTION</head><p>It is widely recognized that a major disruption is underway in computer hardware as processors strive to extend, and go beyond, the end-game of Moore's Law. As part of the disruption, there is an emphasis on specializing SIMD units to improve energy efficiency benefits for compute-intensive domains. An important specialization, which is referred to as "2D vector SIMD datapath" <ref type="bibr">[1]</ref>- <ref type="bibr">[3]</ref>, is the ability of each vector lane to execute more than one scalar operation and to chain the results from one operation to another. Another specialization replaces expensive data permutation units (e.g., shuffle units) <ref type="bibr">[4]</ref>, <ref type="bibr">[5]</ref> with sophisticated, programmable interconnection networks (a.k.a shuffle networks) between the SIMD datapath and vector register file <ref type="bibr">[3]</ref>, <ref type="bibr">[6]</ref>.</p><p>A recent industry example with these specializations is the Xilinx Versal AI Engine <ref type="bibr">[7]</ref>, a high-performance VLIW SIMD core with performance comparable to traditional FPGA solutions for Computer Vision, Deep Learning, and 5G wireless domains, but with 50% less power and up to 8&#215; more compute capacity per silicon area <ref type="bibr">[7]</ref>. The Versal AI Engine series VC1902 has a total of 400 AI Engines that can deliver a peak performance of 6.4 TOPS, 25.6 TOPS, and 102.4 TOPS for 32-bit, 16-bit, and 8-bit operands, respectively <ref type="bibr">[8]</ref>.</p><p>Tensor convolution is a widely used mathematical operation in these domains, and it is becoming increasingly important with the rise of its use in image processing workflows <ref type="bibr">[9]</ref>- <ref type="bibr">[11]</ref> and with the proliferation of deep learning models <ref type="bibr">[12]</ref>- <ref type="bibr">[15]</ref> in data centers, edge, and mobile devices. There has been a lot of prior work on optimizing tensor convolutions for a variety of target hardware devices such as CPUs <ref type="bibr">[9]</ref>, <ref type="bibr">[10]</ref>, <ref type="bibr">[16]</ref>, GPUs <ref type="bibr">[9]</ref>, <ref type="bibr">[16]</ref>, <ref type="bibr">[17]</ref>, FPGAs <ref type="bibr">[16]</ref>, <ref type="bibr">[18]</ref>- <ref type="bibr">[21]</ref>, and Dataflow accelerators <ref type="bibr">[20]</ref>, <ref type="bibr">[22]</ref>- <ref type="bibr">[24]</ref>. However, while it is desirable to automatically generate optimized code for new high performance processor architectures like the AI Engine from high-level descriptions, doing so can be challenging. This work demonstrates the ability to optimize tensor convolutions for the AI Engine automatically and to obtain near-peak performance for various workloads while using the Halide DSL as a high-level programming model, Challenges. Achieving peak performance on the AI Engine requires leveraging several architectural features to maximize vector datapath occupancy during program execution. Unlike standard SIMD architectures that operate on 1D vectors, the AI Engine architecture includes 2D vector operations for some datatypes, which conceptually implement the fusion of several 1D vector operations. Unlike other architectures, the AI Engine does not implement direct support for unaligned loads, scalar broadcasts, and data manipulation operations. Instead, the AI Engine architecture includes a novel shuffle network that selects the desired elements of a vector register for a vector operation instead of explicitly shuffling and storing them into another vector register. To effectively leverage these features, the layout of data in memory must match the capabilities of the shuffle network.</p><p>Existing AI Engine compilers perform VLIW scheduling but do not perform auto-vectorization. High-performance vector code must be expressed using intrinsic architectural functions for most vector operations, including the shuffle network configuration. Optimizing programs in this way can be timeconsuming, even for experts. Simultaneously, there is a wide variety of tensor convolution operators in common use; for instance, deep neural networks may contain regular 2D convolutions, depth-wise convolutions, and point-wise convolutions. Even within the same network, the shape of tensor data can vary radically between the early and late layers in DNN models. We find that no single optimization strategy is an optimal choice for all these scenarios. Reducing the need for manual optimization and quickly adapting to new tensor operations through automatic optimization avoids these problems. The overall goal of our work is to automate the generation of high-performance vector code for tensor convolutions based on their variations and shapes, while exploiting the unique capabilities of the Xilinx AI Engine without requiring manual effort in development and tuning. Achieving this goal requires significant loop-level reuse analysis, code transformations, and data-layout transformations, along with optimized low-level code generation taking into account the shuffle network. Even though our approach is tied to the AI Engine, ideas in the approach are very applicable to other specialized SIMD units with similar architectures. The main technical contributions of this paper are briefly described below:</p><p>&#8226; We introduce an intermediate representation, Triplet, to symbolically capture the loop body of a tensor convolution and also to simplify analyses and transformations to generate optimized code for the AI Engine.</p><p>&#8226; We propose a novel multi-step compiler approach that includes analyses and transformations to 1) exploit the 2D SIMD datapath by identifying multiple 1D logical vector operations that can be legally fused, 2) realize unaligned loads, scalar broadcasts, data manipulation using the shuffle network, 3) improve memory utilization by exploiting vector register reuse and loop optimizations, and 4) generate code that is more amenable to enabling VLIW instruction scheduling for the AI Engine.</p><p>&#8226; We created a new tool, Vyasa<ref type="foot">foot_0</ref> , to implement our multistep compiler approach. Vyasa is built on the Halide framework <ref type="bibr">[9]</ref> and includes extensions needed for the AI Engine that is not supported by Halide. Given a tensor convolution specification in the Halide language and workload sizes, Vyasa generates high-performance C-code with vector intrinsics for the AI Engine.</p><p>&#8226; We evaluated Vyasa on 36 CONV2D workloads using the in-house cycle-accurate simulator<ref type="foot">foot_1</ref> . Our results show geometric means of 7.6 and 24.2 MACs/cycle for 32bit and 16-bit operands (95.9% and 75.6% of the peak performance respectively). For four of these workloads for which expert-written implementations were available to us, Vyasa achieved a geometric mean performance improvement of 1.10&#215; from extended Halide code that is around 50&#215; smaller than the expert-written C/C++ code.</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head>II. BACKGROUND</head><p>In this section, we start with an overview of tensor convolutions, and then we briefly summarize the key architectural features of the Xilinx Versal AI Engine.</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head>A. Tensor Convolutions</head><p>Convolution is a mathematical operation which computes the amount of overlap of a function g as it is shifted over another function f . In this section, we restrict our attention to describing CONV2D, a popular convolution operator widely used in Deep learning <ref type="bibr">[12]</ref>- <ref type="bibr">[15]</ref>, <ref type="bibr">[25]</ref>, <ref type="bibr">[26]</ref> and Computer Vision <ref type="bibr">[9]</ref>- <ref type="bibr">[11]</ref>, <ref type="bibr">[27]</ref>. In these domains, the function f and g are referred to as the "input" tensor (a.k.a image/activations) and "weight" tensor (a.k.a filters/kernels), respectively. The CONV2D deals with three four-dimensional tensors, i.e., Output (O), Weight (W), and Input (I), whose dimensions are described below.</p><p>The mathematical expression of the CONV2D operations is shown below, where f refers to stride factor.</p><p>Specialized versions of CONV2D are often interesting. For example, image processing pipelines such as Blur detection, Harris corner detection algorithms in compute vision domain often involve CONV2D's operating over two-dimensional tensors only (number of channels and batch size are set to one). In Convolutional Neural networks (CNNs), the number of channels is often large, particularly in later layers. Other types of convolution layers are special cases of CONV2D, such as fully-connected, point-wise, depth-wise separable, and spatially separable convolutions. These variations can be viewed as constraints on the regular CONV2D as follows: </p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head>B. Xilinx AI Engine</head><p>Driven by the performance and energy efficiency requirements of many computing applications, Xilinx introduced Versal Advanced Compute Acceleration Platform (ACAP) <ref type="bibr">[8]</ref>, <ref type="bibr">[28]</ref>, a fully software-programmable, heterogeneous compute platform. The Versal platform consists of three types of programmable processors -Scalar Engines (CPUs), Adaptable Engines (Programmable Logic), and an array of Intelligent Engines (AI Engines) <ref type="bibr">[8]</ref>. In this work, we focus on AI Engines, which are specialized SIMD and VLIW high-performance processors for compute-intensive applications.</p><p>An AI Engine includes a 2D SIMD datapath for fixedpoint vector operations (our focus), a 1D SIMD datapath for floating-point vector operations, and a scalar unit for scalar operations. Each AI Engine also has access to 128KB scratchpad (a.k.a data/local) memory, a 16KB program memory, and a 256B vector register file (a total of 16 registers with each size being 128 bits). These high-performance AI Engines are programmed using the C/C++ programming language with optional pragmas. A simplified overview of the key architectural features of the AI Engine core is shown in fig. <ref type="figure">1</ref>. 1) Two-dimensional SIMD Datapath. The fixed point vector unit of the AI Engine is a two-dimensional SIMD datapath, and vector operations on the 2D SIMD datapath </p><p>for weights in 16-bit PW-1x1). Manually identifying such a data layout and writing the corresponding intrinsic-based code is exceptionally challenging and error-prone, even for experts, thereby demonstrating the benefits of our automatic approach. The FC workload in our evaluation has lower arithmetic intensity (because it lacks convolutional reuse) and lies on the left side of the inflection point of the roof-line graph of the AI engine, indicating memory-bound execution. The workload peak performance based on its arithmetic intensity is 21.22 MACs/cycle, and our approach achieved 75% of the peak.</p><p>Overall, our evaluation over all the workloads shows geometric means of 7.6 and 24.2 MACs/cycle for 32-bit and 16bit operands (which represent 95.9% and 75.6% of the peak performance respectively). This difference in efficiency is not surprising, since it is more challenging to utilize two columns in the SIMD data path in the case of 16-bit operands, compared to a single column in the case of 32-bit operands. However, the absolute performance in the 16-bit case is still significantly higher than the 32-bit case, despite a lower efficiency.</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head>V. R ELATED WORK</head><p>The Halide framework <ref type="bibr">[9]</ref> for image processing pipelines have been shown to improve the productivity of application programmers, while generating high-performance code for a variety of architectures, including CPUs, GPUs, and FPGAs. Recently, Vocke et al. <ref type="bibr">[32]</ref> extended the Halide framework to support specialized Digital Signal Processors (DSPs) of the Intel Imaging Processing Units (IPUs). Furthermore, Halide has the support for the Hexagon Vector eXtensions (HVX) on the Qualcomm Hexagon DSP processors. However, none of the above prior work addresses the 2D SIMD datapaths and shuffle network, which are unique to the AI Engine. To the best of our knowledge, the only prior work on auto-vectorizing for a 2D SIMD datapath is the work by Dasika et al. <ref type="bibr">[2]</ref> for the PEPSC's architecture, where the authors have proposed a greedy compiler approach to identify fusible vector operations.</p><p>Exploiting vector register reuse (including partial reuse) on SIMD units is a vital optimization to achieve high-performance, and prior work exploited the reuse by shuffling the vector registers using the data manipulation/shuffle units <ref type="bibr">[33]</ref>- <ref type="bibr">[35]</ref>. However, our approach constructs a larger vector load covering the loads having the reuse and uses the AI Engine's unique shuffle network to select the desired elements. Furthermore, our approach uses the shuffle network to address the unaligned vector loads and scalar broadcasts without requiring any additional hardware support.</p><p>The vector codes generated by our approach can be viewed as high-performance primitives for a single AI Engine. These primitives will be composed and integrated by a high-level compiler to run larger tensor convolutions across multiple AI Engines. Some of the prior works that have followed the similar strategy of automating the library/primitive development for the performance-critical kernels are SPIRAL <ref type="bibr">[36]</ref> for the domain of linear transforms, ATLAS <ref type="bibr">[37]</ref> for the basic linear algebra subroutines (BLAS), and FFTW <ref type="bibr">[38]</ref> for the discrete Fourier transforms.</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head>VI. CONCLUSIONS &amp;FUTURE WORK</head><p>In this work, we introduced Vyasa, a high-level programming system built on the Halide framework, to generate highperformance vector codes for the tensor convolutions onto the Xilinx Versal AI Engine. Our proposed multi-step compiler approach leverages the AI Engine's unique capabilities of the 2D SIMD datapath and the shuffle interconnection networks to achieve close to the peak performance for various workloads. Manually identifying best schedules and writing the corresponding intrinsic-based code is exceptionally challenging and error-prone, even for experts, thereby demonstrating the benefits of our automatic approach. Our results show a geometric mean of 7.6 and 24.2 MACs/cycle for 32-bit and 16-bit operands (which represent 95.9% and 75.6% of the peak performance respectively). In the future, we plan to extend our system to other computationally expensive linear algebra kernels. We also plan to integrate the generated highperformance codes into a high-level compiler to run larger tensor convolutions across multiple AI Engines.</p></div><note xmlns="http://www.tei-c.org/ns/1.0" place="foot" n="1" xml:id="foot_0"><p>Vyasa means "compiler" in the Sanskrit language, and also refers to the sage who first compiled the Mahabharata.</p></note>
			<note xmlns="http://www.tei-c.org/ns/1.0" place="foot" n="2" xml:id="foot_1"><p>Since the AI Engine architecture was developed for real-time processing applications which require deterministic performance, the simulator results are reliably correlated with the actual performance of the AI Engine hardware.</p></note>
		</body>
		</text>
</TEI>
