diff --git a/tutorials/GraphCompiler.md b/tutorials/GraphCompiler.md index 0de5ff0fc..e7d25cd4a 100644 --- a/tutorials/GraphCompiler.md +++ b/tutorials/GraphCompiler.md @@ -15,13 +15,13 @@ limitations under the License. --> # The Graph Compiler -_Note: We're not compiler experts, so this tutorial is more about spidr itself than a guide to compiler design._ +_Note: We're not compiler experts; this tutorial is more about spidr itself than a guide to compiler design._ -## Efficient reuse of tensors, and working with `Ref` +## Efficiently reusing tensors, and working with `Ref` -spidr explicitly caches tensors so they can be efficiently be reused. Our understanding is that the technique we have used to achieve this is called observable sharing. In this section we'll discuss what our implementation means for spidr's tensor API. +spidr explicitly caches tensors so they can be efficiently be reused. We achieved this with _observable sharing_. In this section we discuss what our implementation means for spidr's tensor API. -Caching ensures that the computation you write will be the computation sent to the graph compiler. Unfortunately this comes with downsides. Firstly, there is extra boilerplate. Most tensor operations accept `Tensor shape dtype` and output `Ref (Tensor shape dtype)`, so computations must handle the `Ref` effect. For example, what might be `abs (max x)` in another library is, for example, `abs !(max x)` in spidr. One notable exception to this is for infix operators where, to avoid unreadable algebra, we have defined infix operators to accept `Ref (Tensor shape dtype)` values. This means you will need to wrap a bare `Tensor shape dtype` in `pure` to pass it to an infix operator. For example, +Caching ensures that the computation you write will be the computation sent to the graph compiler. Unfortunately this comes with downsides. First, there is extra boilerplate. Most tensor operations accept `Tensor shape dtype` and output `Ref (Tensor shape dtype)`, so when you compose operations, you'll need to handle the `Ref` effect. For example, what might be `abs (max x y)` in another library can be `abs !(max !x !y)` in spidr. One notable exception to this is infix operators, which accept `Ref (Tensor shape dtype)` values. This is to avoid unreadable algebra: you won't need to write `!(!x * !y) + !z`. However, it does mean you will need to wrap any `Tensor shape dtype` values in `pure` to pass it to an infix operator. Let's see an example: