2020-05-07 09:41:54 +08:00
|
|
|
//===-------------------------------------------------------*- tablegen -*-===//
|
|
|
|
//
|
|
|
|
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
|
|
|
// See https://llvm.org/LICENSE.txt for license information.
|
|
|
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#ifndef TCF_OPS
|
|
|
|
#define TCF_OPS
|
|
|
|
|
|
|
|
include "npcomp/Dialect/TCF/IR/TCFBase.td"
|
|
|
|
|
|
|
|
class TCF_Op<string mnemonic, list<OpTrait> traits = []>
|
|
|
|
: Op<TCF_Dialect, mnemonic, traits> {
|
|
|
|
}
|
|
|
|
|
|
|
|
// TODO: investigate effects framework for defining error semantics
|
|
|
|
// TODO: define in a general way across the dialect what "encounters an error" means.
|
|
|
|
|
|
|
|
// TODO: verify same dtype?
|
|
|
|
// TODO: what are the allowable dtypes?
|
|
|
|
def TCF_AddOp : TCF_Op<"add"> {
|
|
|
|
let summary = "Add two tensors.";
|
|
|
|
let description = [{
|
|
|
|
Add two tensors.
|
|
|
|
}];
|
|
|
|
let arguments = (ins AnyTensor:$lhs, AnyTensor:$rhs);
|
|
|
|
let results = (outs AnyTensor:$result);
|
2020-09-19 05:05:36 +08:00
|
|
|
|
|
|
|
let assemblyFormat = "$lhs `,` $rhs attr-dict `:` functional-type(operands, results)";
|
2020-05-07 09:41:54 +08:00
|
|
|
}
|
|
|
|
|
2020-09-18 09:56:01 +08:00
|
|
|
// TODO: Generalize this op appropriately and add more verification.
|
|
|
|
// For example, an unranked operand probably should be allowed and verified
|
|
|
|
// dynamically in TCF->TCP lowering if needed.
|
|
|
|
def TCF_MatmulOp : TCF_Op<"matmul"> {
|
|
|
|
let summary = "Performs a matrix multiplication";
|
2020-05-07 09:41:54 +08:00
|
|
|
let description = [{
|
2020-09-18 09:56:01 +08:00
|
|
|
Performs a matrix multiplication.
|
2020-05-07 09:41:54 +08:00
|
|
|
|
2020-09-18 09:56:01 +08:00
|
|
|
The tensors have dimensions:
|
|
|
|
- lhs: [M, K]
|
|
|
|
- rhs: [K, N]
|
|
|
|
- result: [M, N]
|
2020-05-07 09:41:54 +08:00
|
|
|
|
2020-09-18 09:56:01 +08:00
|
|
|
If the `K` dimension mismatches between the operands, this op aborts the
|
|
|
|
program.
|
2020-05-07 09:41:54 +08:00
|
|
|
}];
|
2020-09-18 09:56:01 +08:00
|
|
|
let arguments = (ins 2DTensorOf<[F32]>:$lhs, 2DTensorOf<[F32]>:$rhs);
|
|
|
|
let results = (outs 2DTensorOf<[F32]>:$result);
|
2020-05-07 09:41:54 +08:00
|
|
|
|
2020-09-18 09:56:01 +08:00
|
|
|
let assemblyFormat = "$lhs `,` $rhs attr-dict `:` functional-type(operands, results)";
|
2020-05-07 09:41:54 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
#endif // #ifndef TCF_OPS
|