From b6a38d09636566d78477c43f5610775cad5799e0 Mon Sep 17 00:00:00 2001 From: wanghuancoder Date: Wed, 21 Feb 2024 15:09:05 +0800 Subject: [PATCH] [security] refine _get_program_cache_key (#61827) (#61896) * security, refine _get_program_cache_key --- python/paddle/base/executor.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/python/paddle/base/executor.py b/python/paddle/base/executor.py index fff2771da14c2..65a5d79d7ff93 100755 --- a/python/paddle/base/executor.py +++ b/python/paddle/base/executor.py @@ -682,7 +682,7 @@ def _get_varname_from_block(block): ) -def _get_program_cache_key(feed, fetch_list): +def _get_feed_fetch_var_names(feed, fetch_list): feed_var_names = [] if isinstance(feed, dict): feed_var_names = list(feed.keys()) @@ -690,7 +690,11 @@ def _get_program_cache_key(feed, fetch_list): for i, each in enumerate(feed): feed_var_names += list(each.keys()) fetch_var_names = list(map(_to_name_str, fetch_list)) - return str(feed_var_names + fetch_var_names) + return feed_var_names + fetch_var_names + + +def _get_program_cache_key(feed, fetch_list): + return str(_get_feed_fetch_var_names(feed, fetch_list)) def _as_lodtensor(data, place, dtype=None): @@ -1026,7 +1030,7 @@ def _get_program_and_executor(self, cached_data): if enable_inplace or enable_addto: # inplace should skip feed and fetch var - skip_var_names = eval(_get_program_cache_key(feed, fetch_list)) + skip_var_names = _get_feed_fetch_var_names(feed, fetch_list) _apply_inplace_addto_pass( program, enable_inplace, enable_addto, skip_var_names )