Potential issue after loading model twice
Created by: hshen14
Here is the usage scenario in our case:
- A single python unit test
- Load INT8 model, do the inference
- Load FP32 model, do the inference (will crash due to current key reuse mechanism)
- INT8 model is transformed from FP32 model, so all the shape and variable name are same
Here is the sample code for reference:
[int8_infer_program, feed_dict, fetch_targets] = fluid.io.load_inference_model(int8_model, exe) with fluid.program_guard(main_program=int8_infer_program): # do the int8 inference
[fp32_infer_program, feed_dict, fetch_targets] = fluid.io.load_inference_model(fp32_model, exe) with fluid.program_guard(main_program=fp32_infer_program): # do the fp32 inference
The crash shows "paddle.fluid.core.EnforceNotMet: Enforce failed. Expected requested_size >= size, but received requested_size:10035200 < size:40140800". We probably can fix the issue at key reuse side, however, the issue seems general (e.g, run FP16 model first and then FP32), and we would like to raise it for discussion and figure out a better solution.
Is it possible to have the mechanism to reset devicecontext/place/scope in Python API (e.g., p_blobmap in MKLDNNDeviceContext)? Any suggestions? Thanks.
@panyx0718 @Superjomn