(
model,
params,
activation_quantize_type='moving_average_abs_max',
weight_quantize_type='channel_wise_abs_max',
save=False,
)
| 511 | |
| 512 | |
| 513 | def create_quant_model( |
| 514 | model, |
| 515 | params, |
| 516 | activation_quantize_type='moving_average_abs_max', |
| 517 | weight_quantize_type='channel_wise_abs_max', |
| 518 | save=False, |
| 519 | ): |
| 520 | place = paddle.CUDAPlace(0) |
| 521 | scope = global_scope() |
| 522 | exe = paddle.static.Executor(place) |
| 523 | [ |
| 524 | inference_program, |
| 525 | feed_target_names, |
| 526 | fetch_targets, |
| 527 | ] = paddle.static.io.load_inference_model( |
| 528 | path_prefix=None, |
| 529 | executor=exe, |
| 530 | model_filename=model, |
| 531 | params_filename=params, |
| 532 | ) |
| 533 | graph = IrGraph(core.Graph(inference_program.desc), for_test=True) |
| 534 | |
| 535 | out_scale_op_list = [ |
| 536 | "conv2d", |
| 537 | "depthwise_conv2d", |
| 538 | "mul", |
| 539 | "matmul", |
| 540 | "relu", |
| 541 | "leaky_relu", |
| 542 | "relu6", |
| 543 | "sigmoid", |
| 544 | "tanh", |
| 545 | "prelu", |
| 546 | "swish", |
| 547 | "softmax", |
| 548 | "batch_norm", |
| 549 | "layer_norm", |
| 550 | "elementwise_add", |
| 551 | "pool2d", |
| 552 | "reshape2", |
| 553 | "transpose2", |
| 554 | "concat", |
| 555 | "elementwise_mul", |
| 556 | "scale", |
| 557 | "slice", |
| 558 | "hard_swish", |
| 559 | "hard_sigmoid", |
| 560 | "conv2d_transpose", |
| 561 | "gru", |
| 562 | "bilinear_interp", |
| 563 | "nearest_interp", |
| 564 | "trilinear_interp", |
| 565 | "flatten", |
| 566 | "flatten2", |
| 567 | "transpose", |
| 568 | "pad2d", |
| 569 | "reshape", |
| 570 | "layer_norm", |