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

[Feature][PyTorch migration rule] Added PyTorch build script migration rule file #2564

Open
wants to merge 1 commit into
base: SYCLomatic
Choose a base branch
from

Conversation

TejaX-Alaghari
Copy link
Contributor

This PR introduces python_build_script_migration_rule_pytorch.yaml rule file for Python script migration using PyTorch's XPU class instead of IPEX's XPU

@TejaX-Alaghari TejaX-Alaghari requested a review from a team as a code owner December 11, 2024 16:32
Comment on lines +1202 to +1221
// check if RuleFilePaths contains any user specified python migration rule
// file
bool pythonRuleFilePresent = std::any_of(
RuleFilePath.begin(), RuleFilePath.end(),
[](const clang::tooling::UnifiedPath &path) {
return path.getPath().contains("python_build_script_migration_rule");
});

if (!pythonRuleFilePresent) {
SmallString<128> PythonRuleFilePath(DpctInstallPath.getCanonicalPath());
llvm::sys::path::append(
PythonRuleFilePath,
Twine("extensions/python_rules/"
"python_build_script_migration_rule_pytorch.yaml"));
if (llvm::sys::fs::exists(PythonRuleFilePath)) {
std::vector<clang::tooling::UnifiedPath> PythonRuleFiles{
PythonRuleFilePath};
importRules(PythonRuleFiles);
// generage helper functions file in the outroot dir here
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. If both two yaml files(clang/tools/dpct/DpctOptRules/python_build_script_migration_rule_ipex.yaml, clang/tools/dpct/DpctOptRules/python_build_script_migration_rule_pytorch.yaml) exisit, which yaml files take effect?

  2. clang/tools/dpct/DpctOptRules/python_build_script_migration_rule_ipex.yaml, clang/tools/dpct/DpctOptRules/python_build_script_migration_rule_pytorch.yaml have duplicate migration rules, we can keep only one copy, so that it is easy to maintain them.

Copy link
Contributor Author

@TejaX-Alaghari TejaX-Alaghari Dec 12, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. If any yaml file is specified with --rule-file option, then that rule file is chosen
    a. If no --rule-file options is provided, by default, python_build_script_migration_rule_pytorch.yaml is chosen.

  2. Shall I create another yaml file (python_build_script_migration_rule.yaml) that is always loaded by default regardless of while --rule-file is loaded?

Copy link
Contributor

@tomflinda tomflinda Dec 12, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In my opinion:

  1. When option " --migrate-build-script=Python " or " --migrate-build-script=Python --migrate-build-script-only" is specified, then python_build_script_migration_rule_pytorch.yaml is default loaded for pytorch xpu build env
  2. When option " --migrate-build-script=Python " or " --migrate-build-script=Python --migrate-build-script-only" is specified, and --rule-file = python_build_script_migration_rule_ipex.yaml is specified, then python_build_script_migration_rule_ipex.yam is loaded for ipex build env.
  3. As to the common rules between python_build_script_migration_rule_pytorch.yaml and python_build_script_migration_rule_ipex.yaml should be only left in python_build_script_migration_rule_pytorch.yaml, and python_build_script_migration_rule_ipex.yaml files only keeps the rule specific for IPEX.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants