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

[Python Migration] Separated common IPEX and PyTorch rules #2654

Open
wants to merge 4 commits into
base: SYCLomatic
Choose a base branch
from

Conversation

TejaX-Alaghari
Copy link
Contributor

This PR separates common rules from IPEX & PyTorch rule files into a new rule file and appends them to the user selected rule file

@TejaX-Alaghari TejaX-Alaghari requested a review from a team as a code owner February 5, 2025 12:12
Copy link
Contributor

@tomflinda tomflinda left a comment

Choose a reason for hiding this comment

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

I'm OKay for the current refactor, pls make sure the CI run passed for this PR.

Copy link
Contributor

@zhimingwang36 zhimingwang36 left a comment

Choose a reason for hiding this comment

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

I'd prefer not to merge, besides the file specified, a extra yaml file will be load, it it not clear behavior for user.

@TejaX-Alaghari
Copy link
Contributor Author

TejaX-Alaghari commented Feb 14, 2025

The Linux & Win CPU CI have an expected failure in help_option_check.cpp (PR#2665 is already raised)

}

// Get the directory path of the rule file.
llvm::SmallString<128> directoryPath(ruleFilePath);
Copy link
Contributor

Choose a reason for hiding this comment

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

For the variable naming styles, please use the camel case style, just like the other code style in the DPCT folder.


// Get the directory path of the rule file.
llvm::SmallString<128> directoryPath(ruleFilePath);
llvm::sys::path::remove_filename(directoryPath);
Copy link
Contributor

Choose a reason for hiding this comment

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

same as above.

// Split the file content into lines using newline as the delimiter.
llvm::StringRef buffContent = std::move(*Buffer)->getBuffer();
llvm::SmallVector<StringRef, 16> lines;
buffContent.split(lines, "\n");
Copy link
Contributor

Choose a reason for hiding this comment

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

Using '\n' to split the file, we should make sure the content of the YAML file is ended with '\n' for each line.

// Extract the filename following !include.
std::istringstream iss(lineStr);
std::string incDirective, incRuleFilePath;
// iss >> incDirective >> incRuleFilePath;
Copy link
Contributor

Choose a reason for hiding this comment

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

remove

Comment on lines +374 to +409
// Extract the filename following !include.
std::istringstream iss(lineStr);
std::string incDirective, incRuleFilePath;
// iss >> incDirective >> incRuleFilePath;
iss >> incDirective;
std::getline(iss >> std::ws, incRuleFilePath);

// Trim trailing spaces from incRuleFilePath
incRuleFilePath.erase(incRuleFilePath.find_last_not_of(" \t\n\r\f\v") + 1);

if (incDirective == "!include") {
if (!incRuleFilePath.empty()) {
// Remove surrounding quotes if they exist.
if (incRuleFilePath.front() == '"' && incRuleFilePath.back() == '"') {
incRuleFilePath =
incRuleFilePath.substr(1, incRuleFilePath.size() - 2);
}

// Calculate the absolute path of the included file based on its parent
// rule file
llvm::SmallString<128> incRuleFileAbsPath = directoryPath;
llvm::sys::path::append(incRuleFileAbsPath, incRuleFilePath);

// Recursively process the included file.
if (llvm::sys::fs::exists(incRuleFileAbsPath)) {
output << readYAMLFile(incRuleFileAbsPath.str())->getBuffer().str()
<< "\n";
} else {
output << readYAMLFile(incRuleFilePath)->getBuffer().str() << "\n";
}
} else {
continue;
}
} else {
output << lineStr << "\n";
}
Copy link
Contributor

Choose a reason for hiding this comment

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

I think a single for-loop is enough to handle this.

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.

5 participants