summaryrefslogtreecommitdiffstats
path: root/mlir/test/mlir-cpu-runner
Commit message (Collapse)AuthorAgeFilesLines
* [mlir] Change the syntax of AffineMapAttr and IntegerSetAttr to avoid ↵River Riddle2020-01-131-2/+2
| | | | | | | | | | conflicts with function types. Summary: The current syntax for AffineMapAttr and IntegerSetAttr conflict with function types, making it currently impossible to round-trip function types(and e.g. FuncOp) in the IR. This revision changes the syntax for the attributes by wrapping them in a keyword. AffineMapAttr is wrapped with `affine_map<>` and IntegerSetAttr is wrapped with `affine_set<>`. Reviewed By: nicolasvasilache, ftynse Differential Revision: https://reviews.llvm.org/D72429
* [mlir] mlir-cpu-runner test's cblas_interface should export functions on WindowsKern Handa2020-01-095-7/+66
| | | | | | | | | | | | This change fixes the build on Windows, so that cblas_interface.dll exports functions correctly and an implib is created and installed correctly. Currently, LLVM cannot be consumed on Windows after it has been installed in a location because cblas_interface.lib is not created/installed, thus failing the import check in `LLVMExports.cmake`. Differential Revision: https://reviews.llvm.org/D72384
* [mlir] Fix -Wunneeded-internal-declarationFangrui Song2019-12-241-1/+1
|
* Adjust License.txt file to use the LLVM licenseMehdi Amini2019-12-235-65/+20
| | | | PiperOrigin-RevId: 286906740
* Add runtime utils support for print_memref_i8Nicolas Vasilache2019-12-183-15/+50
| | | | | | This CL adds print_memref_i8 along with a unit test. PiperOrigin-RevId: 286299237
* [VectorOps] Replace iostream with stdio in support lib for vector.printAart Bik2019-12-181-6/+8
| | | | PiperOrigin-RevId: 286252829
* [VectorOps] Add vector.print definition, with lowering supportAart Bik2019-12-182-0/+19
| | | | | | | | | | | | | | | | Examples: vector.print %f : f32 vector.print %x : vector<4xf32> vector.print %y : vector<3x4xf32> vector.print %z : vector<2x3x4xf32> LLVM lowering replaces these with fully unrolled calls into a small runtime support library that provides some basic printing operations (single value, opening closing bracket, comma, newline). PiperOrigin-RevId: 286230325
* Move cpu runner utils templates to .hNicolas Vasilache2019-12-123-159/+175
| | | | | | | | This allows reusing the implementation in various places by just including and permits more easily writing test functions without explicit template instantiations. This also modifies UnrankedMemRefType to take a template type parameter since it cannot be type agnostic atm. PiperOrigin-RevId: 285187711
* Add UnrankedMemRef Typenmostafa2019-12-054-15/+93
| | | | | | | Closes tensorflow/mlir#261 COPYBARA_INTEGRATE_REVIEW=https://github.com/tensorflow/mlir/pull/261 from nmostafa:nmostafa/unranked 96b6e918f6ed64496f7573b2db33c0b02658ca45 PiperOrigin-RevId: 284037040
* Fix ViewOp to have at most one offset operandAlex Zinenko2019-12-031-3/+3
| | | | | | | | | | | | | | | | | | | | | As described in the documentation, ViewOp is expected to take an optional dynamic offset followed by a list of dynamic sizes. However, the ViewOp parser did not include a check for the offset being a single value and accepeted a list of values instead. Furthermore, several tests have been exercising the wrong syntax of a ViewOp, passing multiple values to the dyanmic stride list, which was not caught by the parser. The trailing values could have been erronously interpreted as dynamic sizes. This is likely due to resyntaxing of the ViewOp, with the previous syntax taking the list of sizes before the offset. Update the tests to use the syntax with the offset preceding the sizes. Worse, the conversion of ViewOp to the LLVM dialect assumed the wrong order of operands with offset in the trailing position, and erronously relied on the permissive parsing that interpreted trailing dynamic offset values as leading dynamic sizes. Fix the lowering to use the correct order of operands. PiperOrigin-RevId: 283532506
* Implement Linalg to loops lowering as a patternNicolas Vasilache2019-11-272-7/+7
| | | | | | This CL rewrites the linalg ops to loops transformations as patterns that can be targeted directly from Tablegen. Reliance on OpFolder is removed and to cope with it we introduce local folding patterns that are applied greedily. PiperOrigin-RevId: 282765550
* Automated rollback of commit d60133f89bb08341718bb3132b19bc891f7d4f4dNicolas Vasilache2019-11-262-10/+10
| | | | PiperOrigin-RevId: 282574110
* Changing directory shortcut for CPU/GPU runner utils.Christian Sigg2019-11-252-10/+10
| | | | | | | Moving cuda-runtime-wrappers.so into subdirectory to match libmlir_runner_utils.so. Provide parent directory when running test and load .so from subdirectory. PiperOrigin-RevId: 282410749
* Add StridedMemRef<>::operator[] - NFCNicolas Vasilache2019-11-201-0/+29
| | | | | | This operator is used for internal debugging purposes. PiperOrigin-RevId: 281544152
* Fix pretty printer corner case in mlir_runner_utils.cpp.Nicolas Vasilache2019-11-192-27/+17
| | | | | | | In the particular case where the size of a memref dimension is 1, double printing would happen because printLast was called unconditionally. This CL fixes the print and updates an incorrect test that should have caught this in the first place. PiperOrigin-RevId: 281345142
* Change conversion CLI flag from -lower-to-llvm to -convert-std-to-llvmAlex Zinenko2019-11-191-4/+4
| | | | | | | | | | | | The command-line flag name `lower-to-llvm` for the pass performing dialect conversion from the Standard dialect to the LLVM dialect is misleading and inconsistent with most of the conversion passses. It leads the user to believe that there are no restrictions on what can be converted, while in fact only a subset of the Standard dialect can be converted (with operations from other dialects converted by separate passes). Use `convert-std-to-llvm` that better reflects what the pass does and is consistent with most other conversions. PiperOrigin-RevId: 281238797
* Add support for alignment attribute in std.alloc.Nicolas Vasilache2019-11-121-0/+2
| | | | | | | | | | | | This CL adds an extra pointer to the memref descriptor to allow specifying alignment. In a previous implementation, we used 2 types: `linalg.buffer` and `view` where the buffer type was the unit of allocation/deallocation/alignment and `view` was the unit of indexing. After multiple discussions it was decided to use a single type, which conflates both, so the memref descriptor now needs to carry both pointers. This is consistent with the [RFC-Proposed Changes to MemRef and Tensor MLIR Types](https://groups.google.com/a/tensorflow.org/forum/#!searchin/mlir/std.view%7Csort:date/mlir/-wKHANzDNTg/4K6nUAp8AAAJ). PiperOrigin-RevId: 279959463
* Update Linalg to use std.viewNicolas Vasilache2019-11-071-29/+26
| | | | | | Now that a view op has graduated to the std dialect, we can update Linalg to use it and remove ops that have become obsolete. As a byproduct, the linalg buffer and associated ops can also disappear. PiperOrigin-RevId: 279073591
* Lower vector transfer ops to loop.for operations.Nicolas Vasilache2019-10-182-10/+10
| | | | | | This allows mixing linalg operations with vector transfer operations (with additional modifications to affine ops) and is a step towards solving tensorflow/mlir#189. PiperOrigin-RevId: 275543361
* Decouple Linalg promotion from Linalg tiling - NFCNicolas Vasilache2019-10-171-2/+2
| | | | | | This CL creates a new Linalg promotion pass that operates on SubViewOp and decouples it from Linalg tiling. This is mostly moving code around. PiperOrigin-RevId: 275329213
* Consistent use of int in mlir_runner_utils.cppNicolas Vasilache2019-10-151-1/+1
| | | | | | This should fix the OSS build by only using int in template types. PiperOrigin-RevId: 274843584
* Add conversion for splat of vectors of 2+DNicolas Vasilache2019-10-153-39/+143
| | | | | | | This CL adds a missing lowering for splat of multi-dimensional vectors. Additional support is also added to the runtime utils library to allow printing memrefs with such vectors. PiperOrigin-RevId: 274794723
* Use llvm.func to define functions with wrapped LLVM IR function typeAlex Zinenko2019-10-102-10/+10
| | | | | | | | | | | | | | This function-like operation allows one to define functions that have wrapped LLVM IR function type, in particular variadic functions. The operation was added in parallel to the existing lowering flow, this commit only switches the flow to use it. Using a custom function type makes the LLVM IR dialect type system more consistent and avoids complex conversion rules for functions that previously had to use the built-in function type instead of a wrapped LLVM IR dialect type and perform conversions during the analysis. PiperOrigin-RevId: 273910855
* Fix Windows linkage errorNicolas Vasilache2019-10-091-10/+10
| | | | | | | This CL fixes bad macro names usage in mlir_runner_utils.h. The macro mlir_runner_utils_EXPORTS now matches what is defined in CMakeLists.txt. PiperOrigin-RevId: 273773931
* Start a minimal mlir_utils runtime library for testing debugging purposesNicolas Vasilache2019-10-076-40/+308
| | | | | | | | | | | Now that MLIR has a standardized StridedMemRef descriptor, it becomes very easy to interact with external library functions and build utilities directly in C++. This CL introduces basic printing support in a libmlir_utils.so. Unit tests are rewritten using this feature and also to improve coverage. For now, C mandates that we have a unique function for each MemRef element type and rank. In a future a simple unranked descriptor can be introduced to only require uniqu'ing by element type. PiperOrigin-RevId: 273304741
* Unify Linalg types by using strided memrefsNicolas Vasilache2019-10-012-32/+33
| | | | | | | This CL finishes the implementation of the Linalg + Affine type unification of the [strided memref RFC](https://groups.google.com/a/tensorflow.org/forum/#!topic/mlir/MaL8m2nXuio). As a consequence, the !linalg.view type, linalg::DimOp, linalg::LoadOp and linalg::StoreOp can now disappear and Linalg can use standard types everywhere. PiperOrigin-RevId: 272187165
* Fix JitRunner.cpp Error creation pattern and reactivate tests.Nicolas Vasilache2019-09-272-18/+16
| | | | | | | | | | linalg_integration_test.mlir and simple.mlir were temporarily disabled due to an OSS-only failure. The issue is that, once created, an llvm::Error must be explicitly checked before it can be discarded or overwritten. This CL fixes the issue and reenable the test. PiperOrigin-RevId: 271589651
* Disable failing testsJacques Pienaar2019-09-262-16/+18
| | | | PiperOrigin-RevId: 271460509
* Drop support for memrefs from JitRunnerAlex Zinenko2019-09-261-33/+35
| | | | | | | | | | | | | The support for functions taking and returning memrefs of floats was introduced in the first version of the runner, created before MLIR had reliable lowering of allocation/deallocation to library calls. It forcibly runs MLIR transformation convering affine, loop and standard dialects into the LLVM dialect, unlike the other runner flows that accept the LLVM dialect directly. Memref support leads to more complex layering and is generally fragile. Drop it in favor of functions returning a scalar, or library-based function calls to print memrefs and other data structures. PiperOrigin-RevId: 271330839
* Add missing lowering to CFG in mlir-cpu-runner + related cleanupMehdi Amini2019-09-011-2/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | - the list of passes run by mlir-cpu-runner included -lower-affine and -lower-to-llvm but was missing -lower-to-cfg (because -lower-affine at some point used to lower straight to CFG); add -lower-to-cfg in between. IR with affine ops can now be run by mlir-cpu-runner. - update -lower-to-cfg to be consistent with other passes (create*Pass methods were changed to return unique ptrs, but -lower-to-cfg appears to have been missed). - mlir-cpu-runner was unable to parse custom form of affine op's - fix link options - drop unnecessary run options from test/mlir-cpu-runner/simple.mlir (none of the test cases had loops) - -convert-to-llvmir was changed to -lower-to-llvm at some point, but the create pass method name wasn't updated (this pass converts/lowers to LLVM dialect as opposed to LLVM IR). Fix this. (If we prefer "convert", the cmd-line options could be changed to "-convert-to-llvm/cfg" then.) Signed-off-by: Uday Bondhugula <uday@polymagelabs.com> Closes tensorflow/mlir#115 PiperOrigin-RevId: 266666909
* Add mechanism to dump JIT-compiled objects to filesJacques Pienaar2019-08-301-0/+9
| | | | | | | | | | | This commit introduces the bits to be able to dump JIT-compile objects to external files by passing an object cache to OrcJit. The new functionality is tested in mlir-cpu-runner under the flag `dump-object-file`. Closes tensorflow/mlir#95 PiperOrigin-RevId: 266439265
* Add lowering of linalg.copy to an external C++ library and a test.Nicolas Vasilache2019-08-232-0/+33
| | | | | | This CL extends support for lowering of linalg to external C++ libraries with CopyOp. Currently this can only work when the permutation maps in the copies are identity. Future support for permutations will be added later. PiperOrigin-RevId: 265093025
* Add alignment support to linalg.buffer_allocNicolas Vasilache2019-08-191-1/+1
| | | | | | | | | | | | | | | | | | | | | | | 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
* Refactor linalg lowering to LLVMNicolas Vasilache2019-08-191-10/+8
| | | | | | | | | | | | | 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
* External library name mangling support for linalg.Nicolas Vasilache2019-08-092-18/+26
| | | | | | | | | | This CL introduces the ability to generate the external library name for Linalg operations. The problem is that neither mlir or C support overloading and we want a simplified form of name mangling that is still reasonable to read. This CL creates the name of the external call that Linalg expects from the operation name and the type of its arguments. The interface library names are updated and use new cases are added for FillOp. PiperOrigin-RevId: 262556833
* Automated rollback of commit 3708f53219aa2b201e82e7172c5064c1eb9d483bNicolas Vasilache2019-07-262-73/+9
| | | | PiperOrigin-RevId: 260136255
* Add sgemm specializations - NFCNicolas Vasilache2019-07-262-9/+73
| | | | | | | | | This CL adds a few specializations for sgemm. A minor change to alpha is made in cblas_interface.cpp to be compatible with actual BLAS calls. For now this is for internal testing purposes only. PiperOrigin-RevId: 260129027
* Fix linalg_matmul_impl interfacing with sgemmNicolas Vasilache2019-07-262-2/+2
| | | | | | This CL provides a fix that makes linal_matmul_impl compliant with the BLAS interface. Before this CL it would compute either C += A * B when called with cblas.cpp:cblas_sgemm implementation and C = A * B with other implementations. PiperOrigin-RevId: 260117367
* Replace linalg.for by loop.forNicolas Vasilache2019-07-161-1/+1
| | | | | | | With the introduction of the Loop dialect, uses of the `linalg.for` operation can now be subsumed 1-to-1 by `loop.for`. This CL performs the replacement and tests are updated accordingly. PiperOrigin-RevId: 258322565
* Lower affine control flow to std control flow to LLVM dialectNicolas Vasilache2019-07-121-1/+1
| | | | | | | | | | | | | This CL splits the lowering of affine to LLVM into 2 parts: 1. affine -> std 2. std -> LLVM The conversions mostly consists of splitting concerns between the affine and non-affine worlds from existing conversions. Short-circuiting of affine `if` conditions was never tested or exercised and is removed in the process, it can be reintroduced later if needed. LoopParametricTiling.cpp is updated to reflect the newly added ForOp::build. PiperOrigin-RevId: 257794436
* Resolving buffer operand of linalg.view doesnt have the informationMahesh Ravishankar2019-07-021-7/+7
| | | | | | | | | | | about the buffer size. This is needed to resolve the operand correctly. Add that information to view op serialization/deserialization Also modify the parsing of buffer type by splitting at 'x' to side-step issues with StringRef number parsing. PiperOrigin-RevId: 256188319
* Add buffer size information to Linalg::BufferType. If the size isMahesh Ravishankar2019-06-281-18/+18
| | | | | | | | constant then it is represented as <size x elementType>. If the size is not a compile time constant, then it is represented as <? x elementType>. PiperOrigin-RevId: 255619400
* Export symbols in cpu runner cblas libraryLei Zhang2019-06-192-9/+24
| | | | | | | | By default MSVC does not export any symbol and does not create a companion .lib for a .dll. This will cause problems when trying to link against the library. PiperOrigin-RevId: 254033454
* Add a definition of the library function to use when Linalg ops areMahesh Ravishankar2019-06-191-36/+0
| | | | | | lowered to LLVM, instead of expecting one to exist in the Module PiperOrigin-RevId: 253097382
* Add a lowering for Linalg matmul to LLVMNicolas Vasilache2019-06-196-70/+250
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This CL adds a lowering to LLVM for MamulOp and a corresponding integration test. View descriptor manipulation is moved from MLIR's LLVM dialect to C++ code compiled on the side. To this end a separation is introduced between `cblas.cpp` and `cblas_interface.cpp`, the latter operating on view types whose ABI correspond to the LLVM signature generated by MLIR. An intermediary step is introduced that allocates a new descriptor on the MLIR side for the purpose of passing it to LLVM. The reason for this extra step is that the ABI for by-value ViewType objects wants aligned descriptors, e.g.: ``` extern "C" void linalg_dot_impl(ViewType<float, 1> X, ViewType<float, 1> Y, BaseViewType<float> Z) { ... } ``` produces LLVM IR with the signature: ``` %struct.ViewType = type { %struct.BaseViewType, [1 x i64], [1 x i64] } %struct.BaseViewType = type { float*, i64 } define void @linalg_dot_impl(%struct.ViewType* byval align 8, %struct.ViewType* byval align 8, float*, i64) tensorflow/mlir#0 { ... } ``` We don't seem to be able to make such aligned allocations in the MLIR -> LLVM converter atm. Going through a level of indirection allows the test to pass. The temporary tradeoff is that the MLIR shims have to be written by hand. They will disappear in the future. PiperOrigin-RevId: 252670672
* Disable the mlir-cpu-runner tests on win32. llvm orc does not support ↵River Riddle2019-06-011-0/+5
| | | | | | | | the COFF rtld. -- PiperOrigin-RevId: 250556116
* Add lowering linalg.for to LLVM IRNicolas Vasilache2019-06-011-0/+1
| | | | | | | | | This CL adds lowering of linalg.for to LLVM IR and adds an IR test. This also replaces the usage of affine.for with linalg.for and enables the LLVM IR path in the integration test. -- PiperOrigin-RevId: 250503798
* Fix MacOS test: use %shlibext in lit command line to expand to .dylib on ↵Mehdi Amini2019-05-201-2/+2
| | | | | | | | MacOS and .so on Linux -- PiperOrigin-RevId: 249113478
* Cleanup linalg integration testNicolas Vasilache2019-05-203-49/+5
| | | | | | | | | | This CL performs post-commit cleanups. It adds the ability to specify which shared libraries to load dynamically in ExecutionEngine. The linalg integration test is updated to use a shared library. Additional minor cleanups related to LLVM lowering of Linalg are also included. -- PiperOrigin-RevId: 248346589
* Pipe Linalg to a cblas call via mlir-cpu-runnerNicolas Vasilache2019-05-203-8/+106
| | | | | | | | | This CL extends the execution engine to allow the additional resolution of symbols names that have been registered explicitly. This allows linking static library symbols that have not been explicitly exported with the -rdynamic linking flag (which is deemed too intrusive). -- PiperOrigin-RevId: 247969504
OpenPOWER on IntegriCloud