Skip to content

Commit a4a7482

Browse files
authored
Make two links relative - please review
1 parent 5891e06 commit a4a7482

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

docs/DifferentiableProgrammingImplementation.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -465,7 +465,7 @@ bb0(%x):
465465

466466
### Visiting the original function to create a JVP
467467

468-
In the Swift compiler, we have a class called [`JVPCloner`](https://github.com/apple/swift/blob/main/include/swift/SILOptimizer/Differentiation/JVPCloner.h) which subclasses [`TypeSubstCloner`](https://github.com/apple/swift/blob/master/include/swift/SIL/TypeSubstCloner.h). This uses the [visitor pattern](https://en.wikipedia.org/wiki/Visitor_pattern) to visit the original function and generate the JVP function. Taking a look at the `JVPCloner` class, there are methods like `visitApplyInst`, `visitStructExtractInst`, etc. Each of these methods visit an instruction that is important in the generation of the JVP and differential, and emits a newly mapped version. We handle each type of instruction differently, explained below.
468+
In the Swift compiler, we have a class called [`JVPCloner`](../include/swift/SILOptimizer/Differentiation/JVPCloner.h) which subclasses [`TypeSubstCloner`](../include/swift/SIL/TypeSubstCloner.h). This uses the [visitor pattern](https://en.wikipedia.org/wiki/Visitor_pattern) to visit the original function and generate the JVP function. Taking a look at the `JVPCloner` class, there are methods like `visitApplyInst`, `visitStructExtractInst`, etc. Each of these methods visit an instruction that is important in the generation of the JVP and differential, and emits a newly mapped version. We handle each type of instruction differently, explained below.
469469

470470
One important note is that in the JVP, we visit every single instruction in the original function - sometimes it’s an exact copy, and other times there is some special logic we wrote to handle it differently (e.g. like control-flow discussed below). This is so that the JVP function behaves just like the original function. With this, if the original function has a print statement, the JVP will as well. However, when we consider the differential, we will only transform SIL instructions from the original that we deem to be fit (so no print statement in the differential!). These instructions are those that should be differentiated, which uses the activity analysis calculated earlier to determine which SIL instructions are important in computing the tangent values of a function.
471471

0 commit comments

Comments
 (0)