mirror of
https://github.com/saymrwulf/pytorch.git
synced 2026-05-14 20:57:59 +00:00
Cleanup some Python2-related code (#78864)
Pull Request resolved: https://github.com/pytorch/pytorch/pull/78864 Approved by: https://github.com/janeyx99, https://github.com/jbschlosser
This commit is contained in:
parent
7adf929a99
commit
0fdc1caf02
2 changed files with 2 additions and 12 deletions
|
|
@ -1315,7 +1315,7 @@ def _compute_nparams_toprune(amount, tensor_size):
|
|||
if isinstance(amount, numbers.Integral):
|
||||
return amount
|
||||
else:
|
||||
return int(round(amount * tensor_size)) # int needed for Python 2
|
||||
return round(amount * tensor_size)
|
||||
|
||||
|
||||
def _validate_pruning_dim(t, dim):
|
||||
|
|
|
|||
|
|
@ -12,17 +12,7 @@ from typing import Match, Optional, Sequence, Mapping
|
|||
|
||||
|
||||
class CodeTemplate:
|
||||
# Python 2.7.5 has a bug where the leading (^[^\n\S]*)? does not work,
|
||||
# workaround via appending another [^\n\S]? inside
|
||||
|
||||
substitution_str = r"(^[^\n\S]*[^\n\S]?)?\$([^\d\W]\w*|\{,?[^\d\W]\w*\,?})"
|
||||
|
||||
# older versions of Python have a bug where \w* does not work,
|
||||
# so we need to replace with the non-shortened version [a-zA-Z0-9_]*
|
||||
# https://bugs.python.org/issue18647
|
||||
|
||||
substitution_str = substitution_str.replace(r"\w", r"[a-zA-Z0-9_]")
|
||||
|
||||
substitution_str = r"(^[^\n\S]*)?\$([^\d\W]\w*|\{,?[^\d\W]\w*\,?})"
|
||||
substitution = re.compile(substitution_str, re.MULTILINE)
|
||||
|
||||
pattern: str
|
||||
|
|
|
|||
Loading…
Reference in a new issue