Skip to content

Commit 244d262

Browse files
remove extra libtorch dependency (#14928)
This PR was created by the merge bot to help merge the original PR into the main branch. ghstack PR number: #14919 by @Gasoonjia ^ Please use this as the source of truth for the PR details, comments, and reviews ghstack PR base: https://github.com/pytorch/executorch/tree/gh/gasoonjia/51/base ghstack PR head: https://github.com/pytorch/executorch/tree/gh/gasoonjia/51/head Merge bot PR base: https://github.com/pytorch/executorch/tree/gh/gasoonjia/50/orig Merge bot PR head: https://github.com/pytorch/executorch/tree/gh/gasoonjia/51/orig Differential Revision: [D84207378](https://our.internmc.facebook.com/intern/diff/D84207378/) @diff-train-skip-merge --------- Co-authored-by: gasoonjia <[email protected]>
1 parent f8c3ea2 commit 244d262

File tree

14 files changed

+34
-67
lines changed

14 files changed

+34
-67
lines changed

backends/aoti/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ target_compile_options(aoti_common PUBLIC -fexceptions -frtti -fPIC)
4040
# Ensure symbols are exported properly
4141
target_link_options(aoti_common PUBLIC -Wl,--export-dynamic)
4242

43-
# Link against PyTorch libraries and standard libraries
43+
# Link against ExecuTorch libraries and standard libraries
4444
target_link_libraries(aoti_common PUBLIC extension_tensor ${CMAKE_DL_LIBS})
4545
executorch_target_link_options_shared_lib(aoti_common)
4646

backends/aoti/common_shims.cpp

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,11 +127,18 @@ int32_t aoti_torch_layout_strided() {
127127
}
128128

129129
// Dtype constants - these return the PyTorch dtype codes
130-
// Currently only float32 is supported, but using robust enum-based approach
131130
int32_t aoti_torch_dtype_float32() {
132131
return 6; // PyTorch's float32 dtype code
133132
}
134133

134+
int32_t aoti_torch_dtype_bfloat16() {
135+
return 15; // PyTorch's bfloat16 dtype code
136+
}
137+
138+
int32_t aoti_torch_dtype_int64() {
139+
return 4; // PyTorch's int64 dtype code
140+
}
141+
135142
// Cleanup functions
136143
void cleanup_tensor_metadata() {
137144
internal::tensor_to_sizes.clear();

backends/aoti/common_shims.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,8 @@ AOTITorchError aoti_torch_get_dim(Tensor* tensor, int64_t* ret_dim);
5858
int32_t aoti_torch_device_type_cpu();
5959
int32_t aoti_torch_layout_strided();
6060
int32_t aoti_torch_dtype_float32();
61+
int32_t aoti_torch_dtype_bfloat16();
62+
int32_t aoti_torch_dtype_int64();
6163

6264
// Autograd mode functions
6365
int32_t aoti_torch_grad_mode_is_enabled();

backends/cuda/CMakeLists.txt

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,10 +55,7 @@ target_link_options(aoti_cuda PUBLIC -Wl,--export-dynamic)
5555

5656
# Link against CUDA::cudart, common AOTI library, and PyTorch CUDA libraries
5757
target_link_libraries(
58-
aoti_cuda
59-
PUBLIC aoti_common CUDA::cudart ${CMAKE_DL_LIBS}
60-
# Link PyTorch libraries for AOTI CUDA functions
61-
${TORCH_LIBRARIES}
58+
aoti_cuda PUBLIC aoti_common CUDA::cudart ${CMAKE_DL_LIBS}
6259
)
6360
# If you need other CUDA libraries, link them similarly:
6461
# target_link_libraries(aoti_cuda PUBLIC CUDA::cublas CUDA::cufft ...)

backends/cuda/runtime/cuda_backend.cpp

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,7 @@
2626
#include <executorch/backends/cuda/runtime/shims/memory.h>
2727
#include <executorch/backends/cuda/runtime/utils.h>
2828

29-
namespace executorch {
30-
namespace backends {
31-
namespace cuda {
29+
namespace executorch::backends::cuda {
3230

3331
#define LOAD_SYMBOL(name, handle) \
3432
do { \
@@ -335,14 +333,13 @@ class ET_EXPERIMENTAL CudaBackend final
335333
}
336334
};
337335

338-
} // namespace cuda
336+
} // namespace executorch::backends::cuda
339337

338+
namespace executorch::backends {
340339
namespace {
341340
auto cls = cuda::CudaBackend();
342341
executorch::runtime::Backend backend{"CudaBackend", &cls};
343342
static executorch::runtime::Error success_with_compiler =
344343
register_backend(backend);
345344
} // namespace
346-
347-
} // namespace backends
348-
} // namespace executorch
345+
} // namespace executorch::backends

backends/cuda/runtime/guard.cpp

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,7 @@
99
#include <executorch/backends/cuda/runtime/guard.h>
1010
#include <executorch/runtime/platform/log.h>
1111

12-
namespace executorch {
13-
namespace backends {
14-
namespace cuda {
12+
namespace executorch::backends::cuda {
1513

1614
namespace {
1715
// Thread-local stream storage (private to this file)
@@ -146,6 +144,4 @@ Result<CUDAStreamGuard> CUDAStreamGuard::create(
146144
return stream_guard;
147145
}
148146

149-
} // namespace cuda
150-
} // namespace backends
151-
} // namespace executorch
147+
} // namespace executorch::backends::cuda

backends/cuda/runtime/guard.h

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,7 @@
1414
#include <executorch/runtime/core/result.h>
1515
#include <cstdint>
1616

17-
namespace executorch {
18-
namespace backends {
19-
namespace cuda {
17+
namespace executorch::backends::cuda {
2018

2119
using executorch::runtime::Error;
2220
using executorch::runtime::Result;
@@ -190,6 +188,4 @@ class CUDAStreamGuard {
190188
DeviceIndex device_index_;
191189
};
192190

193-
} // namespace cuda
194-
} // namespace backends
195-
} // namespace executorch
191+
} // namespace executorch::backends::cuda

backends/cuda/runtime/shims/cuda_guard.cpp

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,7 @@
88

99
#include <executorch/backends/cuda/runtime/shims/cuda_guard.h>
1010

11-
namespace executorch {
12-
namespace backends {
13-
namespace cuda {
11+
namespace executorch::backends::cuda {
1412

1513
extern "C" {
1614

@@ -104,6 +102,4 @@ AOTITorchError aoti_torch_get_current_cuda_stream(
104102

105103
} // extern "C"
106104

107-
} // namespace cuda
108-
} // namespace backends
109-
} // namespace executorch
105+
} // namespace executorch::backends::cuda

backends/cuda/runtime/shims/cuda_guard.h

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,7 @@
1313
#include <executorch/backends/cuda/runtime/guard.h>
1414
#include <cstdint>
1515

16-
namespace executorch {
17-
namespace backends {
18-
namespace cuda {
16+
namespace executorch::backends::cuda {
1917

2018
using executorch::backends::aoti::AOTITorchError;
2119

@@ -99,6 +97,4 @@ AOTITorchError aoti_torch_get_current_cuda_stream(
9997

10098
} // extern "C"
10199

102-
} // namespace cuda
103-
} // namespace backends
104-
} // namespace executorch
100+
} // namespace executorch::backends::cuda

backends/cuda/runtime/shims/memory.cpp

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,7 @@
1919
#include <unordered_set>
2020
#include <vector>
2121

22-
namespace executorch {
23-
namespace backends {
24-
namespace cuda {
22+
namespace executorch::backends::cuda {
2523

2624
using executorch::aten::SizesType;
2725
using executorch::aten::StridesType;
@@ -659,6 +657,4 @@ AOTITorchError aoti_torch__reinterpret_tensor(
659657

660658
} // extern "C"
661659

662-
} // namespace cuda
663-
} // namespace backends
664-
} // namespace executorch
660+
} // namespace executorch::backends::cuda

0 commit comments

Comments
 (0)