-
Notifications
You must be signed in to change notification settings - Fork 91
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added pytorch build script migration rule file
- Loading branch information
1 parent
70f6c17
commit 2d0d828
Showing
28 changed files
with
427 additions
and
64 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
import torch |
15 changes: 11 additions & 4 deletions
15
clang/test/dpct/python_migration/case_002/case_002_import_torch_ext.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,17 @@ | ||
// RUN: rm -rf %T && mkdir -p %T | ||
// RUN: cd %T | ||
// RUN: cp %S/input.py ./input.py | ||
// RUN: dpct -in-root ./ -out-root out ./input.py --migrate-build-script-only | ||
// RUN: echo "begin" > %T/diff.txt | ||
// RUN: diff --strip-trailing-cr %S/expected.py %T/out/input.py >> %T/diff.txt | ||
// RUN: echo "end" >> %T/diff.txt | ||
|
||
// RUN: dpct -in-root ./ -out-root out_pytorch ./input.py --migrate-build-script-only | ||
// RUN: echo "begin" > %T/diff_pytorch.txt | ||
// RUN: diff --strip-trailing-cr %S/expected_pytorch.py %T/out_pytorch/input.py >> %T/diff_pytorch.txt | ||
// RUN: echo "end" >> %T/diff_pytorch.txt | ||
// CHECK: begin | ||
// CHECK-NEXT: end | ||
|
||
// RUN: dpct -in-root ./ -out-root out_ipex ./input.py --migrate-build-script-only --rule-file=%T/../../../../../../../extensions/python_rules/python_build_script_migration_rule_ipex.yaml | ||
// RUN: echo "begin" > %T/diff_ipex.txt | ||
// RUN: diff --strip-trailing-cr %S/expected_ipex.py %T/out_ipex/input.py >> %T/diff_ipex.txt | ||
// RUN: echo "end" >> %T/diff_ipex.txt | ||
// CHECK: begin | ||
// CHECK-NEXT: end |
File renamed without changes.
14 changes: 14 additions & 0 deletions
14
clang/test/dpct/python_migration/case_002/expected_pytorch.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
from setuptools import setup, Extension | ||
|
||
import torch | ||
from torch.utils import cpp_extension | ||
|
||
from torch.utils.cpp_extension import ( | ||
CppExtension, | ||
CppExtension, | ||
BuildExtension, | ||
SYCL_HOME, | ||
) | ||
|
||
if SYCL_HOME: | ||
var = cuda_specific_op() |
15 changes: 11 additions & 4 deletions
15
clang/test/dpct/python_migration/case_003/case_003_torch_classes.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,17 @@ | ||
// RUN: rm -rf %T && mkdir -p %T | ||
// RUN: cd %T | ||
// RUN: cp %S/input.py ./input.py | ||
// RUN: dpct -in-root ./ -out-root out ./input.py --migrate-build-script-only | ||
// RUN: echo "begin" > %T/diff.txt | ||
// RUN: diff --strip-trailing-cr %S/expected.py %T/out/input.py >> %T/diff.txt | ||
// RUN: echo "end" >> %T/diff.txt | ||
|
||
// RUN: dpct -in-root ./ -out-root out_pytorch ./input.py --migrate-build-script-only | ||
// RUN: echo "begin" > %T/diff_pytorch.txt | ||
// RUN: diff --strip-trailing-cr %S/expected_pytorch.py %T/out_pytorch/input.py >> %T/diff_pytorch.txt | ||
// RUN: echo "end" >> %T/diff_pytorch.txt | ||
// CHECK: begin | ||
// CHECK-NEXT: end | ||
|
||
// RUN: dpct -in-root ./ -out-root out_ipex ./input.py --migrate-build-script-only --rule-file=%T/../../../../../../../extensions/python_rules/python_build_script_migration_rule_ipex.yaml | ||
// RUN: echo "begin" > %T/diff_ipex.txt | ||
// RUN: diff --strip-trailing-cr %S/expected_ipex.py %T/out_ipex/input.py >> %T/diff_ipex.txt | ||
// RUN: echo "end" >> %T/diff_ipex.txt | ||
// CHECK: begin | ||
// CHECK-NEXT: end |
File renamed without changes.
9 changes: 9 additions & 0 deletions
9
clang/test/dpct/python_migration/case_003/expected_pytorch.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
from torch.utils.cpp_extension import SYCL_HOME | ||
|
||
use_cuda = use_cuda and torch.xpu.is_available() and SYCL_HOME is not None | ||
|
||
from torch.utils.cpp_extension import (SYCL_HOME) | ||
|
||
extension = CppExtension if (use_cuda and SYCL_HOME) else CppExtension | ||
|
||
path += torch.utils.cpp_extension.SYCL_HOME |
15 changes: 11 additions & 4 deletions
15
clang/test/dpct/python_migration/case_004/case_004_cuda_src_ext.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,17 @@ | ||
// RUN: rm -rf %T && mkdir -p %T | ||
// RUN: cd %T | ||
// RUN: cp %S/input.py ./input.py | ||
// RUN: dpct -in-root ./ -out-root out ./input.py --migrate-build-script-only | ||
// RUN: echo "begin" > %T/diff.txt | ||
// RUN: diff --strip-trailing-cr %S/expected.py %T/out/input.py >> %T/diff.txt | ||
// RUN: echo "end" >> %T/diff.txt | ||
|
||
// RUN: dpct -in-root ./ -out-root out_pytorch ./input.py --migrate-build-script-only | ||
// RUN: echo "begin" > %T/diff_pytorch.txt | ||
// RUN: diff --strip-trailing-cr %S/expected.py %T/out_pytorch/input.py >> %T/diff_pytorch.txt | ||
// RUN: echo "end" >> %T/diff_pytorch.txt | ||
// CHECK: begin | ||
// CHECK-NEXT: end | ||
|
||
// RUN: dpct -in-root ./ -out-root out_ipex ./input.py --migrate-build-script-only --rule-file=%T/../../../../../../../extensions/python_rules/python_build_script_migration_rule_ipex.yaml | ||
// RUN: echo "begin" > %T/diff_ipex.txt | ||
// RUN: diff --strip-trailing-cr %S/expected.py %T/out_ipex/input.py >> %T/diff_ipex.txt | ||
// RUN: echo "end" >> %T/diff_ipex.txt | ||
// CHECK: begin | ||
// CHECK-NEXT: end |
15 changes: 11 additions & 4 deletions
15
clang/test/dpct/python_migration/case_005/case_005_setup.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,17 @@ | ||
// RUN: rm -rf %T && mkdir -p %T | ||
// RUN: cd %T | ||
// RUN: cp %S/input.py ./input.py | ||
// RUN: dpct -in-root ./ -out-root out ./input.py --migrate-build-script-only | ||
// RUN: echo "begin" > %T/diff.txt | ||
// RUN: diff --strip-trailing-cr %S/expected.py %T/out/input.py >> %T/diff.txt | ||
// RUN: echo "end" >> %T/diff.txt | ||
|
||
// RUN: dpct -in-root ./ -out-root out_pytorch ./input.py --migrate-build-script-only | ||
// RUN: echo "begin" > %T/diff_pytorch.txt | ||
// RUN: diff --strip-trailing-cr %S/expected_pytorch.py %T/out_pytorch/input.py >> %T/diff_pytorch.txt | ||
// RUN: echo "end" >> %T/diff_pytorch.txt | ||
// CHECK: begin | ||
// CHECK-NEXT: end | ||
|
||
// RUN: dpct -in-root ./ -out-root out_ipex ./input.py --migrate-build-script-only --rule-file=%T/../../../../../../../extensions/python_rules/python_build_script_migration_rule_ipex.yaml | ||
// RUN: echo "begin" > %T/diff.txt | ||
// RUN: diff --strip-trailing-cr %S/expected_ipex.py %T/out_ipex/input.py >> %T/diff_ipex.txt | ||
// RUN: echo "end" >> %T/diff_ipex.txt | ||
// CHECK: begin | ||
// CHECK-NEXT: end |
File renamed without changes.
7 changes: 7 additions & 0 deletions
7
clang/test/dpct/python_migration/case_005/expected_pytorch.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
setup( | ||
name='quant_cuda', | ||
ext_modules=[cpp_extension.CppExtension( | ||
'quant_cuda', ["quant_cuda.cpp", 'quant_cuda_kernel.dp.cpp'] | ||
, include_dirs=cpp_extension.include_paths('xpu'),)], | ||
cmdclass={'build_ext': cpp_extension.BuildExtension} | ||
) |
15 changes: 11 additions & 4 deletions
15
clang/test/dpct/python_migration/case_006/case_006_torch_cuda.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,17 @@ | ||
// RUN: rm -rf %T && mkdir -p %T | ||
// RUN: cd %T | ||
// RUN: cp %S/input.py ./input.py | ||
// RUN: dpct -in-root ./ -out-root out ./input.py --migrate-build-script-only | ||
// RUN: echo "begin" > %T/diff.txt | ||
// RUN: diff --strip-trailing-cr %S/expected.py %T/out/input.py >> %T/diff.txt | ||
// RUN: echo "end" >> %T/diff.txt | ||
|
||
// RUN: dpct -in-root ./ -out-root out_pytorch ./input.py --migrate-build-script-only | ||
// RUN: echo "begin" > %T/diff_pytorch.txt | ||
// RUN: diff --strip-trailing-cr %S/expected.py %T/out_pytorch/input.py >> %T/diff_pytorch.txt | ||
// RUN: echo "end" >> %T/diff_pytorch.txt | ||
// CHECK: begin | ||
// CHECK-NEXT: end | ||
|
||
// RUN: dpct -in-root ./ -out-root out_ipex ./input.py --migrate-build-script-only --rule-file=%T/../../../../../../../extensions/python_rules/python_build_script_migration_rule_ipex.yaml | ||
// RUN: echo "begin" > %T/diff.txt | ||
// RUN: diff --strip-trailing-cr %S/expected.py %T/out_ipex/input.py >> %T/diff_ipex.txt | ||
// RUN: echo "end" >> %T/diff_ipex.txt | ||
// CHECK: begin | ||
// CHECK-NEXT: end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 15 additions & 6 deletions
21
clang/test/dpct/python_migration/case_007/case_007_test_extension_name.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,21 @@ | ||
// RUN: rm -rf %T && mkdir -p %T | ||
// RUN: cd %T | ||
// RUN: mkdir -p out | ||
// RUN: mkdir -p out_pytorch | ||
// RUN: mkdir -p out_ipex | ||
// RUN: cp %S/input.py ./input.py | ||
// RUN: cp %S/MainSourceFiles.yaml ./out/MainSourceFiles.yaml | ||
// RUN: dpct -in-root ./ -out-root out ./input.py --migrate-build-script-only | ||
// RUN: echo "begin" > %T/diff.txt | ||
// RUN: diff --strip-trailing-cr %S/expected.py %T/out/input.py >> %T/diff.txt | ||
// RUN: echo "end" >> %T/diff.txt | ||
// RUN: cp %S/MainSourceFiles.yaml ./out_pytorch/MainSourceFiles.yaml | ||
// RUN: cp %S/MainSourceFiles.yaml ./out_ipex/MainSourceFiles.yaml | ||
|
||
// RUN: dpct -in-root ./ -out-root out_pytorch ./input.py --migrate-build-script-only | ||
// RUN: echo "begin" > %T/diff_pytorch.txt | ||
// RUN: diff --strip-trailing-cr %S/expected.py %T/out_pytorch/input.py >> %T/diff_pytorch.txt | ||
// RUN: echo "end" >> %T/diff_pytorch.txt | ||
// CHECK: begin | ||
// CHECK-NEXT: end | ||
|
||
// RUN: dpct -in-root ./ -out-root out_ipex ./input.py --migrate-build-script-only --rule-file=%T/../../../../../../../extensions/python_rules/python_build_script_migration_rule_ipex.yaml | ||
// RUN: echo "begin" > %T/diff.txt | ||
// RUN: diff --strip-trailing-cr %S/expected.py %T/out_ipex/input.py >> %T/diff_ipex.txt | ||
// RUN: echo "end" >> %T/diff_ipex.txt | ||
// CHECK: begin | ||
// CHECK-NEXT: end |
15 changes: 11 additions & 4 deletions
15
clang/test/dpct/python_migration/case_008/case_008_comments.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,17 @@ | ||
// RUN: rm -rf %T && mkdir -p %T | ||
// RUN: cd %T | ||
// RUN: cp %S/input.py ./input.py | ||
// RUN: dpct -in-root ./ -out-root out ./input.py --migrate-build-script-only | ||
// RUN: echo "begin" > %T/diff.txt | ||
// RUN: diff --strip-trailing-cr %S/expected.py %T/out/input.py >> %T/diff.txt | ||
// RUN: echo "end" >> %T/diff.txt | ||
|
||
// RUN: dpct -in-root ./ -out-root out_pytorch ./input.py --migrate-build-script-only | ||
// RUN: echo "begin" > %T/diff_pytorch.txt | ||
// RUN: diff --strip-trailing-cr %S/expected_pytorch.py %T/out_pytorch/input.py >> %T/diff_pytorch.txt | ||
// RUN: echo "end" >> %T/diff_pytorch.txt | ||
// CHECK: begin | ||
// CHECK-NEXT: end | ||
|
||
// RUN: dpct -in-root ./ -out-root out_ipex ./input.py --migrate-build-script-only --rule-file=%T/../../../../../../../extensions/python_rules/python_build_script_migration_rule_ipex.yaml | ||
// RUN: echo "begin" > %T/diff.txt | ||
// RUN: diff --strip-trailing-cr %S/expected_ipex.py %T/out_ipex/input.py >> %T/diff_ipex.txt | ||
// RUN: echo "end" >> %T/diff_ipex.txt | ||
// CHECK: begin | ||
// CHECK-NEXT: end |
File renamed without changes.
2 changes: 2 additions & 0 deletions
2
clang/test/dpct/python_migration/case_008/expected_pytorch.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
# import torch | ||
import torch |
17 changes: 17 additions & 0 deletions
17
clang/test/dpct/python_migration/case_009/case_009_cpp_extension.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
// RUN: rm -rf %T && mkdir -p %T | ||
// RUN: cd %T | ||
// RUN: cp %S/input.py ./input.py | ||
|
||
// RUN: dpct -in-root ./ -out-root out_pytorch ./input.py --migrate-build-script-only | ||
// RUN: echo "begin" > %T/diff_pytorch.txt | ||
// RUN: diff --strip-trailing-cr %S/expected_pytorch.py %T/out_pytorch/input.py >> %T/diff_pytorch.txt | ||
// RUN: echo "end" >> %T/diff_pytorch.txt | ||
// CHECK: begin | ||
// CHECK-NEXT: end | ||
|
||
// RUN: dpct -in-root ./ -out-root out_ipex ./input.py --migrate-build-script-only --rule-file=%T/../../../../../../../extensions/python_rules/python_build_script_migration_rule_ipex.yaml | ||
// RUN: echo "begin" > %T/diff.txt | ||
// RUN: diff --strip-trailing-cr %S/expected_ipex.py %T/out_ipex/input.py >> %T/diff_ipex.txt | ||
// RUN: echo "end" >> %T/diff_ipex.txt | ||
// CHECK: begin | ||
// CHECK-NEXT: end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import torch | ||
import intel_extension_for_pytorch | ||
|
||
intel_extension_for_pytorch.xpu.cpp_extension.load(name=module_name, build_directory=cached_build_dir, | ||
verbose=verbose_build, sources=cached_sources, **build_kwargs, extra_cflags=['-fsycl'], extra_ldflags=['-fsycl']) |
4 changes: 4 additions & 0 deletions
4
clang/test/dpct/python_migration/case_009/expected_pytorch.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
import torch | ||
|
||
torch.utils.cpp_extension.load(name=module_name, build_directory=cached_build_dir, | ||
verbose=verbose_build, sources=cached_sources, **build_kwargs, extra_cflags=['-fsycl'], extra_ldflags=['-fsycl']) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
import torch | ||
|
||
torch.utils.cpp_extension.load(name=module_name, build_directory=cached_build_dir, | ||
verbose=verbose_build, sources=cached_sources, **build_kwargs) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.