-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create TcpTypes.td and move type definitions there
- Loading branch information
1 parent
02e950c
commit 6dbabbd
Showing
5 changed files
with
97 additions
and
45 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
//===-------------------------------------------------------*- tablegen -*-===// | ||
// | ||
// 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 | ||
// Also available under a BSD-style license. See LICENSE. | ||
// | ||
//===----------------------------------------------------------------------===// | ||
|
||
#ifndef TCP_TYPES | ||
#define TCP_TYPES | ||
|
||
include "mlir/IR/AttrTypeBase.td" | ||
include "mlir/IR/DialectBase.td" | ||
|
||
include "mlir-tcp/Dialect/IR/TcpBase.td" | ||
|
||
//===----------------------------------------------------------------------===// | ||
// Tcp Type Definitions. | ||
//===----------------------------------------------------------------------===// | ||
|
||
// The base class of a quantized type. | ||
// Param tuple is: [bitwidth, zeropt, smantissa, sexp, low_end, high_end]. | ||
// Where low and high ends are 0,255 when unsigned, -128,127 when signed, for | ||
// the 8-bit case. | ||
class Tcp_QuantizedType<string n, list<int> params, bit signed> | ||
: Type<And<[CPred<"$_self.isa<mlir::quant::QuantizedType>()">, | ||
CPred<"$_self.cast<mlir::quant::QuantizedType>()" # | ||
".getStorageTypeIntegralWidth() == " # !head(params)>]>, | ||
"Q" # !if (signed, "int", "uint") # !head(params) # " type"> { | ||
string name = n; | ||
string asTraitArgsStr = !interleave(params, ", ") # | ||
!if(signed, ", true", ", false"); | ||
} | ||
|
||
//===----------------------------------------------------------------------===// | ||
// Quantized Integer Types. | ||
//===----------------------------------------------------------------------===// | ||
//===----------------------------------------------------------------------===// | ||
// Name Symmetry Sign | ||
//===----------------------------------------------------------------------===// | ||
// q8ua : asymmetric unsigned | ||
// q8sa : asymmetric signed | ||
// q8ss : symmetric signed | ||
// q16ss : symmetric signed | ||
//===----------------------------------------------------------------------===// | ||
def Tcp_QuantizedInt : AnyTypeOf<[Tcp_QuantizedType<"q8ua", [8], 0>, | ||
Tcp_QuantizedType<"q8sa", [8], 1>, | ||
Tcp_QuantizedType<"q8ss", [8, 0], 1>, | ||
Tcp_QuantizedType<"q16ss", [16, 0], 1>]>; | ||
|
||
def Tcp_Scalar : AnyTypeOf<[AnyFloat, AnySignlessInteger, Tcp_QuantizedInt]>; | ||
def Tcp_Tensor : RankedTensorOf<[Tcp_Scalar]>; | ||
def Tcp_TensorOrScalar : AnyTypeOf<[Tcp_Tensor, Tcp_Scalar]>; | ||
|
||
def Tcp_FloatTensor : RankedTensorOf<[AnyFloat]>; | ||
def Tcp_FloatOrIntTensor : RankedTensorOf<[AnyFloat, AnySignlessInteger]>; | ||
|
||
#endif // TCP_TYPES |