Skip to content

Commit 69fc091

Browse files
teijeongtensorflower-gardener
authored andcommitted
Fix TransposeConv op's declaration
TransposeConv has tensor 1 as its weight, but the definition and tests sometimes assume tensor 2 as weight. PiperOrigin-RevId: 348865651 Change-Id: I5f0aed5a17ef60778540655654726358ac7ad0a5
1 parent fe0dcca commit 69fc091

File tree

2 files changed

+4
-5
lines changed

2 files changed

+4
-5
lines changed

tensorflow/compiler/mlir/lite/ir/tfl_ops.td

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -592,7 +592,7 @@ def TFL_TransposeConvOp: TFL_Op<"transpose_conv", [
592592
PredOpTrait<"input and output must have same element type",
593593
TFL_TCresVTEtIsSameAsOp<0, 2>>,
594594
AccumulatorUniformScale<3, 1, 2>,
595-
AffineQuantizedOpInterface, AffineOpCoefficient<0, 2>,
595+
AffineQuantizedOpInterface, AffineOpCoefficient<0, 1>,
596596
TFL_SparseOp]> {
597597
let summary = "Transpose convolution operator";
598598

@@ -620,7 +620,6 @@ def TFL_TransposeConvOp: TFL_Op<"transpose_conv", [
620620
// AffineQuantizedOpInterface:
621621
int GetChannelDimIndex() { return 0; }
622622
int GetQuantizationDimIndex() { return 0; }
623-
int GetAffineOperandIndex() { return 2; }
624623
// SparseOpInterface:
625624
std::vector<int> GetSparseOperands() { return {1}; }
626625
std::vector<std::vector<int>> GetFloatBlockSize() { return {}; }

tensorflow/compiler/mlir/lite/tests/prepare-quantize-signed.mlir

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -153,16 +153,16 @@ func @QuantizeFullyConnected(%arg0: tensor<1x224x224x3xf32>) -> tensor<1x112x112
153153
func @QuantizeTransposeConv(%arg0: tensor<32x4x4x128xf32>, %arg1: tensor<4xi32>) -> tensor<1x32x42x128xf32> {
154154
%w = constant dense<127.0> : tensor<1x32x42x128xf32>
155155
%b = constant dense<0.0> : tensor<1x32x42x128xf32>
156-
%tc = "tfl.transpose_conv"(%arg1, %arg0, %w, %b) {padding = "SAME", stride_h = 2 : i32, stride_w = 2 : i32} : (tensor<4xi32>, tensor<32x4x4x128xf32>, tensor<1x32x42x128xf32>, tensor<1x32x42x128xf32>) -> tensor<1x32x42x128xf32>
156+
%tc = "tfl.transpose_conv"(%arg1, %w, %arg0, %b) {padding = "SAME", stride_h = 2 : i32, stride_w = 2 : i32} : (tensor<4xi32>, tensor<1x32x42x128xf32>, tensor<32x4x4x128xf32>, tensor<1x32x42x128xf32>) -> tensor<1x32x42x128xf32>
157157
return %tc : tensor<1x32x42x128xf32>
158158

159159
// CHECK: %[[CST:.*]] = constant dense<1.270000e+02> : tensor<1x32x42x128xf32>
160160
// CHECK: %[[QUANTIZE:.*]] = "tfl.quantize"(%[[CST]]) {qtype = tensor<1x32x42x128x!quant.uniform<i8<-127:127>:f32:0, {1.000000e+00}>>, volatile}
161161
// CHECK: %[[DEQUANTIZE:.*]] = "tfl.dequantize"(%[[QUANTIZE]]) : (tensor<1x32x42x128x!quant.uniform<i8<-127:127>:f32:0, {1.000000e+00}>>) -> tensor<1x32x42x128xf32>
162-
// CHECK: "tfl.transpose_conv"(%arg1, %arg0, %[[DEQUANTIZE]]
162+
// CHECK: "tfl.transpose_conv"(%arg1, %[[DEQUANTIZE]], %arg0,
163163

164164
// PerTensor: %[[CST:.*]] = constant dense<1.270000e+02> : tensor<1x32x42x128xf32>
165165
// PerTensor: %[[QUANTIZE:.*]] = "tfl.quantize"(%[[CST]]) {qtype = tensor<1x32x42x128x!quant.uniform<i8<-127:127>:f32, 1.000000e+00>>, volatile}
166166
// PerTensor: %[[DEQUANTIZE:.*]] = "tfl.dequantize"(%[[QUANTIZE]]) : (tensor<1x32x42x128x!quant.uniform<i8<-127:127>:f32, 1.000000e+00>>) -> tensor<1x32x42x128xf32>
167-
// PerTensor: "tfl.transpose_conv"(%arg1, %arg0, %[[DEQUANTIZE]]
167+
// PerTensor: "tfl.transpose_conv"(%arg1, %[[DEQUANTIZE]], %arg0,
168168
}

0 commit comments

Comments
 (0)