File tree Expand file tree Collapse file tree 2 files changed +5
-3
lines changed
include/mlir/Dialect/Quant/IR Expand file tree Collapse file tree 2 files changed +5
-3
lines changed Original file line number Diff line number Diff line change @@ -143,9 +143,11 @@ class QuantizedType : public Type {
143
143
// / Casts from a type based on the storageType to a corresponding type based
144
144
// / on this type (returns nullptr if the cast is not valid).
145
145
// / Examples:
146
+ // / `candidate type` -> `return type`
146
147
// / i8 -> !quant.uniform<i8:f32, 1.0>
147
148
// / tensor<4xi8> -> tensor<4x!quant.uniform<i8:f32, 1.0}>>
148
149
// / vector<4xi8> -> vector<4x!quant.uniform<i8:f32, 1.0>>
150
+ // / It is assumed above that this type's quantization is `<i8:f32, 1.0>`.
149
151
Type castFromStorageType (Type candidateType);
150
152
151
153
// / Casts from a type based on a QuantizedType to a corresponding type based
Original file line number Diff line number Diff line change @@ -127,7 +127,7 @@ QuantizedType::getQuantizedElementType(Type primitiveOrContainerType) {
127
127
128
128
Type QuantizedType::castFromStorageType (Type candidateType) {
129
129
if (candidateType == getStorageType ()) {
130
- // i.e. i32 -> quant<"uniform[i8:f32]{1.0}">
130
+ // i.e. i8 -> quant<"uniform[i8:f32]{1.0}">
131
131
return *this ;
132
132
}
133
133
if (llvm::isa<RankedTensorType>(candidateType)) {
@@ -137,11 +137,11 @@ Type QuantizedType::castFromStorageType(Type candidateType) {
137
137
getStorageType ());
138
138
}
139
139
if (llvm::isa<UnrankedTensorType>(candidateType)) {
140
- // i.e. tensor<i8 > -> tensor<!quant<"uniform[i8:f32]{1.0}">>
140
+ // i.e. tensor<xi8 > -> tensor<x !quant<"uniform[i8:f32]{1.0}">>
141
141
return UnrankedTensorType::get (getStorageType ());
142
142
}
143
143
if (llvm::isa<VectorType>(candidateType)) {
144
- // i.e. tensor <4xi8> -> tensor <4x!quant<"uniform[i8:f32]{1.0}">>
144
+ // i.e. vector <4xi8> -> vector <4x!quant<"uniform[i8:f32]{1.0}">>
145
145
return VectorType::get (llvm::cast<VectorType>(candidateType).getShape (),
146
146
getStorageType ());
147
147
}
You can’t perform that action at this time.
0 commit comments