Skip to content

Commit 6099208

Browse files
ai-edge-botcopybara-github
authored andcommitted
Automated Code Change
LiteRT-Converter-PiperOrigin-RevId: 820551714
1 parent e7164bb commit 6099208

File tree

1 file changed

+11
-10
lines changed

1 file changed

+11
-10
lines changed

tflite/converter/tools/versioning/op_signature.cc

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ std::vector<OpSignatureTensorSpec> GetOpSignatureTensorSpecs(
7373
// Check if the tensor is a constant tensor.
7474
if (buffer_idx != 0 && buffer_idx < model->buffers()->size()) {
7575
auto* buffer = model->buffers()->Get(buffer_idx);
76-
if (buffer->data() && buffer->data()->size() != 0) {
76+
if (buffer->data() && !buffer->data()->empty()) {
7777
tensor_spec.is_const = true;
7878
}
7979
}
@@ -143,16 +143,16 @@ OpSignature GetOpSignature(const OperatorCode* op_code, const Operator* op,
143143
const QuantizationParameters* weight_quant =
144144
weight_tensor->quantization();
145145
if (weight_quant && weight_quant->scale() &&
146-
weight_quant->scale()->size() && weight_tensor->shape() &&
147-
weight_tensor->shape()->size()) {
146+
!weight_quant->scale()->empty() && weight_tensor->shape() &&
147+
!weight_tensor->shape()->empty()) {
148148
op_sig.ext_options.fully_connected.is_per_channel_quantized =
149149
IsTensorSizeEqual(weight_quant->scale()->size(),
150150
weight_tensor->shape()->Get(0));
151151
}
152152
} break;
153153

154154
case BuiltinOperator_MUL: {
155-
if (op->inputs()->size() < 2 || op->outputs()->size() < 1) {
155+
if (op->inputs()->size() < 2 || op->outputs()->empty()) {
156156
break;
157157
}
158158
const Tensor* input1_tensor =
@@ -167,10 +167,10 @@ OpSignature GetOpSignature(const OperatorCode* op_code, const Operator* op,
167167
const QuantizationParameters* output_quant =
168168
output_tensor->quantization();
169169
if (input1_quant && input1_quant->scale() &&
170-
input1_quant->scale()->size() && input2_qunt &&
171-
input2_qunt->scale() && input2_qunt->scale()->size() &&
170+
!input1_quant->scale()->empty() && input2_qunt &&
171+
input2_qunt->scale() && !input2_qunt->scale()->empty() &&
172172
output_quant && output_quant->scale() &&
173-
output_quant->scale()->size()) {
173+
!output_quant->scale()->empty()) {
174174
op_sig.ext_options.mul.input1_scale = input1_quant->scale()->Get(0);
175175
op_sig.ext_options.mul.input2_scale = input2_qunt->scale()->Get(0);
176176
op_sig.ext_options.mul.output_scale = output_quant->scale()->Get(0);
@@ -192,7 +192,7 @@ OpSignature GetOpSignature(const OperatorCode* op_code, const Operator* op,
192192
filter_quant->scale()->size() == static_cast<size_t>(num_filters)) {
193193
op_sig.ext_options.conv_2d.is_per_channel_quantized = true;
194194
}
195-
if (input_tensor->shape() && input_tensor->shape()->size()) {
195+
if (input_tensor->shape() && !input_tensor->shape()->empty()) {
196196
int num_input_channels = input_tensor->shape()->Get(3);
197197
int num_filter_input_channels = filter_tensor->shape()->Get(3);
198198
op_sig.ext_options.conv_2d.is_grouped_convolution =
@@ -249,8 +249,9 @@ OpSignature GetOpSignature(const OperatorCode* op_code, const Operator* op,
249249
const Tensor* table_tensor =
250250
subgraph->tensors()->Get(op->inputs()->Get(1));
251251
const QuantizationParameters* table_quant = table_tensor->quantization();
252-
if (table_quant && table_quant->scale() && table_quant->scale()->size() &&
253-
table_tensor->shape() && table_tensor->shape()->size()) {
252+
if (table_quant && table_quant->scale() &&
253+
!table_quant->scale()->empty() && table_tensor->shape() &&
254+
!table_tensor->shape()->empty()) {
254255
op_sig.ext_options.embedding_lookup.is_per_channel_quantized =
255256
table_quant->scale()->size() > 1 &&
256257
IsTensorSizeEqual(table_quant->scale()->size(),

0 commit comments

Comments
 (0)