Skip to content

Add a different implementation of Differentiation #33941

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

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions stdlib/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ option(SWIFT_STDLIB_OS_VERSIONING
"Build stdlib with availability based on OS versions (Darwin only)."
TRUE)

option(SWIFT_EXPERIMENTAL_DIFFERENTIABLE_PROGRAMMING_FUTURE_IMPLEMENTATION
"Build Differentation as it would be long term (i.e. no tgmath)"
FALSE)

#
# End of user-configurable options.
#
Expand Down
8 changes: 7 additions & 1 deletion stdlib/public/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,13 @@ if(SWIFT_BUILD_STDLIB)
add_subdirectory(SwiftOnoneSupport)

if(SWIFT_ENABLE_EXPERIMENTAL_DIFFERENTIABLE_PROGRAMMING)
add_subdirectory(Differentiation)
if(SWIFT_EXPERIMENTAL_DIFFERENTIABLE_PROGRAMMING_FUTURE_IMPLEMENTATION)
# This implementation will quickly evolve, so it does not make sense
# to share code with the other implementation
add_subdirectory(Differentiation_Future)
else()
add_subdirectory(Differentiation)
endif()
endif()

if(SWIFT_ENABLE_EXPERIMENTAL_CONCURRENCY)
Expand Down
20 changes: 20 additions & 0 deletions stdlib/public/Differentiation_Future/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
set(SOURCES_FOLDER ../Differentiation)
Copy link
Member

Choose a reason for hiding this comment

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

This seems in conflict with the comment in the parent CMakeLists, that this code should not be shared.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It is indeed confusing -- my concern was around the CMake code, but the comment is not clear in this regard

I will sit a bit on the PR to see if I can improve the wording and/or the overall readability of the code

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I went ahead and did some rewording -- for the sake of clarify, did that in a new PR, #34116


add_swift_target_library(swift_Differentiation ${SWIFT_STDLIB_LIBRARY_BUILD_TYPES} IS_STDLIB
${SOURCES_FOLDER}/Differentiable.swift
${SOURCES_FOLDER}/DifferentialOperators.swift
${SOURCES_FOLDER}/DifferentiationUtilities.swift
${SOURCES_FOLDER}/AnyDifferentiable.swift
${SOURCES_FOLDER}/ArrayDifferentiation.swift
${SOURCES_FOLDER}/OptionalDifferentiation.swift

GYB_SOURCES
${SOURCES_FOLDER}/FloatingPointDifferentiation.swift.gyb
${SOURCES_FOLDER}/SIMDDifferentiation.swift.gyb

SWIFT_COMPILE_FLAGS
${SWIFT_STANDARD_LIBRARY_SWIFT_FLAGS}
-parse-stdlib
LINK_FLAGS "${SWIFT_RUNTIME_SWIFT_LINK_FLAGS}"
DARWIN_INSTALL_NAME_DIR "@rpath"
INSTALL_IN_COMPONENT stdlib)