diff --git a/python/paddle/fluid/contrib/slim/quantization/post_training_quantization.py b/python/paddle/fluid/contrib/slim/quantization/post_training_quantization.py index a0b28243d2fd0eeb0d022dab1ba8a3a315e65cf4..6dcbf9e1e278afd574709c44948f2a9b8b97096b 100644 --- a/python/paddle/fluid/contrib/slim/quantization/post_training_quantization.py +++ b/python/paddle/fluid/contrib/slim/quantization/post_training_quantization.py @@ -562,8 +562,9 @@ class PostTrainingQuantization(object): for var_name in self._quantized_act_var_name: var_tensor = _load_variable_data(self._scope, var_name) var_tensor = var_tensor.ravel() - save_path = os.path.join(self._cache_dir, - var_name + "_" + str(iter) + ".npy") + save_path = os.path.join( + self._cache_dir, + var_name.replace("/", ".") + "_" + str(iter) + ".npy") np.save(save_path, var_tensor) else: for var_name in self._quantized_act_var_name: @@ -598,7 +599,7 @@ class PostTrainingQuantization(object): for var_name in self._quantized_act_var_name: sampling_data = [] filenames = [f for f in os.listdir(self._cache_dir) \ - if re.match(var_name + '_[0-9]+.npy', f)] + if re.match(var_name.replace("/", ".") + '_[0-9]+.npy', f)] for filename in filenames: file_path = os.path.join(self._cache_dir, filename) sampling_data.append(np.load(file_path))