summaryrefslogtreecommitdiffstats
path: root/mlir
Commit message (Collapse)AuthorAgeFilesLines
...
* Reduce reliance on custom grown Jit implementation - NFCNicolas Vasilache2019-08-213-215/+150
| | | | | | | | | | This CL makes use of the standard LLVM LLJIT and removes the need for a custom JIT implementation within MLIR. To achieve this, one needs to clone (i.e. serde) the produced llvm::Module into a new LLVMContext. This is currently necessary because the llvm::LLVMContext is owned by the LLVMDialect, somewhat deep in the call hierarchy. In the future we should remove the reliance of serding the llvm::Module by allowing the injection of an LLVMContext from the top-level. Unfortunately this will require deeper API changes and impact multiple places. It is therefore left for future work. PiperOrigin-RevId: 264737459
* Remove the wrapping function in SPIR-V (de)serializationLei Zhang2019-08-2117-488/+412
| | | | | | | | | Previously Module and Function are builtinn constructs in MLIR. Due to the structural requirements we must wrap the SPIR-V module inside a Function inside a Module. Now the requirement is lifted and we can remove the wrapping function! :) PiperOrigin-RevId: 264736051
* NFC: Update in-code documentation for type.MLIR Team2019-08-211-3/+3
| | | | PiperOrigin-RevId: 264734014
* Fix minor typos in TestingGuide and OpDefinitions.Chintan Kaur2019-08-212-6/+6
| | | | PiperOrigin-RevId: 264733092
* NFC: Update in-code documentation for function-type.MLIR Team2019-08-211-1/+1
| | | | PiperOrigin-RevId: 264723462
* Add a hook to the OpAsmDialectInterface to allow providing a special name ↵River Riddle2019-08-213-24/+57
| | | | | | | | for the operation result. This generalizes the current special handling for constant operations(they get named 'cst'/'true'/'false'/etc.) PiperOrigin-RevId: 264723379
* [TableGen] Add a `StaticShapeMemRefOf` trait.MLIR Team2019-08-213-0/+18
| | | | | | The trait specifies that the `MemRefOf` has to have a static shape. PiperOrigin-RevId: 264692758
* Automated rollback of commit b9dc2e481818315f2f0d87455349f497f6118a4cRiver Riddle2019-08-214-300/+35
| | | | PiperOrigin-RevId: 264672975
* NFC: Make the ModuleState field in the ModulePrinter optional.River Riddle2019-08-211-43/+35
| | | | | | The ModuleState is only used for printing aliases, which is only done when printing the top-level module. PiperOrigin-RevId: 264664138
* Add iterator support to ElementsAttr and SparseElementsAttr.River Riddle2019-08-214-35/+300
| | | | | | This will allow iterating the values of a non-opaque ElementsAttr, with all of the types currently supported by DenseElementsAttr. This should help reduce the amount of specialization on DenseElementsAttr. PiperOrigin-RevId: 264637293
* Move the parser extensions for aliases currently on Dialect to a new ↵River Riddle2019-08-215-28/+85
| | | | | | | | OpAsmDialectInterface. This will allow for adding more hooks for controlling parser behavior without bloating Dialect in the common case. This cl also adds iteration support to the DialectInterfaceCollection. PiperOrigin-RevId: 264627846
* [spirv] Support i1 as bool typeLei Zhang2019-08-213-13/+26
| | | | PiperOrigin-RevId: 264612014
* Support variadic ops in declarative rewrite rulesLei Zhang2019-08-216-127/+482
| | | | | | | | | | | | | | | | | | | | | | | | This CL extends declarative rewrite rules to support matching and generating ops with variadic operands/results. For this, the generated `matchAndRewrite()` method for each pattern now are changed to * Use "range" types for the local variables used to store captured values (`operand_range` for operands, `ArrayRef<Value *>` for values, *Op for results). This allows us to have a unified way of handling both single values and value ranges. * Create local variables for each operand for op creation. If the operand is variadic, then a `SmallVector<Value*>` will be created to collect all values for that operand; otherwise a `Value*` will be created. * Use a collective result type builder. All result types are specified via a single parameter to the builder. We can use one result pattern to replace multiple results of the matched root op. When that happens, it will require specifying types for multiple results. Add a new collective-type builder. PiperOrigin-RevId: 264588559
* Materialize spv.constants at use sitesLei Zhang2019-08-213-148/+233
| | | | | | | | | | | | | | | In SPIR-V binary format, constants are placed at the module level and referenced by instructions inside functions using their result <id>s. To model this natively (using SSA values for result <id>s), it means we need to have implicit capturing functions. We will lose the ability to have function passes if going down that path. Instead, this CL changes to materialize constants at their use sites in deserialization. It's cheap to copy constants in MLIR given that attributes is uniqued to MLIRContext. By localizing constants into functions, we can preserve isolated functions. PiperOrigin-RevId: 264582532
* NFC: Keep the dialect list in the context sorted by namespace.River Riddle2019-08-201-6/+14
| | | | | | Most dialects are initialized statically, which does not have a guaranteed initialization order. By keeping the dialect list sorted, we can guarantee a deterministic iteration order of dialects. PiperOrigin-RevId: 264522875
* NFC: Use a DenseSet instead of a DenseMap for DialectInterfaceCollection.River Riddle2019-08-202-7/+26
| | | | | | The interfaces are looked up by dialect, which can always be retrieved from an interface instance. PiperOrigin-RevId: 264516023
* NFC: Move the LangRef documentation on StandardOps to a new document.River Riddle2019-08-203-947/+956
| | | | | | The LangRef should contain documentation about the core system, and standard ops is a dialect just like any other. This will also simplify the transition when StandardOps is eventually split apart. PiperOrigin-RevId: 264514988
* NFC: Move AffineOps dialect to the Dialect sub-directory.River Riddle2019-08-2046-51/+51
| | | | PiperOrigin-RevId: 264482571
* Add spv.specConstant and spv._reference_ofLei Zhang2019-08-207-260/+658
| | | | | | | | | | | | | | | | | | | | | | | | | | | Similar to global variables, specialization constants also live in the module scope and can be referenced by instructions in functions in native SPIR-V. A direct modelling would be to allow functions in the SPIR-V dialect to implicit capture, but it means we are losing the ability to write passes for Functions. While in SPIR-V normally we want to process the module as a whole, it's not common to see multiple functions get used so we'd like to leave the door open for those cases. Therefore, similar to global variables, we introduce spv.specConstant to model three SPIR-V instructions: OpSpecConstantTrue, OpSpecConstantFalse, and OpSpecConstant. They do not return SSA value results; instead they have symbols and can only be referenced by the symbols. To use it in a function, we need to have another op spv._reference_of to turn the symbol into an SSA value. This breaks the tie and makes functions still explicit capture. Previously specialization constants were handled similarly as normal constants. That is incorrect given that specialization constant actually acts more like variable (without need to load and store). E.g., they cannot be de-duplicated like normal constants. This CL also refines various documents and comments. PiperOrigin-RevId: 264455172
* [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
OpenPOWER on IntegriCloud