2020-08-13 10:28:04 +08:00
|
|
|
//===- ATen.td ---------------------------------------------*- tablegen -*-===//
|
|
|
|
//
|
|
|
|
// This file is licensed 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
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
2020-10-23 05:13:26 +08:00
|
|
|
#ifndef NPCOMP_DIALECT_ATEN_IR_ATEN_OPS
|
|
|
|
#define NPCOMP_DIALECT_ATEN_IR_ATEN_OPS
|
2020-08-13 10:28:04 +08:00
|
|
|
|
2020-10-23 05:13:26 +08:00
|
|
|
include "npcomp/Dialect/ATen/IR/ATenDialect.td"
|
|
|
|
include "npcomp/Dialect/ATen/IR/ATenOpInterface.td"
|
2020-10-23 14:31:34 +08:00
|
|
|
include "npcomp/Dialect/Torch/IR/OpInterfaces.td"
|
|
|
|
include "npcomp/Dialect/Torch/IR/TorchBase.td"
|
2020-08-13 10:28:04 +08:00
|
|
|
|
|
|
|
include "mlir/Interfaces/SideEffectInterfaces.td"
|
2020-08-28 06:09:10 +08:00
|
|
|
|
2020-08-13 10:28:04 +08:00
|
|
|
// TODO: convert to "let results =" style
|
2020-08-28 06:09:10 +08:00
|
|
|
// TODO: Rename prefix from "aten" to "ATen" for consistency.
|
2020-08-13 10:28:04 +08:00
|
|
|
|
|
|
|
class aten_Op<string mnemonic, list<OpTrait> traits = [StatisticsOpInterface]> :
|
2020-08-28 06:09:10 +08:00
|
|
|
Op<ATen_Dialect, mnemonic, traits>;
|
2020-08-13 10:28:04 +08:00
|
|
|
|
|
|
|
|
|
|
|
// Most ops are automatically generated from pytorch specs.
|
2020-10-23 05:13:26 +08:00
|
|
|
include "npcomp/Dialect/ATen/IR/GeneratedATenOps.td"
|
2020-10-28 09:13:23 +08:00
|
|
|
include "npcomp/Dialect/ATen/IR/LegacyGeneratedATenOps.td"
|
2020-08-13 10:28:04 +08:00
|
|
|
|
|
|
|
def aten_BatchNormOp: aten_Op<"batch_norm", [NoSideEffect, StatisticsOpInterface]>,
|
|
|
|
Results<(outs AnyTensor:$output, AnyTensor:$save_mean, AnyTensor:$save_invstd)> {
|
|
|
|
let arguments = (
|
|
|
|
ins AnyType:$arg0,
|
|
|
|
AnyType:$arg1,
|
|
|
|
AnyType:$arg2,
|
|
|
|
AnyType:$arg3,
|
|
|
|
AnyType:$arg4,
|
|
|
|
AnyType:$arg5,
|
|
|
|
AnyType:$arg6,
|
|
|
|
AnyType:$arg7,
|
|
|
|
AnyType:$arg8
|
|
|
|
);
|
|
|
|
|
|
|
|
let summary = "BatchNorm operator";
|
|
|
|
let description = [{
|
|
|
|
BatchNorm operator
|
|
|
|
}];
|
|
|
|
let extraClassDeclaration = [{
|
|
|
|
std::map<std::string, uint64_t> getStatistics();
|
|
|
|
}];
|
|
|
|
}
|
|
|
|
|
|
|
|
// We have list constants, which come out of pytorch. Represent them using
|
|
|
|
// our own constant-like type, which gets lowered to std_ConstantOp later.
|
|
|
|
def aten_ConstantOp: aten_Op<"constant", [NoSideEffect]>,
|
|
|
|
Results<(outs AnyType)> {
|
|
|
|
let summary = "Constant operator";
|
|
|
|
let description = [{
|
|
|
|
Constant operator
|
|
|
|
}];
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
def aten_FlattenOp: aten_Op<"flatten", [NoSideEffect, StatisticsOpInterface]>,
|
|
|
|
Results<(outs AnyTensor)> {
|
|
|
|
let arguments = (
|
|
|
|
ins AnyType:$arg0,
|
|
|
|
AnyType:$arg1,
|
|
|
|
AnyType:$arg2
|
|
|
|
);
|
|
|
|
|
|
|
|
let summary = "Flatten operator";
|
|
|
|
let description = [{
|
|
|
|
Flatten operator
|
|
|
|
}];
|
|
|
|
let extraClassDeclaration = [{
|
|
|
|
std::map<std::string, uint64_t> getStatistics();
|
|
|
|
}];
|
|
|
|
}
|
|
|
|
|
|
|
|
def aten_MaxPool2dOp: aten_Op<"max_pool2d", [NoSideEffect, StatisticsOpInterface]>,
|
|
|
|
Results<(outs AnyTensor)> {
|
|
|
|
let arguments = (
|
|
|
|
ins AnyType:$arg0,
|
|
|
|
AnyType:$arg1,
|
|
|
|
AnyType:$arg2,
|
|
|
|
AnyType:$arg3,
|
|
|
|
AnyType:$arg4,
|
|
|
|
AnyType:$arg5
|
|
|
|
);
|
|
|
|
|
|
|
|
let summary = "MaxPool2d operator";
|
|
|
|
let description = [{
|
|
|
|
MaxPool2d operator
|
|
|
|
}];
|
|
|
|
let extraClassDeclaration = [{
|
|
|
|
std::map<std::string, uint64_t> getStatistics();
|
|
|
|
}];
|
|
|
|
}
|
|
|
|
|
|
|
|
def aten_TypeCastOp : aten_Op<"type_cast", [NoSideEffect]>,
|
|
|
|
Results<(outs AnyType)> {
|
|
|
|
let summary = "TypeCast operator";
|
|
|
|
let arguments = (
|
|
|
|
ins AnyType:$x
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2020-10-23 05:13:26 +08:00
|
|
|
#endif // NPCOMP_DIALECT_ATEN_IR_ATEN_OPS
|