-
Notifications
You must be signed in to change notification settings - Fork 19
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
Long long fix #191
Long long fix #191
Conversation
e491c33
to
5fb0887
Compare
@jwallwork23 @jatkinson1000 , to make reviewing easier this PR should be merged before #137 |
src/CMakeLists.txt
Outdated
add_library(${LIB_NAME} SHARED ctorch.cpp ftorch.F90 ftorch_test_utils.f90) | ||
|
||
if(UNIX) | ||
message(STATUS "CMAKE_SYSTEM_PROCESSOR = ${CMAKE_SYSTEM_PROCESSOR}") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
message(STATUS "CMAKE_SYSTEM_PROCESSOR = ${CMAKE_SYSTEM_PROCESSOR}") |
Just remembered I left this print statement in for debugging. I should take this out
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did you remove this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not yet. I will look at fixing the mac build before I take it out completely
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks sensible to me, @TomMelt. I haven't tested it on my laptop running Windows but I can do if needed.
Thanks @jwallwork23. Wouldn't hurt if you get time but I did test on windows vm so it should be fine 👌 I do plan on setting up a windows CI soon so that should also catch any issues. |
594e938
to
4d66327
Compare
5fb0887
to
a005817
Compare
It seems that this incompatibility still exists on Mac 12 and 13 - see #192 So the CMake/#ifdef might need some refinement. |
src/ctorch.h
Outdated
EXPORT_C const long long int * | ||
torch_tensor_get_sizes(const torch_tensor_t tensor); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm surprised the linter likes these not being on the same line.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
honestly... it makes me sad. I had them on the same line, but the linter forces it to split :(
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can maybe use a config file to extend the column limit?
https://clang.llvm.org/docs/ClangFormatStyleOptions.html
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm a little confused, when I run clang-format locally it moves them to be placed on one line...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if this is to do with the default settings being different for different clang-format versions? We observed this in nextSIM-DG and so pinned the version used by the CI.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have just opened #199 to here which should resolve this by fixing Cpp Column Limit to 88.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Approved once, will approve again. Thanks @TomMelt!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As discussed in-person, I think this can go in now and the issues with mac can be resolved in a separate set of issues.
Thanks @TomMelt!
fixes [#183](#183) There is an issue when building on mac (arm_64) or windows. The version of `libtorch` exposes a torch tensors shape (`t->sizes().data()`) as a `const long long int*` instead of just a `const long int*` like on linux and mac (x86). This commit adds preprocessor macro to switch between implementations automatically detecting the correct version at CMake build stage.
a005817
to
6ec89a0
Compare
Have rebased #199 on this if you want to merge. |
closes #183
Problem
This issue also affected windows and is also fixed by this PR.
Tldr;
FTorch
expects along int*
whilst thelibtorch
binary seems to be returning along long int*
.Example output below.
Solution
The solution is to check which system we are running on (OS and architecture) and create a preprocess macro
-DUNIX
that we can use to switch betweenlong long int
andlong int
versions of thelibtorch
library.FTorch/src/CMakeLists.txt
Lines 57 to 62 in 5fb0887
Then in the source code we check for that macro e.g.,
FTorch/src/ctorch.h
Lines 128 to 132 in 5fb0887
TODO