2019-01-17 01:26:16 +08:00
|
|
|
// RUN: mlir-tblgen -gen-reference-implementations -I %S/../../include %s | FileCheck %s
|
|
|
|
|
|
|
|
#ifdef OP_BASE
|
|
|
|
#else
|
|
|
|
include "mlir/IR/op_base.td"
|
|
|
|
#endif // OP_BASE
|
|
|
|
|
|
|
|
def X_AddOp : Op<"x.add">,
|
|
|
|
Arguments<(ins Tensor:$lhs, Tensor:$rhs)>,
|
|
|
|
Results<[Tensor]> {
|
|
|
|
// TODO: extract referenceImplementation to Op.
|
|
|
|
// TODO: shrink the reference implementation
|
|
|
|
code referenceImplementation = [{
|
|
|
|
auto *lhsMemRef = *(f->getArguments().begin());
|
|
|
|
auto *rhsMemRef = *(f->getArguments().begin() + 1);
|
|
|
|
auto *resultMemRef = *(f->getArguments().begin() + 2);
|
|
|
|
|
|
|
|
Bindable lhs, rhs, result;
|
Fix improperly indexed DimOp in LowerVectorTransfers.cpp
This CL fixes a misunderstanding in how to build DimOp which triggered
execution issues in the CPU path.
The problem is that, given a `memref<?x4x?x8x?xf32>`, the expressions to
construct the dynamic dimensions should be:
`dim %arg, 0 : memref<?x4x?x8x?xf32>`
`dim %arg, 2 : memref<?x4x?x8x?xf32>`
and
`dim %arg, 4 : memref<?x4x?x8x?xf32>`
Before this CL, we wold construct:
`dim %arg, 0 : memref<?x4x?x8x?xf32>`
`dim %arg, 1 : memref<?x4x?x8x?xf32>`
`dim %arg, 2 : memref<?x4x?x8x?xf32>`
and expect the other dimensions to be constants.
This assumption seems consistent at first glance with the syntax of alloc:
```
%tensor = alloc(%M, %N, %O) : memref<?x4x?x8x?xf32>
```
But this was actuallyincorrect.
This CL also makes the relevant functions available to EDSCs and removes
duplication of the incorrect function.
PiperOrigin-RevId: 229622766
2019-01-17 06:06:20 +08:00
|
|
|
auto lhsShape = emitter.makeBoundSizes(lhsMemRef);
|
2019-01-17 01:26:16 +08:00
|
|
|
|
|
|
|
auto ivs = makeBindables(lhsShape.size());
|
|
|
|
Bindable zero, one;
|
|
|
|
// Same bindable, all equal to `zero`.
|
|
|
|
SmallVector<Bindable, 8> zeros(ivs.size(), zero);
|
|
|
|
// Same bindable, all equal to `one`.
|
|
|
|
SmallVector<Bindable, 8> ones(ivs.size(), one);
|
|
|
|
Indexed IA(lhs), IB(rhs), IC(result);
|
|
|
|
block = edsc::Block({
|
|
|
|
ForNest(ivs, zeros, lhsShape, ones, {
|
|
|
|
IC[ivs] = IA[ivs] + IB[ivs]
|
|
|
|
})
|
|
|
|
});
|
|
|
|
}];
|
|
|
|
}
|
|
|
|
|
|
|
|
// CHECK: printRefImplementation
|