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

Expose TORCH_XPU_API to Pytorch #279

Merged
merged 2 commits into from
Jul 31, 2024
Merged

Expose TORCH_XPU_API to Pytorch #279

merged 2 commits into from
Jul 31, 2024

Conversation

etaf
Copy link
Contributor

@etaf etaf commented May 20, 2024

Expose TORCH_XPU_API to Pytorch

@etaf
Copy link
Contributor Author

etaf commented May 20, 2024

This PR is relied upon stock Pytorch PR: pytorch/pytorch#126678

@etaf etaf marked this pull request as draft May 20, 2024 09:39
@etaf etaf force-pushed the xinanlin/export_api branch from 5d6c3e7 to a1a2448 Compare May 21, 2024 01:06
@etaf etaf requested review from EikanWang and fengyuan14 May 21, 2024 01:08
@etaf etaf self-assigned this May 21, 2024
@etaf etaf marked this pull request as ready for review May 21, 2024 01:15
@EikanWang
Copy link
Contributor

@etaf , is it critical to catch up PT 2.4?

@etaf
Copy link
Contributor Author

etaf commented May 31, 2024

@etaf , is it critical to catch up PT 2.4?

No, it's a performance optimization.

@etaf
Copy link
Contributor Author

etaf commented Jun 14, 2024

Since this Pytorch 2.4 release branch has been cut, I think we can start land this PR and the pytorch/pytorch#126678 that depend on it.

Copy link
Contributor

@EikanWang EikanWang left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

src/aten/EmptyTensor.h Outdated Show resolved Hide resolved
@@ -1,6 +1,7 @@
#define TORCH_ASSERT_NO_OPERATORS
#include <ATen/Context.h>
#include <ATen/EmptyTensor.h>
#include <ATen/xpu/EmptyTensor.h>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since we have included the xpu/EmptyTensor, is ATen/EmptyTensor still required?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ATen/xpu/EmptyTensor.h is the exported interface of EmptyTensor.cpp
and ATen/EmptyTensor.h is for at::detail::empty_generic which is used in this EmptyTensor.cpp file.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Then my question will be why ATen/xpu/EmptyTensor.h includes ATen/EmptyTensor.h?

Copy link
Contributor Author

@etaf etaf Jun 16, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, but ATen/xpu/EmptyTensor.h does not include ATen/EmptyTensor.h. ATen/xpu/EmptyTensor.h is a copy of torch-xpu-ops/src/aten/EmptyTensor.h.

@etaf etaf force-pushed the xinanlin/export_api branch 3 times, most recently from da79f4c to e24770c Compare June 18, 2024 13:10
@etaf
Copy link
Contributor Author

etaf commented Jun 19, 2024

@fengyuan14 can you help review this PR?

@etaf etaf requested a review from EikanWang June 19, 2024 01:14
@etaf etaf force-pushed the xinanlin/export_api branch 3 times, most recently from 5296f1b to 0b2393a Compare June 21, 2024 00:29
@etaf etaf force-pushed the xinanlin/export_api branch from 0b2393a to 292fadc Compare June 22, 2024 02:05
@fengyuan14
Copy link
Contributor

fengyuan14 commented Jun 22, 2024

You can expose the var to PyTorch cmake,

set(ATen_XPU_INCLUDE_DIRS ${TORCH_XPU_OPS_ROOT}/src)

And append it into cmake var of Caffe2 or ATen include dirs.

@etaf
Copy link
Contributor Author

etaf commented Jun 22, 2024

You can expose the var to PyTorch cmake,

set(ATen_XPU_INCLUDE_DIRS ${TORCH_XPU_OPS_ROOT}/src)

And append it into cmake var of Caffe2 or ATen include dirs.

Wouldn't that make the two PRs dependent on each other?

@fengyuan14
Copy link
Contributor

You can expose the var to PyTorch cmake,

set(ATen_XPU_INCLUDE_DIRS ${TORCH_XPU_OPS_ROOT}/src)

And append it into cmake var of Caffe2 or ATen include dirs.

Wouldn't that make the two PRs dependent on each other?

ATen_XPU_INCLUDE_DIR is the committed formal and stable API of torch-xpu-ops CMAKE. It is not implementation dependent.

@fengyuan14
Copy link
Contributor

Can we do like this ? What do you think of it?
image

@fengyuan14
Copy link
Contributor

fengyuan14 commented Jun 22, 2024

Looks I have exposed it by CMAKE target torch-xpu-ops, like this,
image
You can retrieve them in caffe2/CMakeList.txt by get_target_property(ATen_XPU_INCLUDE_DIR torch-xpu-ops INCLUDE_DIRECTORIES)

@etaf
Copy link
Contributor Author

etaf commented Jun 25, 2024

The original design is to align the include path with CPU/CUDA, eg. ATen/xpu/EmptyTensor.h, can I still keep this path with your design ?

@etaf etaf force-pushed the xinanlin/export_api branch from 292fadc to 085062d Compare July 29, 2024 18:13
@etaf etaf requested a review from fengyuan14 July 29, 2024 18:14
@etaf etaf force-pushed the xinanlin/export_api branch from 085062d to b150b98 Compare July 30, 2024 05:42
@fengyuan14 fengyuan14 added this pull request to the merge queue Jul 31, 2024
Merged via the queue into main with commit 4f5c2b1 Jul 31, 2024
2 checks passed
@fengyuan14 fengyuan14 deleted the xinanlin/export_api branch July 31, 2024 00:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants