Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[security] refine _get_program_cache_key #61827

Merged
merged 4 commits into from
Feb 21, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 7 additions & 3 deletions python/paddle/base/executor.py
Original file line number Diff line number Diff line change
Expand Up @@ -684,15 +684,19 @@ 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())
elif isinstance(feed, (list, tuple)):
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):
Expand Down Expand Up @@ -1028,7 +1032,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
)
Expand Down