2020-09-29 03:02:35 +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 TORCH_OPS
|
|
|
|
#define TORCH_OPS
|
|
|
|
|
|
|
|
include "npcomp/Dialect/Torch/IR/TorchBase.td"
|
2020-10-23 14:31:34 +08:00
|
|
|
include "npcomp/Dialect/Torch/IR/OpInterfaces.td"
|
2020-09-29 03:02:35 +08:00
|
|
|
|
|
|
|
class Torch_Op<string mnemonic, list<OpTrait> traits = []>
|
|
|
|
: Op<Torch_Dialect, mnemonic, traits> {
|
|
|
|
}
|
|
|
|
|
2020-10-23 14:31:34 +08:00
|
|
|
// TODO: Add alias mapping from the signature and use it to implement the
|
|
|
|
// effects interface (since whether the kernel_call has side effects is
|
|
|
|
// dependent on its metadata).
|
|
|
|
def Torch_KernelCallOp : Torch_Op<"kernel_call", [
|
|
|
|
DeclareOpInterfaceMethods<TorchKernelOpInterface>]> {
|
2020-09-30 05:17:34 +08:00
|
|
|
let summary = "Calls a Torch custom kernel";
|
|
|
|
let description = [{
|
|
|
|
Torch kernel calls are matched by the runtime based on signature, including
|
|
|
|
the fully qualified kernel name (i.e. "namespace::name") and the tuple of
|
|
|
|
argument types. This op models such an invocation.
|
|
|
|
}];
|
|
|
|
|
|
|
|
let arguments = (ins
|
2020-10-23 14:31:34 +08:00
|
|
|
StrAttr:$kernelName,
|
|
|
|
Variadic<AnyTorchType>:$args,
|
|
|
|
StrArrayAttr:$sigArgTypes,
|
|
|
|
StrArrayAttr:$sigRetTypes,
|
|
|
|
BoolAttr:$sigIsVararg,
|
|
|
|
BoolAttr:$sigIsVarret,
|
|
|
|
BoolAttr:$sigIsMutable
|
|
|
|
// TODO: Add alias mapping.
|
2020-09-30 05:17:34 +08:00
|
|
|
);
|
|
|
|
let results = (outs
|
|
|
|
Variadic<AnyTorchType>:$results
|
|
|
|
);
|
|
|
|
|
|
|
|
let assemblyFormat = [{
|
2020-10-23 14:31:34 +08:00
|
|
|
$kernelName $args `:` functional-type($args, results) attr-dict
|
2020-09-30 05:17:34 +08:00
|
|
|
}];
|
2020-09-29 03:02:35 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
#endif // TORCH_OPS
|