Skip to content

Commit 6ce1c54

Browse files
abhrovchuravy
authored andcommitted
Fix typos
1 parent 41ee62c commit 6ce1c54

17 files changed

Lines changed: 95 additions & 95 deletions

File tree

docs/src/dev_docs.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
## Development of Enzyme and Enzyme.jl together (recommended)
44

55
Normally Enzyme.jl downloads and installs [Enzyme](https://github.com/EnzymeAD/enzyme) for the user automatically since Enzyme needs to be built against
6-
Julia bundeled LLVM. In case that you are making updates to Enzyme and want to test them against Enzyme.jl the instructions
6+
Julia bundled LLVM. In case that you are making updates to Enzyme and want to test them against Enzyme.jl the instructions
77
below should help you get started.
88

99
Start Julia in your development copy of Enzyme.jl and initialize the deps project
@@ -24,7 +24,7 @@ It may take a few minutes to compile fully.
2424
~/s/Enzyme.jl (master)> julia --project=deps deps/build_local.jl
2525
```
2626

27-
You will now find a file LocalPrefernces.toml which has been generated and contains a path to the new Enzyme\_jll binary you have built.
27+
You will now find a file LocalPreferences.toml which has been generated and contains a path to the new Enzyme\_jll binary you have built.
2828
To use your Enzyme\_jll instead of the default shipped by Enzyme.jl, ensure that this file is at the root of any Julia project you wish
2929
to test it with *and* that the Julia project has Enzyme\_jll as an explicit dependency. Note that an indirect dependency here is not
3030
sufficient (e.g. just because a project depends on Enzyme.jl, which depends on Enzyme\_jll, does not mean that your project will pick up

docs/src/faq.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ The derivative that Enzyme creates for `A(x)` would create both the backing/inde
235235

236236
For any program which generates sparse data structures internally, like the total program `f(A(x))`, this will always give you the answer you expect. Moreover, the memory requirements of the derivative will be the same as the primal (other AD tools will blow up the memory usage and construct dense derivatives where the primal was sparse).
237237

238-
The added caveat, however, comes when you differentiate a top level function that has a sparse array input. For example, consider the sparse `sum` function which adds up all elements. While in one definition, this function represents summing up all elements of the virtual sparse array (including the zero's which are never materialized), in a more literal sense this `sum` function will only add elements 3 and 10 of the input sparse array -- the only two nonzero elements -- or equivalently the sum of the whole backing array. Correspondingly Enzyme will update the sparse shadow data structure to mark both elements 3 and 10 as having a derivative of 1 (or more literally set all the elements of the backing array to derivative 1). These are the only variables that Enzyme needs to update, since they are the only variables read (and thus the only ones which have a non-zero derivative). Thus any function which may call this method and compose via the chain rule will only ever read the derivative of these two elements. This is why this memory-safe representation composes within Enzyme, though may produce counter-intuitive reuslts at the top level.
238+
The added caveat, however, comes when you differentiate a top level function that has a sparse array input. For example, consider the sparse `sum` function which adds up all elements. While in one definition, this function represents summing up all elements of the virtual sparse array (including the zero's which are never materialized), in a more literal sense this `sum` function will only add elements 3 and 10 of the input sparse array -- the only two nonzero elements -- or equivalently the sum of the whole backing array. Correspondingly Enzyme will update the sparse shadow data structure to mark both elements 3 and 10 as having a derivative of 1 (or more literally set all the elements of the backing array to derivative 1). These are the only variables that Enzyme needs to update, since they are the only variables read (and thus the only ones which have a non-zero derivative). Thus any function which may call this method and compose via the chain rule will only ever read the derivative of these two elements. This is why this memory-safe representation composes within Enzyme, though may produce counter-intuitive results at the top level.
239239

240240
If the name we gave to this data structure wasn’t "SparseArray" but instead "MyStruct" this is precisely the answer we would have desired. However, since the sparse array printer prints zeros for elements outside of the sparse backing array, this isn’t what one would expect. Making a nicer user conversion from Enzyme’s form of differential data structures, to the more natural "Julia" form where there is a semantic mismatch between what Julia intends a data structure to mean by name, and what is being discussed [here](https://github.com/EnzymeAD/Enzyme.jl/issues/1334).
241241

@@ -323,7 +323,7 @@ If one created a new zero'd copy of each return from `g`, this would mean that t
323323

324324
Instead, Enzyme has a special mode known as "Runtime Activity" which can handle these types of situations. It can come with a minor performance reduction, and is therefore off by default. It can be enabled with by setting runtime activity to true in a desired differentiation mode.
325325

326-
The way Enzyme's runtime activity resolves this issue is to return the original primal variable as the derivative whenever it needs to denote the fact that a variable is a constant. As this issue can only arise with mutable variables, they must be represented in memory via a pointer. All addtional loads and stores will now be modified to first check if the primal pointer is the same as the shadow pointer, and if so, treat it as a constant. Note that this check is not saying that the same arrays contain the same values, but rather the same backing memory represents both the primal and the shadow (e.g. `a === b` or equivalently `pointer(a) == pointer(b)`).
326+
The way Enzyme's runtime activity resolves this issue is to return the original primal variable as the derivative whenever it needs to denote the fact that a variable is a constant. As this issue can only arise with mutable variables, they must be represented in memory via a pointer. All additional loads and stores will now be modified to first check if the primal pointer is the same as the shadow pointer, and if so, treat it as a constant. Note that this check is not saying that the same arrays contain the same values, but rather the same backing memory represents both the primal and the shadow (e.g. `a === b` or equivalently `pointer(a) == pointer(b)`).
327327

328328
Enabling runtime activity does therefore, come with a sharp edge, which is that if the computed derivative of a function is mutable, one must also check to see if the primal and shadow represent the same pointer, and if so the true derivative of the function is actually zero.
329329

@@ -492,9 +492,9 @@ This is somewhat inefficient, since we need to call the forward pass twice, once
492492
```jldoctest complex
493493
fwd, rev = Enzyme.autodiff_thunk(ReverseSplitNoPrimal, Const{typeof(f)}, Active, Active{ComplexF64})
494494
495-
# Compute the reverse pass seeded with a differntial return of 1.0 + 0.0im
495+
# Compute the reverse pass seeded with a differential return of 1.0 + 0.0im
496496
grad_u = rev(Const(f), Active(z), 1.0 + 0.0im, fwd(Const(f), Active(z))[1])[1][1]
497-
# Compute the reverse pass seeded with a differntial return of 0.0 + 1.0im
497+
# Compute the reverse pass seeded with a differential return of 0.0 + 1.0im
498498
grad_v = rev(Const(f), Active(z), 0.0 + 1.0im, fwd(Const(f), Active(z))[1])[1][1]
499499
500500
(grad_u, grad_v)
@@ -558,7 +558,7 @@ d_im = -im * Enzyme.autodiff(Forward, f, Duplicated(z, 0.0+1.0im))[1]
558558

559559
Interestingly, the derivative of `z*z` is the same when computed in either axis. That is because this function is part of a special class of functions that are invariant to the input direction, called holomorphic.
560560

561-
Thus, for holomorphic functions, we can simply seed Forward-mode AD with a shadow of one for whatever input we are differenitating. This is nice since seeding the shadow with an input of one is exactly what we'd do for real-valued funtions as well.
561+
Thus, for holomorphic functions, we can simply seed Forward-mode AD with a shadow of one for whatever input we are differenitating. This is nice since seeding the shadow with an input of one is exactly what we'd do for real-valued functions as well.
562562

563563
Reverse-mode AD, however, is more tricky. This is because holomorphic functions are invariant to the direction of differentiation (aka the derivative inputs), not the direction of the differential return.
564564

@@ -577,7 +577,7 @@ conj(grad_u)
577577

578578
In the case of a scalar-input scalar-output function, that's sufficient. However, most of the time one uses reverse mode, it involves either several inputs or outputs, perhaps via memory. This case requires additional handling to properly sum all the partial derivatives from the use of each input and apply the conjugate operator at only the ones relevant to the differential return.
579579

580-
For simplicity, Enzyme provides a helper utlity `ReverseHolomorphic` which performs Reverse mode properly here, assuming that the function is indeed holomorphic and thus has a well-defined single derivative.
580+
For simplicity, Enzyme provides a helper utility `ReverseHolomorphic` which performs Reverse mode properly here, assuming that the function is indeed holomorphic and thus has a well-defined single derivative.
581581

582582
```jldoctest complex
583583
Enzyme.autodiff(ReverseHolomorphic, f, Active, Active(z))[1][1]
@@ -754,7 +754,7 @@ mutable struct Obj
754754
function Obj(x)
755755
o = new(x)
756756
finalizer(o) do o
757-
# do someting with o
757+
# do something with o
758758
end
759759
return o
760760
end

docs/src/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -309,7 +309,7 @@ EnzymeRules.inactive_noinl(::typeof(det), ::UnitaryMatrix) = true
309309

310310
### [Easy Rules](@id man-easy-rule)
311311

312-
The recommended way for writing rules for most use cases is through the [`EnzymeRules.@easy_rule`](@ref) macro. This macro enables users to write derivatives for any functions which only read from their arguments (e.g. do not overwrite memory), and has numbers, matricies of numbers, or tuples thereof as arguments/result types.
312+
The recommended way for writing rules for most use cases is through the [`EnzymeRules.@easy_rule`](@ref) macro. This macro enables users to write derivatives for any functions which only read from their arguments (e.g. do not overwrite memory), and has numbers, matrices of numbers, or tuples thereof as arguments/result types.
313313

314314
When writing an [`EnzymeRules.@easy_rule`](@ref) one first describes the function signature one wants the derivative rule to apply to. In each subsequent line, one should write a tuple, where each element of the tuple represents the derivative of the corresponding input argument. In that sense writing an [`EnzymeRules.@easy_rule`](@ref) is equivalent to specifying the Jacobian. Inside of this tuple, one can call arbitrary Julia code.
315315

lib/EnzymeCore/src/easyrules.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -729,7 +729,7 @@ If a specific argument has no partial derivative, then all corresponding argumen
729729
730730
# Examples
731731
732-
Let's write an `@easy_rule` for a simple trigonometric function. Enzyme already has rules for `sin` and `cos`, but for the sake of illustration we can define a new pass-through function to oen of them to demostrate the `@easy_rule` interface.
732+
Let's write an `@easy_rule` for a simple trigonometric function. Enzyme already has rules for `sin` and `cos`, but for the sake of illustration we can define a new pass-through function to one of them to demonstrate the `@easy_rule` interface.
733733
734734
```julia
735735
mycos(x) = cos(x)

lib/EnzymeTestUtils/test/to_vec.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ end
140140

141141
@testset "subarrays" begin
142142
x = randn(2, 3)
143-
# note: bottom right 2x2 submatrix ommited from y but will be present in v
143+
# note: bottom right 2x2 submatrix omitted from y but will be present in v
144144
y = @views (x[:, 1], x[1, :])
145145
test_to_vec(y)
146146
v, from_vec = to_vec(y)

src/Enzyme.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -920,7 +920,7 @@ or `Duplicated` (or its variants `DuplicatedNoNeed`, `BatchDuplicated`, and
920920
921921
The forward function will return a tape, the primal (or nothing if not requested),
922922
and the shadow (or nothing if not a `Duplicated` variant), and tapes the corresponding
923-
type arguements provided.
923+
type arguments provided.
924924
925925
The reverse function will return the derivative of `Active` arguments, updating the `Duplicated`
926926
arguments in place. The same arguments to the forward pass should be provided, followed by
@@ -1364,7 +1364,7 @@ or `Duplicated` (or its variants `DuplicatedNoNeed`, `BatchDuplicated`, and
13641364
13651365
The forward function will return a tape, the primal (or nothing if not requested),
13661366
and the shadow (or nothing if not a `Duplicated` variant), and tapes the corresponding
1367-
type arguements provided.
1367+
type arguments provided.
13681368
13691369
The reverse function will return the derivative of `Active` arguments, updating the `Duplicated`
13701370
arguments in place. The same arguments to the forward pass should be provided, followed by

src/absint.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -646,7 +646,7 @@ function abs_typeof(
646646
# julia code (for example pointer(x) ), or is a storage container for an array / memory
647647
# in the latter case, it may need an extra level of indirection because of boxing. It is semantically
648648
# consistent here to consider Ptr{T} to represent the ptr to the boxed value in that case [and we essentially
649-
# add the extra poitner offset when loading here]. However for pointers constructed by ccall outside julia
649+
# add the extra pointer offset when loading here]. However for pointers constructed by ccall outside julia
650650
# to a julia object, which are not inline by type but appear so, like SparseArrays, this is a problem
651651
# and merits further investigation. x/ref https://github.com/EnzymeAD/Enzyme.jl/issues/2085
652652
@static if Base.USE_GPL_LIBS

src/api.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1189,7 +1189,7 @@ end
11891189
11901190
Enzyme runs a type analysis to deduce the corresponding types of all values being
11911191
differentiated. This is necessary to compute correct derivatives of various values.
1192-
To ensure this analysis temrinates, it operates on a finite lattice of possible
1192+
To ensure this analysis terminates, it operates on a finite lattice of possible
11931193
states. This function sets the maximum offset into a type that Enzyme will consider.
11941194
A smaller value will cause type analysis to run faster, but may result in some
11951195
necessary types not being found and result in unknown type errors. A larger value
@@ -1206,7 +1206,7 @@ end
12061206
12071207
Enzyme runs a type analysis to deduce the corresponding types of all values being
12081208
differentiated. This is necessary to compute correct derivatives of various values.
1209-
To ensure this analysis temrinates, it operates on a finite lattice of possible
1209+
To ensure this analysis terminates, it operates on a finite lattice of possible
12101210
states. This function sets the maximum depth into a type that Enzyme will consider.
12111211
A smaller value will cause type analysis to run faster, but may result in some
12121212
necessary types not being found and result in unknown type errors. A larger value
@@ -1270,7 +1270,7 @@ end
12701270
"""
12711271
typeWarning!(val::Bool)
12721272
1273-
Whether to print a warning when Type Analysis learns informatoin about a value's type
1273+
Whether to print a warning when Type Analysis learns information about a value's type
12741274
which cannot be represented in the current size of the lattice. See [`maxtypeoffset!`](@ref) for
12751275
more information.
12761276
Off by default.

src/compiler.jl

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ struct EnzymeCompilerParams{Params<:AbstractCompilerParams} <: AbstractEnzymeCom
8282
rt::Type{<:Annotation{T} where {T}}
8383
run_enzyme::Bool
8484
abiwrap::Bool
85-
# Whether, in split mode, acessible primal argument data is modified
85+
# Whether, in split mode, accessible primal argument data is modified
8686
# between the call and the split
8787
modifiedBetween::NTuple{N,Bool} where {N}
8888
# Whether to also return the primal
@@ -1425,8 +1425,8 @@ function julia_sanitize(
14251425
val = LLVM.Value(val)
14261426
B = LLVM.IRBuilder(B)
14271427
if CheckNan[]
1428-
curent_bb = position(B)
1429-
fn = LLVM.parent(curent_bb)
1428+
current_bb = position(B)
1429+
fn = LLVM.parent(current_bb)
14301430
mod = LLVM.parent(fn)
14311431
ty = LLVM.value_type(val)
14321432
vt = LLVM.VoidType()
@@ -1776,7 +1776,7 @@ function shadow_alloc_rewrite(V::LLVM.API.LLVMValueRef, gutils::API.EnzymeGradie
17761776
end
17771777

17781778
if mode == API.DEM_ForwardMode && (used || idx != 0)
1779-
# Zero any jlvalue_t inner elements of preceeding allocation.
1779+
# Zero any jlvalue_t inner elements of preceding allocation.
17801780

17811781
# Specifically in forward mode, you will first run the original allocation,
17821782
# then all shadow allocations. These allocations will thus all run before
@@ -1785,7 +1785,7 @@ function shadow_alloc_rewrite(V::LLVM.API.LLVMValueRef, gutils::API.EnzymeGradie
17851785
# %"orig'" = julia.gcalloc(...)
17861786
# store orig[0] = jlvaluet
17871787
# store "orig'"[0] = jlvaluet'
1788-
# As a result, by the time of the subsequent GC allocation, the memory in the preceeding
1788+
# As a result, by the time of the subsequent GC allocation, the memory in the preceding
17891789
# allocation might be undefined, and trigger a GC error. To avoid this,
17901790
# we will explicitly zero the GC'd fields of the previous allocation.
17911791

@@ -1797,7 +1797,7 @@ function shadow_alloc_rewrite(V::LLVM.API.LLVMValueRef, gutils::API.EnzymeGradie
17971797
create_recursive_stores(B, Ty, prev, count)
17981798
end
17991799
if (mode == API.DEM_ReverseModePrimal || mode == API.DEM_ReverseModeCombined) && used
1800-
# Zero any jlvalue_t inner elements of preceeding allocation.
1800+
# Zero any jlvalue_t inner elements of preceding allocation.
18011801

18021802
# Specifically in reverse mode, you will run the original allocation,
18031803
# after all shadow allocations. The shadow allocations will thus all run before any value may store into them. For example, as follows:
@@ -2228,9 +2228,9 @@ end
22282228

22292229
function emit_inacterror(B::LLVM.API.LLVMBuilderRef, V::LLVM.API.LLVMValueRef, orig::LLVM.API.LLVMValueRef)
22302230
B = LLVM.IRBuilder(B)
2231-
curent_bb = position(B)
2231+
current_bb = position(B)
22322232
orig = LLVM.Value(orig)
2233-
fn = LLVM.parent(curent_bb)
2233+
fn = LLVM.parent(current_bb)
22342234
mod = LLVM.parent(fn)
22352235

22362236
bt = GPUCompiler.backtrace(orig)
@@ -3371,7 +3371,7 @@ function create_abi_wrapper(
33713371
# Enzyme expects, arg, [w x darg], root, droot
33723372
# Julia expects arg, root, darg, droot
33733373
# We already pushed arg
3374-
# now params[i] referrs to root
3374+
# now params[i] refers to root
33753375
darg = nothing
33763376
root = nothing
33773377
droot = nothing
@@ -6608,7 +6608,7 @@ const DumpLLVMCall = Ref(false)
66086608
tape = callparams[end-1]
66096609
end
66106610
if value_type(tape) != llty
6611-
throw(AssertionError("MisMatched Tape type, expected $(string(value_type(tape))) found $(string(llty)) from $TapeType arg_roots=$arg_roots"))
6611+
throw(AssertionError("Mismatched Tape type, expected $(string(value_type(tape))) found $(string(llty)) from $TapeType arg_roots=$arg_roots"))
66126612
end
66136613
end
66146614
end

src/compiler/interpreter.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1260,7 +1260,7 @@ function abstract_call_known(
12601260
if interp.broadcast_rewrite
12611261
if f === Base.copyto! && length(argtypes) == 3
12621262
# Ideally we just override uses of the AbstractArray base class, but
1263-
# I don't know how to override the method in base, without accidentally overridding
1263+
# I don't know how to override the method in base, without accidentally overriding
12641264
# it for say CuArray or other users. For safety, we only override for Array
12651265
if widenconst(argtypes[2]) <: Array &&
12661266
widenconst(argtypes[3]) <: Base.Broadcast.Broadcasted{Nothing}

0 commit comments

Comments
 (0)