@@ -495,9 +495,13 @@ def get_op_name(name):
495
495
return op_name
496
496
497
497
def backward_quantization (op_detail , op ):
498
- scales = np .asarray (op_detail ["quantization" ][0 ], dtype = np .float32 )
499
- zero_points = np .asarray (op_detail ["quantization" ][1 ], dtype = np .float32 )
500
- return (op - zero_points ) * scales
498
+ if not 'quantization' in op_detail or \
499
+ (input_detail ['quantization' ][0 ] == 0.0 and input_detail ['quantization' ][1 ] == 0 ):
500
+ return op
501
+ else :
502
+ scales = np .asarray (op_detail ['quantization' ][0 ], dtype = np .float32 )
503
+ zero_points = np .asarray (op_detail ['quantization' ][1 ], dtype = np .float32 )
504
+ return (op - zero_points ) * scales
501
505
502
506
def searh_json_tensor_detail (name ):
503
507
tensor_detail_dict = None
@@ -518,16 +522,16 @@ def searh_json_tensor_detail(name):
518
522
519
523
for input_detail in input_details :
520
524
if not 'quantization' in input_detail or \
521
- (input_detail [" quantization" ][0 ] == 0.0 and input_detail [" quantization" ][1 ] == 0 ):
525
+ (input_detail [' quantization' ][0 ] == 0.0 and input_detail [' quantization' ][1 ] == 0 ):
522
526
523
527
tensors [input_detail ['index' ]] = tf .placeholder (
524
528
dtype = input_detail ['dtype' ],
525
529
shape = input_detail ['shape' ],
526
530
name = get_op_name (input_detail ['name' ]))
527
531
528
532
else :
529
- scales = np .asarray (input_detail [" quantization" ][0 ], dtype = np .float32 )
530
- zero_points = np .asarray (input_detail [" quantization" ][1 ], dtype = np .float32 )
533
+ scales = np .asarray (input_detail [' quantization' ][0 ], dtype = np .float32 )
534
+ zero_points = np .asarray (input_detail [' quantization' ][1 ], dtype = np .float32 )
531
535
inp = tf .placeholder (
532
536
dtype = np .float32 ,
533
537
shape = input_detail ['shape' ],
0 commit comments