-
Notifications
You must be signed in to change notification settings - Fork 44
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
23
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
23 commits
Select commit
Hold shift + click to select a range
18fa363
add linalg svd
yucai-intel aad1315
fix
yucai-intel 2a7f687
fix
yucai-intel 9f03747
add svd_xpu_float64 test cases
yucai-intel e39de02
Directly register svd instead of stub
CuiYifeng 86b139e
Retain fallback in XPUFallback.template
CuiYifeng 506817f
Clean unused header files
CuiYifeng 95f27bf
Remove fallback
CuiYifeng 85ff97d
Fix namespace
CuiYifeng b3f904d
Remove fallback from XPUFallback.template
CuiYifeng 1916257
Simplify oneMKL header file
CuiYifeng 7b2c103
Remove unused variables
CuiYifeng cef7bb8
Add fallback with stub
CuiYifeng 7e670c4
Keep empty U and Vh for svdvals
CuiYifeng e98eab3
Remove nested USE_ONEMKL
CuiYifeng 4be635c
Small refinement
CuiYifeng 185458c
Fix typo
CuiYifeng 3f7989f
Fix code style
CuiYifeng b04bbea
To link mkl_sycl_blas forcely
CuiYifeng db79027
Using pageable memory instead of pinned memory
CuiYifeng 3550383
Filter oneMKL integration code in CMAKE
CuiYifeng 0bfaf6a
Refactor code to eliminate copy and resize
CuiYifeng e46f07e
Fix macro
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.
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.