Skip to content

Commit

Permalink
Update docs
Browse files Browse the repository at this point in the history
  • Loading branch information
adrhill committed Sep 2, 2024
1 parent cd4cf86 commit 7746e81
Showing 1 changed file with 8 additions and 15 deletions.
23 changes: 8 additions & 15 deletions docs/src/dev/adding_overloads.md
Original file line number Diff line number Diff line change
Expand Up @@ -123,19 +123,13 @@ Depending on the type of function you're dealing with, you will have to specify
## [Overloading](@id code-gen)

After implementing the required classification methods for a function, the function has not been overloaded on our tracer types yet.
SCT provides six functions that generate code via meta-programming:
SCT provides three functions that generate code via meta-programming:

* 1-to-1
* `eval(SCT.generate_code_gradient_1_to_1(module_symbol, f))`
* `eval(SCT.generate_code_hessian_1_to_1(module_symbol, f))`
* 2-to-1
* `eval(SCT.generate_code_gradient_1_to_2(module_symbol, f))`
* `eval(SCT.generate_code_hessian_1_to_2(module_symbol, f))`
* 1-to-2
* `eval(SCT.generate_code_gradient_2_to_1(module_symbol, f))`
* `eval(SCT.generate_code_hessian_2_to_1(module_symbol, f))`
* 1-to-1: `eval(SCT.generate_code_1_to_1(module_symbol, f))`
* 2-to-1: `eval(SCT.generate_code_1_to_2(module_symbol, f))`
* 1-to-2: `eval(SCT.generate_code_2_to_1(module_symbol, f))`

You are required to call the two functions that match your type of operator.
You are required to call the function that matches your type of operator.

!!! tip "Code generation"
We will take a look at the code generation mechanism in the example below.
Expand Down Expand Up @@ -170,17 +164,16 @@ The `relu` function has not been overloaded on our tracer types yet.
Let's call the code generation utilities from the [*"Overloading"*](@ref code-gen) section for this purpose:

```@example overload
eval(SCT.generate_code_gradient_1_to_1(:NNlib, relu))
eval(SCT.generate_code_hessian_1_to_1(:NNlib, relu))
eval(SCT.generate_code_1_to_1(:NNlib, relu))
```

The `relu` function is now ready to be called with SCT's tracer types.

!!! details "What is the eval call doing?"
Let's call `generate_code_gradient_1_to_1` without wrapping it `eval`:
Let's call `generate_code_1_to_1` without wrapping it `eval`:

```@example overload
SCT.generate_code_gradient_1_to_1(:NNlib, relu)
SCT.generate_code_1_to_1(:NNlib, relu)
```

As you can see, this returns a `quote`, a type of expression containing our generated Julia code.
Expand Down

0 comments on commit 7746e81

Please sign in to comment.