-
Notifications
You must be signed in to change notification settings - Fork 49
[WA] Fix the lack of exceptions vector in getrf_batch #1916
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
base: main
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,6 +11,7 @@ | |
#include <ATen/ops/_linalg_check_errors_native.h> | ||
#include <ATen/ops/empty.h> | ||
#include <ATen/ops/from_blob.h> | ||
#include <ATen/ops/zeros_like.h> | ||
|
||
#include <comm/SYCLContext.h> | ||
#include <comm/TensorInfo.h> | ||
|
@@ -40,6 +41,18 @@ static oneapi::mkl::transpose to_blas_(TransposeType trans) { | |
void error_handle(int32_t* infos, const oneapi::mkl::lapack::batch_error& be) { | ||
auto errs = be.exceptions(); | ||
auto ids = be.ids(); | ||
|
||
if (!errs.size()) { | ||
std::cout << "Cathed lapack exception:" | ||
<< "\nWhat: " << be.what() << "\nInfo: " << be.info() | ||
<< std::endl; | ||
for (auto& i : ids) { | ||
std::cout << "Error in martix #" << i << std::endl; | ||
CuiYifeng marked this conversation as resolved.
Show resolved
Hide resolved
CuiYifeng marked this conversation as resolved.
Show resolved
Hide resolved
|
||
infos[i] = 1; | ||
} | ||
return; | ||
} | ||
|
||
for (auto& i : ids) { | ||
try { | ||
std::rethrow_exception(errs[i]); | ||
|
@@ -529,8 +542,8 @@ void lu_factor_mkl( | |
"linalg.lu_factor: LU without pivoting is not implemented on the XPU"); | ||
|
||
// handle the info | ||
info.zero_(); | ||
int32_t* infos_data = info.data_ptr<int32_t>(); | ||
Tensor info_ = at::zeros_like(info, Device(at::kCPU)); | ||
int32_t* infos_data = info_.data_ptr<int32_t>(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. can you provide more explanation here? why you create a zero tensor on cpu and pass it to apply_lu_xpu_? and then you copy info_ to xpu? mkl will get seg fault when info is on xpu? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. On stock Pytorch side, original info Tensor is on device instead of host. |
||
|
||
// oneMKL requires Long for pivots but PyTorch provides Int | ||
Tensor pivots_ = at::empty(pivots.sizes(), pivots.options().dtype(kLong)); | ||
|
@@ -539,7 +552,8 @@ void lu_factor_mkl( | |
apply_lu_xpu_<scalar_t>(LU, pivots_, infos_data); | ||
}); | ||
|
||
// Copy to original pivots tensor | ||
// Copy to original info and pivots tensor | ||
info.copy_(info_); | ||
pivots.copy_(pivots_); | ||
} | ||
|
||
|
Uh oh!
There was an error while loading. Please reload this page.