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

Move kernel pieces of cumsum/cumprod into unfied file. #681

Merged
merged 3 commits into from
Aug 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions src/ATen/native/xpu/sycl/CumprodKernel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,22 @@ void launch_cumprod_kernel(
});
}

static c10::MaybeOwned<Tensor> contiguous_out_arg(const Tensor& tensor) {
if (tensor.is_contiguous()) {
return c10::MaybeOwned<Tensor>::borrowed(tensor);
}
return c10::MaybeOwned<Tensor>::owned(
at::empty(tensor.sizes(), tensor.options()));
}

void cumprod_kernel(const Tensor& result, const Tensor& self, int64_t dim) {
auto result_ = contiguous_out_arg(result);

launch_cumprod_kernel(*result_, self, dim);

if (!result.is_same(*result_)) {
result.copy_(*result_);
}
}

} // namespace at::native::xpu
18 changes: 18 additions & 0 deletions src/ATen/native/xpu/sycl/CumsumKernel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,22 @@ void launch_cumsum_kernel(
});
}

static c10::MaybeOwned<Tensor> contiguous_out_arg(const Tensor& tensor) {
if (tensor.is_contiguous()) {
return c10::MaybeOwned<Tensor>::borrowed(tensor);
}
return c10::MaybeOwned<Tensor>::owned(
at::empty(tensor.sizes(), tensor.options()));
}

void cumsum_kernel(const Tensor& result, const Tensor& self, int64_t dim) {
auto result_ = contiguous_out_arg(result);

launch_cumsum_kernel(*result_, self, dim);

if (!result.is_same(*result_)) {
result.copy_(*result_);
}
}

} // namespace at::native::xpu
49 changes: 0 additions & 49 deletions src/ATen/native/xpu/sycl/ScanKernels.cpp

This file was deleted.