Skip to content

Commit

Permalink
Fix invalid escape sequence in rocm_agent_enumerator, which are depre…
Browse files Browse the repository at this point in the history
…cated in Python3

In Python3, unescaped backslashes in regular expressions are deprecated, and these were generating SyntaxWarnings.

Patch submitted by (Tianao Ge <getianao@gmail.com>) on github:
#55

Change-Id: Icbcf2803291add5b5f3971ac9901a8927d23f225
  • Loading branch information
ShwetakAMD authored and dayatsin-amd committed Jan 4, 2024
1 parent c9905a8 commit 429baf0
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions rocm_agent_enumerator
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ def getGCNISA(line, match_from_beginning = False):
return result.group(0)
return None

@staticVars(search_name=re.compile("gfx[0-9a-fA-F]+(:[-+:\w]+)?"))
@staticVars(search_name=re.compile(r"gfx[0-9a-fA-F]+(:[-+:\w]+)?"))
def getGCNArchName(line):
result = getGCNArchName.search_name.search(line)

Expand Down Expand Up @@ -149,9 +149,9 @@ def readFromROCMINFO(search_arch_name = False):

# search AMDGCN gfx ISA
if search_arch_name is True:
line_search_term = re.compile("\A\s+Name:\s+(amdgcn-amd-amdhsa--gfx\d+)")
line_search_term = re.compile(r"\A\s+Name:\s+(amdgcn-amd-amdhsa--gfx\d+)")
else:
line_search_term = re.compile("\A\s+Name:\s+(gfx\d+)")
line_search_term = re.compile(r"\A\s+Name:\s+(gfx\d+)")
for line in rocminfo_output:
if line_search_term.match(line) is not None:
if search_arch_name is True:
Expand All @@ -172,7 +172,7 @@ def readFromLSPCI():
except:
lspci_output = []

target_search_term = re.compile("1002:\w+")
target_search_term = re.compile(r"1002:\w+")
for line in lspci_output:
search_result = target_search_term.search(line)
if search_result is not None:
Expand Down

0 comments on commit 429baf0

Please sign in to comment.