Fix post quant save bug, test=develop (#25370)

fix_copy_if_different
cc 5 years ago committed by GitHub
parent ea7e532598
commit 22720a1535
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -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))

Loading…
Cancel
Save