2019-01-17 01:26:16 +08:00
|
|
|
// RUN: mlir-tblgen -gen-reference-implementations -I %S/../../include %s | FileCheck %s
|
|
|
|
|
|
|
|
#ifdef OP_BASE
|
|
|
|
#else
|
2019-03-02 05:48:24 +08:00
|
|
|
include "mlir/IR/OpBase.td"
|
2019-01-17 01:26:16 +08:00
|
|
|
#endif // OP_BASE
|
|
|
|
|
|
|
|
def X_AddOp : Op<"x.add">,
|
2019-02-02 01:16:31 +08:00
|
|
|
Arguments<(ins Tensor:$A, Tensor:$B)>,
|
|
|
|
Results<(outs Tensor: $C)> {
|
2019-01-17 01:26:16 +08:00
|
|
|
// TODO: extract referenceImplementation to Op.
|
|
|
|
code referenceImplementation = [{
|
2019-03-18 21:52:23 +08:00
|
|
|
auto ivs = IndexHandle::makeIndexHandles(view_A.rank());
|
2019-03-25 01:45:22 +08:00
|
|
|
auto pivs = IndexHandle::makeIndexHandlePointers(ivs);
|
2019-03-18 21:52:23 +08:00
|
|
|
IndexedValue A(arg_A), B(arg_B), C(arg_C);
|
|
|
|
LoopNestBuilder(pivs, view_A.getLbs(), view_A.getUbs(), view_A.getSteps())({
|
|
|
|
C(ivs) = A(ivs) + B(ivs)
|
|
|
|
});
|
2019-01-17 01:26:16 +08:00
|
|
|
}];
|
|
|
|
}
|
|
|
|
|
2019-01-17 22:29:05 +08:00
|
|
|
// CHECK: printRefImplementation
|