Skip to content

Commit d53ec66

Browse files
committed
Define the new shim where the CUDA library can actually see it
The link stub advertises `aoti_torch_is_defined` against the CUDA shim library, but the function was added to the ETensor shim file, which only the Apple Metal backend links. The CUDA library is built from the CUDA shims plus the SlimTensor common shims, and the SlimTensor file did not define it. So a Windows CUDA export would link against a name nothing in that library provides, and fail when loading, which is the failure the earlier commit set out to remove. Add it to the SlimTensor shims as well, following that file's habit of rejecting a null output pointer rather than writing through it. The other two names were already in the right places: the dtype helper in the SlimTensor shims, the pinned allocator in the CUDA memory shims. Also regenerate the link stub deterministically. The tool used to rebuild it stamped the build time into all 48 members, where every member of the previous file had it zeroed, and this file is packaged into the wheel, so that timestamp reached users and made two builds of the same source differ. Test Plan: Compared what each shim file defines and what the CUDA library links. The name was in the ETensor file and absent from the SlimTensor one, and the CUDA build links only the SlimTensor variant, so nothing in that library defined it. The other two are present in the closure, which is why they were fine. Parsed every archive member header in the stub, before and after. The previous file had the time, user and group zeroed in all 48; the version committed earlier carried a real build time in 48 of 49; the version here has all three zeroed again, and the file is byte-for-byte the same size, so nothing but the metadata changed. Compared the advertised names against the previous file: 42 before, 45 now, none dropped, and the three added are exactly the three intended. I have no Windows machine, so the link and load themselves are still for CI.
1 parent 6627a2d commit d53ec66

3 files changed

Lines changed: 12 additions & 0 deletions

File tree

‎backends/aoti/common_shims_slim.cpp‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,14 @@ AOTITorchError aoti_torch_get_numel(Tensor* tensor, int64_t* ret_numel) {
6868
return Error::Ok;
6969
}
7070

71+
AOTITorchError aoti_torch_is_defined(Tensor* tensor, bool* ret_is_defined) {
72+
if (ret_is_defined == nullptr) {
73+
return Error::InvalidArgument;
74+
}
75+
*ret_is_defined = tensor != nullptr;
76+
return Error::Ok;
77+
}
78+
7179
int32_t aoti_torch_layout_strided() {
7280
// Slimtensor only support strided layout, the return value will always be 0,
7381
// a.k.a at::Layout::Strided;

‎backends/aoti/common_shims_slim.h‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,10 @@ aoti_torch_get_dim(Tensor* tensor, int64_t* ret_dim);
5151
AOTI_SHIM_EXPORT AOTITorchError
5252
aoti_torch_get_numel(Tensor* tensor, int64_t* ret_numel);
5353

54+
// PyTorch has an undefined-tensor state with no equivalent here: null check.
55+
AOTI_SHIM_EXPORT AOTITorchError
56+
aoti_torch_is_defined(Tensor* tensor, bool* ret_is_defined);
57+
5458
AOTI_SHIM_EXPORT int32_t aoti_torch_layout_strided();
5559

5660
// ============================================================
0 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)