-
Notifications
You must be signed in to change notification settings - Fork 39
Add mkl::linalg_svd relative Ops #1511
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
Open
yucai-intel
wants to merge
21
commits into
main
Choose a base branch
from
slogdet
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
400c610
add linalg svd
yucai-intel 8b271f2
fix
yucai-intel 5042da6
fix
yucai-intel 58b6432
add svd_xpu_float64 test cases
yucai-intel d59fe90
Directly register svd instead of stub
CuiYifeng 950c00f
Retain fallback in XPUFallback.template
CuiYifeng 88cefaa
Clean unused header files
CuiYifeng 6d4be2c
Remove fallback
CuiYifeng 08996fd
Fix namespace
CuiYifeng 83731fd
Remove fallback from XPUFallback.template
CuiYifeng 4ff2b3d
Simplify oneMKL header file
CuiYifeng 7f1df73
Remove unused variables
CuiYifeng 6c7e207
Add fallback with stub
CuiYifeng e3acec9
Keep empty U and Vh for svdvals
CuiYifeng 24c1147
Remove nested USE_ONEMKL
CuiYifeng 8b4dae3
Small refinement
CuiYifeng a38f3aa
Fix typo
CuiYifeng d156e8b
Fix code style
CuiYifeng a193621
To link mkl_sycl_blas forcely
CuiYifeng 4d0f184
Using pageable memory instead of pinned memory
CuiYifeng 8ea8267
Filter oneMKL integration code in CMAKE
CuiYifeng File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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,61 @@ | ||
#include <ATen/core/Tensor.h> | ||
#include <ATen/native/BatchLinearAlgebra.h> | ||
#include <ATen/native/DispatchStub.h> | ||
#include <ATen/ops/empty_like.h> | ||
#if defined(USE_ONEMKL) | ||
#include <ATen/native/xpu/mkl/BatchLinearAlgebra.h> | ||
#endif // USE_ONEMKL | ||
|
||
namespace at::native { | ||
|
||
void svd_kernel_xpu( | ||
const Tensor& A, | ||
const bool full_matrices, | ||
const bool compute_uv, | ||
const c10::optional<c10::string_view>& driver, | ||
const Tensor& U, | ||
const Tensor& S, | ||
const Tensor& Vh, | ||
const Tensor& info) { | ||
#if defined(USE_ONEMKL) | ||
native::xpu::svd_mkl(A, full_matrices, compute_uv, driver, U, S, Vh, info); | ||
#else | ||
const auto A_cpu = A.to( | ||
A.options().device(kCPU).memory_format(at::MemoryFormat::Contiguous)); | ||
// U, S, Vh, info are the right size and strides, but these tensors are on GPU | ||
// and need to be copied | ||
const auto empty_like_cpu = [](const Tensor& t) { | ||
return at::empty_like(t, t.options().device(kCPU)); | ||
}; | ||
|
||
auto U_cpu = compute_uv ? empty_like_cpu(U) : Tensor{}; | ||
auto S_cpu = empty_like_cpu(S); | ||
auto Vh_cpu = compute_uv ? empty_like_cpu(Vh) : Tensor{}; | ||
auto info_cpu = empty_like_cpu(info); | ||
|
||
svd_stub( | ||
at::kCPU, | ||
A_cpu, | ||
full_matrices, | ||
compute_uv, | ||
driver, | ||
U_cpu, | ||
S_cpu, | ||
Vh_cpu, | ||
info_cpu); | ||
|
||
// Copy from CPU back to XPU | ||
// We can do a non_blocking copy, as there is an unconditional check of the | ||
// infos in the calling function | ||
if (compute_uv) { | ||
U.copy_(U_cpu); | ||
Vh.copy_(Vh_cpu); | ||
} | ||
S.copy_(S_cpu); | ||
info.copy_(info_cpu); | ||
#endif // USE_ONEMKL | ||
} | ||
|
||
REGISTER_XPU_DISPATCH(svd_stub, &svd_kernel_xpu); | ||
|
||
} // namespace at::native |
This file contains hidden or 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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.