| Commit message (Collapse) | Author | Age | Files | Lines |
... | |
| |
| |
| |
| |
| |
| | |
Change the use of 'array' to 'tensor' to reflect the new flow that the tutorial will follow. Also tidy up some of the documentation, code comments, and fix a few out-dated links.
PiperOrigin-RevId: 265174676
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
Add an extra RewritePattern that does not convert types to rewrite a CopyOp that has non-identity permutations into a sequence of TransposeOp followed by a CopyOp without such permutations.
This RewitePattern is made to fail in the non-permutation case so that the conversion pattern can kick in to lower to LLVM.
This is an instance of A->A->B lowering where A->A is done by a RewritePattern in case_1 and A->B is done by a ConversionPatternRewriter when not(case_1).
PiperOrigin-RevId: 265171380
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
Add a conversion pattern that transforms a linalg.transpose op into:
1. A function entry `alloca` operation to allocate a ViewDescriptor.
2. A load of the ViewDescriptor from the pointer allocated in 1.
3. Updates to the ViewDescriptor to introduce the data ptr, offset, size
and stride. Size and stride are permutations of the original values.
4. A store of the resulting ViewDescriptor to the alloca'ed pointer.
The linalg.transpose op is replaced by the alloca'ed pointer.
PiperOrigin-RevId: 265169112
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
A linalg.transpose op is a pure metadata operation that takes a view + permutation map and produces
another view of the same underlying data, with a different reindexing. This is a
pure metadata operation that does not touch the underlying data.
Example:
```
%t = linalg.transpose %v (i, j) -> (j, i) : !linalg.view<?x?xf32>
```
PiperOrigin-RevId: 265139429
|
| |
| |
| |
| |
| |
| | |
Fixes tensorflow/mlir#72
PiperOrigin-RevId: 265097597
|
| |
| |
| |
| |
| |
| | |
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
|
| |
| |
| |
| | |
PiperOrigin-RevId: 265092922
|
| |
| |
| |
| |
| |
| | |
This CL is also purely moving code around for better file organization.
PiperOrigin-RevId: 265092566
|
| |
| |
| |
| |
| |
| | |
names for the basic block arguments in their body.
PiperOrigin-RevId: 265084627
|
| |
| |
| |
| |
| |
| | |
static-dimension-list consistent.
PiperOrigin-RevId: 265084348
|
| |
| |
| |
| |
| |
| | |
This is purely moving code around for better file organization.
PiperOrigin-RevId: 265082517
|
| |
| |
| |
| |
| |
| | |
One of the BufferAllocOp builders was improperly specified which triggered infinite recursion. This CL fixes it.
PiperOrigin-RevId: 265080371
|
| |
| |
| |
| |
| |
| |
| |
| | |
section.
Operations/Regions/Blocks represent the core IR building blocks and should be introduced before types and attributes.
PiperOrigin-RevId: 265079103
|
| |
| |
| |
| | |
PiperOrigin-RevId: 264969142
|
| |
| |
| |
| |
| |
| | |
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: 264968151
|
| |
| |
| |
| |
| |
| |
| |
| | |
* Add a section on dialect attribute values and attribute aliases
* Move FloatAttr into its alphabetically correct place
* Add a "Standard Attribute Values" section
PiperOrigin-RevId: 264959306
|
| |
| |
| |
| |
| |
| |
| |
| | |
* Alphabetize the type definitions
* Make 'Dialect specific types' a type-system subsection
* Merge Builtin types and Standard types
PiperOrigin-RevId: 264947721
|
| |
| |
| |
| |
| |
| |
| | |
Only a few important KHR extensions are registered to the
SPIR-V dialect for now.
PiperOrigin-RevId: 264939428
|
| |
| |
| |
| |
| |
| | |
Both sections are out-of-date and need to be updated. The dialect section is particularly bad in that it never actually mentions what a 'Dialect' is.
PiperOrigin-RevId: 264937905
|
| |
| |
| |
| | |
PiperOrigin-RevId: 264904489
|
| |
| |
| |
| |
| |
| |
| |
| | |
linalg.subview used to lower to a slice with a bounded range resulting in correct bounded accesses. However linalg.slice could still index out of bounds. This CL moves the bounding to linalg.slice.
LLVM select and cmp ops gain a more idiomatic builder.
PiperOrigin-RevId: 264897125
|
| |
| |
| |
| | |
PiperOrigin-RevId: 264881293
|
| |
| |
| |
| |
| |
| |
| | |
This CL pulls in capabilities defined in the spec and adds
support for (de)serialize capabilities of a spv.module.
PiperOrigin-RevId: 264877413
|
| |
| |
| |
| |
| |
| |
| |
| | |
This commit adds `PositiveI32Attr` and `PositiveI64Attr` to match positive
integers but not zero nor negative integers. This commit also adds
`HasAnyRankOfPred` to match tensors with the specified ranks.
PiperOrigin-RevId: 264867046
|
| |
| |
| |
| |
| |
| | |
Split out method into specialized instances + add an early exit. Should be NFC, but simplifies reading the logic slightly IMHO.
PiperOrigin-RevId: 264855529
|
| |
| |
| |
| |
| |
| | |
Currently the benefit is always set to 1 which limits the ability to do A->B->C lowering
PiperOrigin-RevId: 264854146
|
| |
| |
| |
| | |
PiperOrigin-RevId: 264827908
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
Operation interfaces generally require a bit of boilerplate code to connect all of the pieces together. This cl introduces mechanisms in the ODS to allow for generating operation interfaces via the 'OpInterface' class.
Providing a definition of the `OpInterface` class will auto-generate the c++
classes for the interface. An `OpInterface` includes a name, for the c++ class,
along with a list of interface methods. There are two types of methods that can be used with an interface, `InterfaceMethod` and `StaticInterfaceMethod`. They are both comprised of the same core components, with the distinction that `StaticInterfaceMethod` models a static method on the derived operation.
An `InterfaceMethod` is comprised of the following components:
* ReturnType
- A string corresponding to the c++ return type of the method.
* MethodName
- A string corresponding to the desired name of the method.
* Arguments
- A dag of strings that correspond to a c++ type and variable name
respectively.
* MethodBody (Optional)
- An optional explicit implementation of the interface method.
def MyInterface : OpInterface<"MyInterface"> {
let methods = [
// A simple non-static method with no inputs.
InterfaceMethod<"unsigned", "foo">,
// A new non-static method accepting an input argument.
InterfaceMethod<"Value *", "bar", (ins "unsigned":$i)>,
// Query a static property of the derived operation.
StaticInterfaceMethod<"unsigned", "fooStatic">,
// Provide the definition of a static interface method.
// Note: `ConcreteOp` corresponds to the derived operation typename.
StaticInterfaceMethod<"Operation *", "create",
(ins "OpBuilder &":$builder, "Location":$loc), [{
return builder.create<ConcreteOp>(loc);
}]>,
// Provide a definition of the non-static method.
// Note: `op` corresponds to the derived operation variable.
InterfaceMethod<"unsigned", "getNumInputsAndOutputs", (ins), [{
return op.getNumInputs() + op.getNumOutputs();
}]>,
];
PiperOrigin-RevId: 264754898
|
| |
| |
| |
| |
| |
| | |
Fixes tensorflow/mlir#97
PiperOrigin-RevId: 264743395
|
| |
| |
| |
| | |
PiperOrigin-RevId: 264742130
|
| |
| |
| |
| |
| |
| | |
LowerToLLVMDialect.cpp - NFC
PiperOrigin-RevId: 264740014
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
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
|
| |
| |
| |
| |
| |
| |
| |
| |
| | |
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
|
| |
| |
| |
| | |
PiperOrigin-RevId: 264734014
|
| |
| |
| |
| | |
PiperOrigin-RevId: 264733092
|
| |
| |
| |
| | |
PiperOrigin-RevId: 264723462
|
| |
| |
| |
| |
| |
| |
| |
| | |
for the operation result.
This generalizes the current special handling for constant operations(they get named 'cst'/'true'/'false'/etc.)
PiperOrigin-RevId: 264723379
|
| |
| |
| |
| |
| |
| | |
The trait specifies that the `MemRefOf` has to have a static shape.
PiperOrigin-RevId: 264692758
|
| |
| |
| |
| | |
PiperOrigin-RevId: 264672975
|
| |
| |
| |
| |
| |
| | |
The ModuleState is only used for printing aliases, which is only done when printing the top-level module.
PiperOrigin-RevId: 264664138
|
| |
| |
| |
| |
| |
| | |
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
|
| |
| |
| |
| |
| |
| |
| |
| | |
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
|
| |
| |
| |
| | |
PiperOrigin-RevId: 264612014
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
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
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
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
|
| |
| |
| |
| |
| |
| | |
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
|
| |
| |
| |
| |
| |
| | |
The interfaces are looked up by dialect, which can always be retrieved from an interface instance.
PiperOrigin-RevId: 264516023
|
| |
| |
| |
| |
| |
| | |
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
|
| |
| |
| |
| | |
PiperOrigin-RevId: 264482571
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
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
|