Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit7cc1a95

Browse files
xuhancnpytorchmergebot
authored andcommitted
[AOTI] fix extract file failed on Windows. (#158702)
Changes:1. rename zip index name, and keep it out of normalize path.2. normalize output path for extract file.Extract files successful:<img width="683" height="247" alt="image" src="https://github.com/user-attachments/assets/72dff7b9-5ec0-4523-a6ee-7768b37bbe63" />Pull Requestresolved:#158702Approved by:https://github.com/angelayi
1 parent7cc5d03 commit7cc1a95

File tree

1 file changed

+21
-20
lines changed

1 file changed

+21
-20
lines changed

‎torch/csrc/inductor/aoti_package/model_package_loader.cpp

Lines changed: 21 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -435,19 +435,21 @@ AOTIModelPackageLoader::AOTIModelPackageLoader(
435435

436436
std::vector<std::string> found_filenames;
437437
for (uint32_t i =0; i < zip_archive.m_total_files; i++) {
438-
uint32_tfilename_len =
438+
uint32_tzip_filename_len =
439439
mz_zip_reader_get_filename(&zip_archive, i,nullptr,0);
440-
if (filename_len ==0) {
440+
if (zip_filename_len ==0) {
441441
throwstd::runtime_error("Failed to read filename");
442442
}
443-
// filename_len returned by mz_zip_reader_get_filename includes the null
444-
// terminator, so we need to subtract 1 here
445-
std::stringfilename_str(filename_len -1,'\0');
443+
// zip_filename_len returned by mz_zip_reader_get_filename includes the null
444+
// terminator, so we need to subtract 1 here.
445+
std::stringzip_filename_str(zip_filename_len -1,'\0');
446+
// zip_filename_str can't be normalize_path_separator, because it should be
447+
// as index for mz_zip_reader_extract_file_to_file.
446448
if (!mz_zip_reader_get_filename(
447-
&zip_archive, i,filename_str.data(),filename_len)) {
449+
&zip_archive, i,zip_filename_str.data(),zip_filename_len)) {
448450
throwstd::runtime_error("Failed to read filename");
449451
}
450-
found_filenames.push_back(normalize_path_separator(filename_str));
452+
found_filenames.push_back(zip_filename_str);
451453
}
452454

453455
if (found_filenames.empty()) {
@@ -504,18 +506,17 @@ AOTIModelPackageLoader::AOTIModelPackageLoader(
504506
.append(filename);
505507
}
506508

507-
output_path_str =normalize_path_separator(output_path_str);
508-
509+
std::string output_file_path =normalize_path_separator(output_path_str);
509510
LOG(INFO) <<"Extract file:" << filename_str <<" to"
510-
<<output_path_str;
511+
<<output_file_path;
511512

512513
// Create the parent directory if it doesn't exist
513-
size_t parent_path_idx =output_path_str.find_last_of(k_separator);
514+
size_t parent_path_idx =output_file_path.find_last_of(k_separator);
514515
if (parent_path_idx == std::string::npos) {
515516
throwstd::runtime_error(
516-
"Failed to find parent path in" +output_path_str);
517+
"Failed to find parent path in" +output_file_path);
517518
}
518-
std::string parent_path =output_path_str.substr(0, parent_path_idx);
519+
std::string parent_path =output_file_path.substr(0, parent_path_idx);
519520
if (!recursive_mkdir(parent_path)) {
520521
throwstd::runtime_error(fmt::format(
521522
"Failed to create directory {}: {}",
@@ -525,22 +526,22 @@ AOTIModelPackageLoader::AOTIModelPackageLoader(
525526

526527
// Extracts file to the temp directory
527528
mz_bool b_extract =mz_zip_reader_extract_file_to_file(
528-
&zip_archive, filename_str.c_str(),output_path_str.c_str(),0);
529+
&zip_archive, filename_str.c_str(),output_file_path.c_str(),0);
529530
if (b_extract == MZ_FALSE) {
530531
throwstd::runtime_error(fmt::format(
531-
"Failed to extract file {} to {}", filename_str,output_path_str));
532+
"Failed to extract file {} to {}", filename_str,output_file_path));
532533
}
533534

534535
// Save the file for bookkeeping
535-
size_t extension_idx =output_path_str.find_last_of('.');
536+
size_t extension_idx =output_file_path.find_last_of('.');
536537
if (extension_idx != std::string::npos) {
537-
std::string filename_extension =output_path_str.substr(extension_idx);
538+
std::string filename_extension =output_file_path.substr(extension_idx);
538539
if (filename_extension ==".cpp") {
539-
cpp_filename =output_path_str;
540+
cpp_filename =output_file_path;
540541
}elseif (filename_extension ==object_file_ext()) {
541-
obj_filenames.push_back(output_path_str);
542+
obj_filenames.push_back(output_file_path);
542543
}elseif (filename_extension ==extension_file_ext()) {
543-
so_filename =output_path_str;
544+
so_filename =output_file_path;
544545
}
545546
}
546547
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp