Skip to content

Commit

Permalink
Expose TORCH_XPU_API to Pytorch
Browse files Browse the repository at this point in the history
Signed-off-by: xinan.lin <[email protected]>
  • Loading branch information
etaf committed May 21, 2024
1 parent 5bf9e0c commit a1a2448
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 6 deletions.
9 changes: 9 additions & 0 deletions src/aten/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,10 +1,19 @@
# ATen XPU sources

file(GLOB xpu_cpp "*.cpp")
file(GLOB xpu_h "*.h")
file(GLOB xpu_sycl "sycl/*.cpp")

list(APPEND ATen_XPU_CPP_SRCS ${xpu_cpp})
list(APPEND ATen_XPU_SYCL_SRCS ${xpu_sycl})

set(ATen_XPU_CPP_SRCS ${ATen_XPU_CPP_SRCS} PARENT_SCOPE)
set(ATen_XPU_SYCL_SRCS ${ATen_XPU_SYCL_SRCS} PARENT_SCOPE)

set(INCLUDE_DIR_FOR_TORCH "${CMAKE_BINARY_DIR}/aten/src/ATen/xpu" )
file(MAKE_DIRECTORY ${INCLUDE_DIR_FOR_TORCH})
foreach(HEADER ${xpu_h})
file(COPY ${HEADER} DESTINATION ${INCLUDE_DIR_FOR_TORCH})
# uncomment the following line to install the header to torch/include/ATen/xpu
# install(FILES ${HEADER} DESTINATION "include/ATen/xpu")
endforeach()
1 change: 1 addition & 0 deletions src/aten/EmptyTensor.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#define TORCH_ASSERT_NO_OPERATORS
#include <ATen/Context.h>
#include <ATen/EmptyTensor.h>
#include <ATen/xpu/EmptyTensor.h>
#include <c10/core/DeviceGuard.h>
#include <c10/xpu/XPUCachingAllocator.h>

Expand Down
13 changes: 7 additions & 6 deletions src/aten/EmptyTensor.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,37 +4,38 @@
namespace at::detail {

// XXX: add TORCH_XPU_API
TensorBase empty_xpu(
TORCH_XPU_API TensorBase empty_xpu(
IntArrayRef size,
ScalarType dtype,
c10::optional<Device> device_opt,
c10::optional<c10::MemoryFormat> memory_format_opt);

TensorBase empty_xpu(
TORCH_XPU_API TensorBase empty_xpu(
IntArrayRef size,
c10::optional<ScalarType> dtype_opt,
c10::optional<Layout> layout_opt,
c10::optional<Device> device_opt,
c10::optional<bool> pin_memory_opt,
c10::optional<c10::MemoryFormat> memory_format_opt);

TensorBase empty_xpu(IntArrayRef size, const TensorOptions& options);
TORCH_XPU_API TensorBase
empty_xpu(IntArrayRef size, const TensorOptions& options);

TensorBase empty_strided_xpu(
TORCH_XPU_API TensorBase empty_strided_xpu(
IntArrayRef size,
IntArrayRef stride,
ScalarType dtype,
c10::optional<Device> device_opt);

TensorBase empty_strided_xpu(
TORCH_XPU_API TensorBase empty_strided_xpu(
IntArrayRef size,
IntArrayRef stride,
c10::optional<ScalarType> dtype_opt,
c10::optional<Layout> layout_opt,
c10::optional<Device> device_opt,
c10::optional<bool> pin_memory_opt);

TensorBase empty_strided_xpu(
TORCH_XPU_API TensorBase empty_strided_xpu(
IntArrayRef size,
IntArrayRef stride,
const TensorOptions& options);
Expand Down

0 comments on commit a1a2448

Please sign in to comment.