1 //===- StandardToSPIRV.h - Standard to SPIR-V Patterns --------*- C++ -*-===// 2 // 3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4 // See https://llvm.org/LICENSE.txt for license information. 5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 // 7 //===----------------------------------------------------------------------===// 8 // 9 // Provides patterns to convert Standard dialect to SPIR-V dialect. 10 // 11 //===----------------------------------------------------------------------===// 12 13 #ifndef MLIR_CONVERSION_STANDARDTOSPIRV_STANDARDTOSPIRV_H abs(&self) -> Self14#define MLIR_CONVERSION_STANDARDTOSPIRV_STANDARDTOSPIRV_H 15 16 #include "mlir/Transforms/DialectConversion.h" 17 18 namespace mlir { 19 class SPIRVTypeConverter; 20 21 /// Appends to a pattern list additional patterns for translating standard ops 22 /// to SPIR-V ops. Also adds the patterns to legalize ops not directly 23 /// translated to SPIR-V dialect. 24 void populateStandardToSPIRVPatterns(SPIRVTypeConverter &typeConverter, 25 RewritePatternSet &patterns); 26 27 /// Appends to a pattern list additional patterns for translating tensor ops 28 /// to SPIR-V ops. 29 /// 30 /// Note: Normally tensors will be stored in buffers before converting to 31 /// SPIR-V, given that is how a large amount of data is sent to the GPU. 32 /// However, SPIR-V supports converting from tensors directly too. This is 33 /// for the cases where the tensor just contains a small amount of elements 34 /// and it makes sense to directly inline them as a small data array in the 35 /// shader. To handle this, internally the conversion might create new local 36 /// variables. SPIR-V consumers in GPU drivers may or may not optimize that 37 /// away. So this has implications over register pressure. Therefore, a 38 /// threshold is used to control when the patterns should kick in. 39 void populateTensorToSPIRVPatterns(SPIRVTypeConverter &typeConverter, 40 int64_t byteCountThreshold, 41 RewritePatternSet &patterns); 42 43 } // namespace mlir 44 45 #endif // MLIR_CONVERSION_STANDARDTOSPIRV_STANDARDTOSPIRV_H 46