Skip to content

Commit 980ac0e

Browse files
authored
[SYCLomatic] Support more python script migration rules (#2750)
Signed-off-by: Jiang, Zhiwei <[email protected]>
1 parent fc688e1 commit 980ac0e

File tree

3 files changed

+42
-0
lines changed

3 files changed

+42
-0
lines changed

Diff for: clang/test/dpct/python_migration/case_006/expected.py

+5
Original file line numberDiff line numberDiff line change
@@ -56,3 +56,8 @@
5656

5757
torch.xpu.set_stream(st)
5858
xpu.set_stream(st)
59+
60+
if torch.xpu.current_stream() != torch.xpu.current_stream():
61+
print("Not default stream")
62+
device = torch.device('xpu')
63+
extra_cuda_cflags=['-ffast-math', '']

Diff for: clang/test/dpct/python_migration/case_006/input.py

+5
Original file line numberDiff line numberDiff line change
@@ -56,3 +56,8 @@
5656

5757
torch.cuda.set_stream(st)
5858
cuda.set_stream(st)
59+
60+
if torch.cuda.current_stream() != torch.cuda.default_stream():
61+
print("Not default stream")
62+
device = torch.device('cuda')
63+
extra_cuda_cflags=['--use_fast_math', '--allow-unsupported-compiler']

Diff for: clang/tools/dpct/extensions/python_rules/python_build_script_migration_rule_pytorch_common.yaml

+32
Original file line numberDiff line numberDiff line change
@@ -247,3 +247,35 @@
247247
PythonSyntax: CUDA_HOME
248248
In: CUDA_HOME
249249
Out: SYCL_HOME
250+
251+
- Rule: rule_cuda_flag_use_fast_math
252+
Kind: PythonRule
253+
Priority: Fallback
254+
MatchMode: Partial
255+
PythonSyntax: cuda_flag_use_fast_math
256+
In: '--use_fast_math'
257+
Out: '-ffast-math'
258+
259+
- Rule: rule_cuda_flag_allow-unsupported-compiler
260+
Kind: PythonRule
261+
Priority: Fallback
262+
MatchMode: Partial
263+
PythonSyntax: cuda_flag_allow-unsupported-compiler
264+
In: '--allow-unsupported-compiler'
265+
Out: ''
266+
267+
- Rule: rule_cuda_default_stream
268+
Kind: PythonRule
269+
Priority: Fallback
270+
MatchMode: Full
271+
PythonSyntax: cuda_default_stream
272+
In: torch.cuda.default_stream
273+
Out: torch.xpu.current_stream
274+
275+
- Rule: rule_torch_device_cuda
276+
Kind: PythonRule
277+
Priority: Fallback
278+
MatchMode: Full
279+
PythonSyntax: torch_device_cuda
280+
In: torch.device('cuda')
281+
Out: torch.device('xpu')

0 commit comments

Comments
 (0)