SparseConnectivityTracer
Documentation for SparseConnectivityTracer.
SparseConnectivityTracer.Tracer
SparseConnectivityTracer.connectivity
SparseConnectivityTracer.inputs
SparseConnectivityTracer.sortedinputs
SparseConnectivityTracer.trace_input
SparseConnectivityTracer.tracer
API reference
Interface
SparseConnectivityTracer.connectivity
— Functionconnectivity(f, x)
Enumerates inputs x
and primal outputs y=f(x)
and returns sparse connectivity matrix C
of size (m, n)
where C[i, j]
is true if the compute graph connects the i
-th entry in y
to the j
-th entry in x
.
Example
julia> x = rand(3);
+Home · SparseConnectivityTracer.jl SparseConnectivityTracer
Documentation for SparseConnectivityTracer.
API reference
SparseConnectivityTracer.Tracer
SparseConnectivityTracer.connectivity
SparseConnectivityTracer.inputs
SparseConnectivityTracer.sortedinputs
SparseConnectivityTracer.trace_input
SparseConnectivityTracer.tracer
Interface
SparseConnectivityTracer.connectivity
— Functionconnectivity(f, x)
Enumerates inputs x
and primal outputs y=f(x)
and returns sparse connectivity matrix C
of size (m, n)
where C[i, j]
is true if the compute graph connects the i
-th entry in y
to the j
-th entry in x
.
Example
julia> x = rand(3);
julia> f(x) = [x[1]^2, 2 * x[1] * x[2]^2, sin(x[3])];
@@ -7,7 +7,7 @@
3×3 SparseArrays.SparseMatrixCSC{Bool, UInt64} with 4 stored entries:
1 ⋅ ⋅
1 1 ⋅
- ⋅ ⋅ 1
sourceconnectivity(f!, y, x)
Enumerates inputs x
and primal outputs y
after f!(y, x)
and returns sparse connectivity matrix C
of size (m, n)
where C[i, j]
is true if the compute graph connects the i
-th entry in y
to the j
-th entry in x
.
sourceInternals
SparseConnectivityTracer works by pushing a Number
type called Tracer
through generic functions:
SparseConnectivityTracer.Tracer
— TypeTracer(indexset) <: Number
Number type keeping track of input indices of previous computations.
See also the convenience constructor tracer
. For a higher-level interface, refer to connectivity
.
Examples
By enumerating inputs with tracers, we can keep track of input connectivities:
julia> xt = [tracer(1), tracer(2), tracer(3)]
+ ⋅ ⋅ 1
sourceconnectivity(f!, y, x)
Enumerates inputs x
and primal outputs y
after f!(y, x)
and returns sparse connectivity matrix C
of size (m, n)
where C[i, j]
is true if the compute graph connects the i
-th entry in y
to the j
-th entry in x
.
sourceInternals
SparseConnectivityTracer works by pushing a Number
type called Tracer
through generic functions:
SparseConnectivityTracer.Tracer
— TypeTracer(indexset) <: Number
Number type keeping track of input indices of previous computations.
See also the convenience constructor tracer
. For a higher-level interface, refer to connectivity
.
Examples
By enumerating inputs with tracers, we can keep track of input connectivities:
julia> xt = [tracer(1), tracer(2), tracer(3)]
3-element Vector{Tracer}:
Tracer(1,)
Tracer(2,)
@@ -18,8 +18,8 @@
julia> yt = f(xt)
3-element Vector{Tracer}:
Tracer(1,)
- Tracer(1, 2)
- Tracer(3,)
This works via operator-overloading, which either keep input connectivities constant, compute unions or set connectivities to zero:
julia> x = tracer(1, 2, 3)
+ Tracer(1, 2)
+ Tracer(3,)
This works by overloading operators to either keep input connectivities constant, compute unions or set connectivities to zero:
julia> x = tracer(1, 2, 3)
Tracer(1, 2, 3)
julia> sin(x) # Most operators don't modify input connectivities.
@@ -41,7 +41,7 @@
Tracer(1, 2, 3, 5)
julia> x ^ y
-Tracer(1, 2, 3, 5)
Tracer
also supports random number generation and pre-allocations:
julia> M = rand(Tracer, 3, 2)
+Tracer(1, 2, 3, 5)
Tracer
also supports random number generation and pre-allocations:
julia> M = rand(Tracer, 3, 2)
3×2 Matrix{Tracer}:
Tracer() Tracer()
Tracer() Tracer()
@@ -57,8 +57,8 @@
3-element Vector{Tracer}:
Tracer(1, 2, 3, 5)
Tracer(1, 2, 3, 5)
- Tracer(1, 2, 3, 5)
sourceSparseConnectivityTracer.tracer
— Functiontracer(index)
-tracer(indices)
Convenience constructor for Tracer
from input indices.
sourceSparseConnectivityTracer.trace_input
— Functiontrace_input(x)
Enumerates input indices and constructs Tracer
s.
Example
julia> x = rand(3);
+ Tracer(1, 2, 3, 5)
sourceSparseConnectivityTracer.tracer
— Functiontracer(index)
+tracer(indices)
Convenience constructor for Tracer
from input indices.
sourceSparseConnectivityTracer.trace_input
— Functiontrace_input(x)
Enumerates input indices and constructs Tracer
s.
Example
julia> x = rand(3);
julia> f(x) = [x[1]^2, 2 * x[1] * x[2]^2, sin(x[3])];
@@ -72,15 +72,15 @@
3-element Vector{Tracer}:
Tracer(1,)
Tracer(1, 2)
- Tracer(3,)
sourceThe following utilities can be used to extract input indices from Tracer
s:
SparseConnectivityTracer.inputs
— Functioninputs(tracer)
Return raw UInt64
input indices of a Tracer
. See also sortedinputs
.
Example
julia> t = tracer(1, 2, 4)
+ Tracer(3,)
sourceThe following utilities can be used to extract input indices from Tracer
s:
SparseConnectivityTracer.inputs
— Functioninputs(tracer)
Return raw UInt64
input indices of a Tracer
. See also sortedinputs
.
Example
julia> t = tracer(1, 2, 4)
Tracer(1, 2, 4)
julia> inputs(t)
3-element Vector{UInt64}:
0x0000000000000004
0x0000000000000002
- 0x0000000000000001
sourceSparseConnectivityTracer.sortedinputs
— Functionsortedinputs(tracer)
-sortedinputs([T=Int], tracer)
Return sorted input indices of a Tracer
. See also inputs
.
Example
julia> t = tracer(1, 2, 4)
+ 0x0000000000000001
sourceSparseConnectivityTracer.sortedinputs
— Functionsortedinputs(tracer)
+sortedinputs([T=Int], tracer)
Return sorted input indices of a Tracer
. See also inputs
.
Example
julia> t = tracer(1, 2, 4)
Tracer(1, 2, 4)
julia> sortedinputs(t)
@@ -93,4 +93,4 @@
3-element Vector{UInt8}:
0x01
0x02
- 0x04
sourceSettings
This document was generated with Documenter.jl version 1.3.0 on Monday 1 April 2024. Using Julia version 1.10.2.
+ 0x04