summaryrefslogtreecommitdiffstats
Commit message (Collapse)AuthorAgeFilesLines
...
| * [spirv] Support (de)serialization of spv.structDenis Khalikov2019-08-204-13/+152
| | | | | | | | | | | | | | | | Support (de)serialization of spv.struct with offset decorations. Closes tensorflow/mlir#94 PiperOrigin-RevId: 264421427
| * Fix build of affine load/store with empty mapDiego Caballero2019-08-208-7/+49
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | tensorflow/mlir#58 fixed and exercised verification of load/store ops using empty affine maps. Unfortunately, it didn't exercise the creation of them. This PR addresses that aspect. It removes the assumption of AffineMap having at least one result and stores a pointer to MLIRContext as member of AffineMap. * Add empty map support to affine.store + test * Move MLIRContext to AffineMapStorage Closes tensorflow/mlir#74 PiperOrigin-RevId: 264416260
| * Update MLIR code examples in Passes.md doc to use new affine.load/store ↵Andy Davis2019-08-201-78/+72
| | | | | | | | | | | | dma_start/wait operations. PiperOrigin-RevId: 264415037
| * Update Ch-2.mdZhang2019-08-201-1/+1
| | | | | | | | | | | | | | | | | | | | | | -- 406f1e8211f8f5017f44f46af750dec061e707a2 by Zhang <5205699+Naville@users.noreply.github.com>: Update Ch-2.md Closes tensorflow/mlir#93 PiperOrigin-RevId: 264392995
| * ConvertLaunchFuncToCudaCalls: use LLVM dialect globalsAlex Zinenko2019-08-206-61/+87
| | | | | | | | | | | | | | | | | | | | | | | | This conversion has been using a stack-allocated array of i8 to store the null-terminated kernel name in order to pass it to the CUDA wrappers expecting a C string because the LLVM dialect was missing support for globals. Now that the suport is introduced, use a global instead. Refactor global string construction from GenerateCubinAccessors into a common utility function living in the LLVM namespace. PiperOrigin-RevId: 264382489
| * JitRunner: support entry functions returning voidAlex Zinenko2019-08-202-32/+51
| | | | | | | | | | | | | | | | | | | | | | | | | | JitRunner can use as entry points functions that produce either a single '!llvm.f32' value or a list of memrefs. Memref support is legacy and was introduced before MLIR could lower memref allocation and deallocation to malloc/free calls so as to allocate the memory externally, and is likely to be dropped in the future since it unconditionally runs affine+standard-to-llvm lowering on the module instead of accepting the LLVM dialect. CUDA runner relies on memref-based flow in the runner without actually returning anything. Introduce a runner flow to use functions that return void as entry points. PiperOrigin-RevId: 264381686
| * LLVM dialect: prefix operations that correspond to intrinsics with "intr."Alex Zinenko2019-08-204-8/+9
| | | | | | | | | | | | | | | | | | | | LLVM intrinsics have an open name space and their names can potentially overlap with names of LLVM instructions (LLVM intrinsics are functions, not instructions). In MLIR, LLVM intrinsics are modeled as operations, so it needs to make sure their names cannot clash with the instructions. Use the "intr." prefix for intrinsics in the LLVM dialect. PiperOrigin-RevId: 264372173
| * Add support for LLVM lowering of binary ops on n-D vector typesNicolas Vasilache2019-08-206-29/+171
| | | | | | | | | | | | This CL allows binary operations on n-D vector types to be lowered to LLVMIR by performing an (n-1)-D extractvalue, 1-D vector operation and an (n-1)-D insertvalue. PiperOrigin-RevId: 264339118
| * Fix AffineExpr::simplifyAdd bugUday Bondhugula2019-08-202-1/+7
| | | | | | | | | | | | | | | | | | | | | | | | - fix missing check while simplifying an expression with floordiv to a mod - fixes issue tensorflow/mlir#82 Signed-off-by: Uday Bondhugula <uday@polymagelabs.com> Closes tensorflow/mlir#84 PiperOrigin-RevId: 264338353
| * Fix minor typos and add missing syntax in the documentation.Chintan Kaur2019-08-191-15/+39
| | | | | | | | PiperOrigin-RevId: 264281501
| * Move Linalg and VectorOps dialects to the Dialect subdir - NFCNicolas Vasilache2019-08-1942-93/+93
| | | | | | | | PiperOrigin-RevId: 264277760
| * Add a DialectConversion document detailing the conversion infrastructure.River Riddle2019-08-192-2/+231
| | | | | | | | | | | | This is an important piece of the infrastructure that is missing proper high level documentation on usage. PiperOrigin-RevId: 264275482
| * Add DictionaryAttr to OpBase.tdRob Suderman2019-08-191-0/+7
| | | | | | | | PiperOrigin-RevId: 264262369
| * Allow isolated regions to form isolated SSA name scopes in the printer.River Riddle2019-08-199-104/+194
| | | | | | | | | | | | | | | | | | | | | | This will allow for naming values the same as existing SSA values for regions attached to operations that are isolated from above. This fits in with how the system already allows separate name scopes for sibling regions. This name shadowing can be enabled in the custom parser of operations by setting the 'enableNameShadowing' flag to true when calling 'parseRegion'. %arg = constant 10 : i32 foo.op { %arg = constant 10 : i32 } PiperOrigin-RevId: 264255999
| * Add alignment support to linalg.buffer_allocNicolas Vasilache2019-08-197-79/+149
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This CL adds an integer attribute to linalg.buffer_alloc and lowering to LLVM. The alignment is constrained to be a positive power of 2. Lowering to LLVM produces the pattern: ``` %[[alloc:.*]] = llvm.call @malloc(%[[s]]) : (!llvm.i64) -> !llvm<"i8*"> %[[cast:.*]] = llvm.bitcast %[[alloc]] : !llvm<"i8*"> to !llvm.i64 %[[rem:.*]] = llvm.urem %[[cast]], %[[c16]] : !llvm.i64 %[[drem:.*]] = llvm.sub %[[c16]], %[[rem]] : !llvm.i64 %[[off:.*]] = llvm.urem %[[drem]], %[[c16]] : !llvm.i64 llvm.getelementptr %{{.*}}[%[[off]]] : (!llvm<"i8*">, !llvm.i64) -> !llvm<"i8*"> ``` where `ptr` is aligned on `align` by computing the address `ptr + (align - ptr % align) % align`. To allow dealloc op to still be able to free memory, additional information is needed in the buffer type. The buffer type is thus extended with an extra i8* for the base allocation address. PiperOrigin-RevId: 264244455
| * Add support for Operation interfaces.River Riddle2019-08-196-114/+285
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Operation interfaces, as the name suggests, are those registered at the Operation level. These interfaces provide an opaque view into derived operations, by providing a virtual interface that must be implemented. As an example, the Linalg dialect implements an interface LinalgOp that provides general queries about some of the dialects library operations. These queries may provide things like: the number of parallel loops, the number of inputs and outputs, etc. Operation interfaces are defined by overriding the CRTP base class OpInterface. This class takes as a template parameter, a `Traits` class that defines a Concept and a Model class. These classes provide an implementation of concept-based polymorphism, where the Concept defines a set of virtual methods that are overridden by the Model that is templated on the concrete operation type. It is important to note that these classes should be pure in that they contain no non-static data members. PiperOrigin-RevId: 264218741
| * NFC: Don't assume that all operation traits are within the 'OpTrait::' ↵River Riddle2019-08-193-23/+25
| | | | | | | | | | | | | | | | namespace. This places an unnecessary restriction that all traits are within this namespace. PiperOrigin-RevId: 264212000
| * Fix parsing/printing of spv.globalVariable and spv._address_ofMahesh Ravishankar2019-08-198-207/+236
| | | | | | | | | | | | | | | | | | | | | | | | Change the prining/parsing of spv.globalVariable to print the type of the variable after the ':' to be consistent with MLIR convention. The spv._address_of should print the variable type after the ':'. It was mistakenly printing the address of the return value. Add a (missing) test that should have caught that. Also move spv.globalVariable and spv._address_of tests to structure-ops.mlir. PiperOrigin-RevId: 264204686
| * NFC: Move LLVMIR, SDBM, and StandardOps to the Dialect/ directory.River Riddle2019-08-1996-128/+128
| | | | | | | | PiperOrigin-RevId: 264193915
| * [spirv] Add spv.ReturnValueLei Zhang2019-08-197-20/+158
| | | | | | | | | | | | | | | | | | This CL adds the spv.ReturnValue op and its tests. Also adds a InFunctionScope trait to make sure that the op stays inside a function. To be consistent, ModuleOnly trait is changed to InModuleScope. PiperOrigin-RevId: 264193081
| * Refactor linalg lowering to LLVMNicolas Vasilache2019-08-197-223/+268
| | | | | | | | | | | | | | | | | | | | | | | | | | The linalg.view type used to be lowered to a struct containing a data pointer, offset, sizes/strides information. This was problematic when passing to external functions due to ABI, struct padding and alignment issues. The linalg.view type is now lowered to LLVMIR as a *pointer* to a struct containing the data pointer, offset and sizes/strides. This simplifies the interfacing with external library functions and makes it trivial to add new functions without creating a shim that would go from a value type struct to a pointer type. The consequences are that: 1. lowering explicitly uses llvm.alloca in lieu of llvm.undef and performs the proper llvm.load/llvm.store where relevant. 2. the shim creation function `getLLVMLibraryCallDefinition` disappears. 3. views are passed by pointer, scalars are passed by value. In the future, other structs will be passed by pointer (on a per-need basis). PiperOrigin-RevId: 264183671
| * Add alignment support for llvm.allocaNicolas Vasilache2019-08-185-5/+59
| | | | | | | | | | | | Extend the LLVM dialect AllocaOp with an alignment attribute. PiperOrigin-RevId: 264068306
| * InitLLVM already initializes PrettyStackTraceProgramJacques Pienaar2019-08-184-10/+2
| | | | | | | | | | | | Remove extra PrettyStackTraceProgram and use InitLLVM consistently. PiperOrigin-RevId: 264041205
| * Change from llvm::make_unique to std::make_uniqueJacques Pienaar2019-08-1774-205/+195
| | | | | | | | | | | | | | | | Switch to C++14 standard method as llvm::make_unique has been removed ( https://reviews.llvm.org/D66259). Also mark some targets as c++14 to ease next integrates. PiperOrigin-RevId: 263953918
| * NFC: Add header blocks to improve readability.River Riddle2019-08-171-2/+10
| | | | | | | | PiperOrigin-RevId: 263951251
| * Add spirv::GlobalVariableOp that allows module level definition of variablesMahesh Ravishankar2019-08-1712-238/+801
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | FuncOps in MLIR use explicit capture. So global variables defined in module scope need to have a symbol name and this should be used to refer to the variable within the function. This deviates from SPIR-V spec, which assigns an SSA value to variables at all scopes that can be used to refer to the variable, which requires SPIR-V functions to allow implicit capture. To handle this add a new op, spirv::GlobalVariableOp that can be used to define module scope variables. Since instructions need an SSA value, an new spirv::AddressOfOp is added to convert a symbol reference to an SSA value for use with other instructions. This also means the spirv::EntryPointOp instruction needs to change to allow initializers to be specified using symbol reference instead of SSA value The current spirv::VariableOp which returns an SSA value (as defined by SPIR-V spec) can still be used to define function-scope variables. PiperOrigin-RevId: 263951109
| * NFC: Modernize and cleanup standard ops.River Riddle2019-08-161-64/+46
| | | | | | | | PiperOrigin-RevId: 263891926
| * NFC: Refactor the PassInstrumentation framework to operate on Operation ↵River Riddle2019-08-165-98/+61
| | | | | | | | | | | | | | | | instead of llvm::Any. Now that functions and modules are operations, Operation makes more sense as the opaque object to refer to both. PiperOrigin-RevId: 263883913
| * NFC: Move the Type::is* predicates to StandardTypes.cppRiver Riddle2019-08-162-26/+26
| | | | | | | | | | | | These methods are currently defined 'inline' in StandardTypes.h, but this may create linker errors if StandardTypes.h isn't included at the use site. PiperOrigin-RevId: 263850328
| * Fix minor typos in the documentationMLIR Team2019-08-162-12/+12
| | | | | | | | PiperOrigin-RevId: 263805025
| * [spirv] Extend spv.array with LayoutinfoDenis Khalikov2019-08-167-21/+138
| | | | | | | | | | | | | | | | Extend spv.array with Layoutinfo to support (de)serialization. Closes tensorflow/mlir#80 PiperOrigin-RevId: 263795304
| * Refactor DialectConversion to convert the signatures of blocks when they are ↵River Riddle2019-08-161-33/+41
| | | | | | | | | | | | | | | | moved. Often we want to ensure that block arguments are converted before operations that use them. This refactors the current implementation to be cleaner/less frequent by triggering conversion when a set of blocks are moved/inlined; or when legalization is successful. PiperOrigin-RevId: 263795005
| * C++14 is now default enabled in LLVM, remove obsolete CMake flag.Jacques Pienaar2019-08-161-3/+3
| | | | | | | | PiperOrigin-RevId: 263776602
| * Remove C++11 requirement set in cmakelistsJacques Pienaar2019-08-161-5/+0
| | | | | | | | | | | | C++14 is now the required. PiperOrigin-RevId: 263772579
| * Extend vector.outerproduct with an optional 3rd argumentNicolas Vasilache2019-08-167-115/+198
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This CL adds an optional third argument to the vector.outerproduct instruction. When such a third argument is specified, it is added to the result of the outerproduct and is lowered to FMA intrinsic when the lowering supports it. In the future, we can add an attribute on the `vector.outerproduct` instruction to modify the operations for which to emit code (e.g. "+/*", "max/+", "min/+", "log/exp" ...). This CL additionally performs minor cleanups in the vector lowering and adds tests to improve coverage. This has been independently verified to result in proper fma instructions for haswell as follows. Input: ``` func @outerproduct_add(%arg0: vector<17xf32>, %arg1: vector<8xf32>, %arg2: vector<17x8xf32>) -> vector<17x8xf32> { %2 = vector.outerproduct %arg0, %arg1, %arg2 : vector<17xf32>, vector<8xf32> return %2 : vector<17x8xf32> } } ``` Command: ``` mlir-opt vector-to-llvm.mlir -vector-lower-to-llvm-dialect --disable-pass-threading | mlir-opt -lower-to-cfg -lower-to-llvm | mlir-translate --mlir-to-llvmir | opt -O3 | llc -O3 -march=x86-64 -mcpu=haswell -mattr=fma,avx2 ``` Output: ``` outerproduct_add: # @outerproduct_add # %bb.0: ... vmovaps 112(%rbp), %ymm8 vbroadcastss %xmm0, %ymm0 ... vbroadcastss 64(%rbp), %ymm15 vfmadd213ps 144(%rbp), %ymm8, %ymm0 # ymm0 = (ymm8 * ymm0) + mem ... vfmadd213ps 400(%rbp), %ymm8, %ymm9 # ymm9 = (ymm8 * ymm9) + mem ... ``` PiperOrigin-RevId: 263743359
| * Simplify the classes that support SPIR-V conversion.Mahesh Ravishankar2019-08-153-60/+67
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Modify the Type converters to have a SPIRVBasicTypeConverter which only handles conversion from standard types to SPIRV types. Rename SPIRVEntryFnConverter to SPIRVTypeConverter. This contains the SPIRVBasicTypeConverter within it. Remove SPIRVFnLowering class and have separate utility methods to lower a function as entry function or a non-entry function. The current setup could end with diamond inheritence that is not very friendly to use. For example, you could define the following Op conversion methods that lower from a dialect "Foo" which resuls in diamond inheritance. template<typename OpTy> class FooDialect : public SPIRVOpLowering<OpTy> {...}; class FooFnLowering : public FooDialect, SPIRVFnLowering {...}; PiperOrigin-RevId: 263597101
| * Add BuiltIn EnumAttr to SPIR-V dialectMahesh Ravishankar2019-08-158-10/+204
| | | | | | | | | | | | | | | | | | | | Generate the EnumAttr to represent BuiltIns in SPIR-V dialect. The builtIn can be specified as a StringAttr with value being the name of the builtin. Extend Decoration (de)serialization to handle BuiltIns. Also fix an error in the SPIR-V dialect generator script. PiperOrigin-RevId: 263596624
| * ExecutionEngine: fix after upstream LLVM ORC updateAlex Zinenko2019-08-151-5/+6
| | | | | | | | | | | | | | | | LLVM r368707 updated the APIs in llvm::orc::DynamicLibrarySearchGenerator to use unique_ptr for holding the instance of the generator. Update our uses of DynamicLibrarySearchGenerator in the ExecutionEngine to reflect that. PiperOrigin-RevId: 263539855
| * Add support for Dialect interfaces.River Riddle2019-08-144-1/+305
| | | | | | | | | | | | | | | | | | | | Dialect interfaces are virtual apis registered to a specific dialect instance. Dialect interfaces are generally useful for transformation passes, or analyses, that want to opaquely operate on operations within a given dialect. These interfaces generally involve wide coverage over the entire dialect. A dialect interface can be defined by inheriting from the CRTP base class DialectInterfaceBase::Base. This class provides the necessary utilities for registering an interface with the dialect so that it can be looked up later. Dialects overriding an interface may register an instance via 'Dialect::addInterfaces'. This API works very similarly to the respective addOperations/addTypes/etc. This will allow for a transformation/utility to later query the interface from an opaque dialect instance via 'getInterface<T>'. A utility class 'DialectInterfaceCollection' is also provided that will collect all of the dialects that implement a specific interface within a given module. This allows for simplifying the API of interface lookups. PiperOrigin-RevId: 263489015
| * Refactor ElementsAttr::getValue and DenseElementsAttr::getSplatValue.River Riddle2019-08-148-106/+179
| | | | | | | | | | | | All 'getValue' variants now require that the index is valid, queryable via 'isValidIndex'. 'getSplatValue' now requires that the attribute is a proper splat. This allows for querying these methods on DenseElementAttr with all possible value types; e.g. float, int, APInt, etc. This also allows for removing unnecessary conversions to Attribute that really want the underlying value. PiperOrigin-RevId: 263437337
| * Move remaining linalg ops to ODS - NFCNicolas Vasilache2019-08-146-425/+405
| | | | | | | | | | | | | | | | This CL moves the linalg.load/range/store ops to ODS. Minor cleanups are performed. Additional invalid IR tests are added for coverage. PiperOrigin-RevId: 263432110
| * Allow the use of the $cppClass template variable in verifier code blocks.Ben Vanik2019-08-141-3/+7
| | | | | | | | PiperOrigin-RevId: 263378198
| * Refactor linalg.view lowering to LLVM - NFCNicolas Vasilache2019-08-142-38/+28
| | | | | | | | | | | | This CL fuses the emission of size and stride information and makes it clearer which indexings are stepped over when querying the positions. This refactor was motivated by an index calculation bug in the stride computation. PiperOrigin-RevId: 263341610
| * Move linalg.slice to ODSNicolas Vasilache2019-08-148-235/+205
| | | | | | | | PiperOrigin-RevId: 263334168
| * Add a utility script to auto-generate CHECK commands for mlir test cases.River Riddle2019-08-131-0/+201
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This script is a utility to add FileCheck patterns to an mlir file. The script will heuristically insert CHECK/CHECK-LABEL commands for each line within the file. By default this script will also try to insert string substitution blocks for all SSA value names. The script is designed to make adding checks to a test case fast, it is *not* designed to be authoritative about what constitutes a good test! Note: Some cases may not be handled well, e.g. operands to operations with regions, but this script is only intended to be a starting point. Example usage: $ generate-test-checks.py foo.mlir $ mlir-opt foo.mlir -transformation | generate-test-checks.py module { func @fold_extract_element(%arg0: index) -> (f32, f16, f16, i32) { %cst = constant 4.500000e+00 : f32 %cst_0 = constant -2.000000e+00 : f16 %cst_1 = constant 0.000000e+00 : f16 %c64_i32 = constant 64 : i32 return %cst, %cst_0, %cst_1, %c64_i32 : f32, f16, f16, i32 } } // CHECK-LABEL: func @fold_extract_element( // CHECK-SAME: [[VAL_0:%.*]]: index) -> (f32, f16, f16, i32) { // CHECK: [[VAL_1:%.*]] = constant 4.500000e+00 : f32 // CHECK: [[VAL_2:%.*]] = constant -2.000000e+00 : f16 // CHECK: [[VAL_3:%.*]] = constant 0.000000e+00 : f16 // CHECK: [[VAL_4:%.*]] = constant 64 : i32 // CHECK: return [[VAL_1]], [[VAL_2]], [[VAL_3]], [[VAL_4]] : f32, f16, f16, i32 // CHECK: } PiperOrigin-RevId: 263242983
| * Add unreachable to avoid GCC -Wreturn-type warningjpienaar2019-08-131-0/+3
| | | | | | | | | | | | | | | | GCC warns of control reaching end of non-void function (-Wreturn-type). Closes tensorflow/mlir#75 PiperOrigin-RevId: 263214601
| * Fix indexing issue in lowering of linalg.sliceNicolas Vasilache2019-08-132-3/+28
| | | | | | | | | | | | | | | | | | | | This CL fixes the stepping through operands when emitting the view sizes of linalg.slice to LLVMIR. This is now consistent with the strides emission. A relevant test is added. Fix suggested by Alex Zinenko, thanks! PiperOrigin-RevId: 263150922
| * LLVM dialect: introduce fmuladd intrinsic as operationAlex Zinenko2019-08-132-0/+32
| | | | | | | | | | | | | | | | | | | | | | This operation is important to achieve decent performance in computational kernels. In LLVM, it is implemented as an intrinsic (through function declaration and function call). Thanks to MLIR's extendable set of operations, it does not have to differentiate between built-ins and intrinsics, so fmuladd is introduced as a general type-polymorphic operation. Custom printing and parsing will be added later. PiperOrigin-RevId: 263106305
| * GenerateCubinAccessors: use LLVM dialect constantsAlex Zinenko2019-08-132-96/+57
| | | | | | | | | | | | | | | | | | | | | | | | The GenerateCubinAccessors was generating functions that fill dynamically-allocated memory with the binary constant of a CUBIN attached as a stirng attribute to the GPU kernel. This approach was taken to circumvent the missing support for global constants in the LLVM dialect (and MLIR in general). Global constants were recently added to the LLVM dialect. Change the GenerateCubinAccessors pass to emit a global constant array of characters and a function that returns a pointer to the first character in the array. PiperOrigin-RevId: 263092052
| * Express ownership transfer in PassManager API through std::unique_ptr (NFC)Mehdi Amini2019-08-1266-169/+217
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Since raw pointers are always passed around for IR construct without implying any ownership transfer, it can be error prone to have implicit ownership transferred the same way. For example this code can seem harmless: Pass *pass = .... pm.addPass(pass); pm.addPass(pass); pm.run(module); PiperOrigin-RevId: 263053082
OpenPOWER on IntegriCloud