From d2a56aac2cc1f37f8b08f22569f50e92592c933c Mon Sep 17 00:00:00 2001 From: "Documenter.jl" Date: Wed, 3 Apr 2024 12:48:22 +0000 Subject: [PATCH] build based on 719b019 --- dev/.documenter-siteinfo.json | 2 +- dev/index.html | 22 +++++++++++----------- dev/search_index.js | 2 +- 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/dev/.documenter-siteinfo.json b/dev/.documenter-siteinfo.json index 60c10904..6ac8dad4 100644 --- a/dev/.documenter-siteinfo.json +++ b/dev/.documenter-siteinfo.json @@ -1 +1 @@ -{"documenter":{"julia_version":"1.10.2","generation_timestamp":"2024-04-01T21:23:55","documenter_version":"1.3.0"}} \ No newline at end of file +{"documenter":{"julia_version":"1.10.2","generation_timestamp":"2024-04-03T12:48:19","documenter_version":"1.3.0"}} \ No newline at end of file diff --git a/dev/index.html b/dev/index.html index ddabaceb..308edb55 100644 --- a/dev/index.html +++ b/dev/index.html @@ -1,5 +1,5 @@ -Home · SparseConnectivityTracer.jl

SparseConnectivityTracer

Documentation for SparseConnectivityTracer.

API reference

Interface

SparseConnectivityTracer.connectivityFunction
connectivity(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

Interface

SparseConnectivityTracer.connectivityFunction
connectivity(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
source
connectivity(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.

source

Internals

SparseConnectivityTracer works by pushing a Number type called Tracer through generic functions:

SparseConnectivityTracer.TracerType
Tracer(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
source
connectivity(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.

source

Internals

SparseConnectivityTracer works by pushing a Number type called Tracer through generic functions:

SparseConnectivityTracer.TracerType
Tracer(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)
source
SparseConnectivityTracer.trace_inputFunction
trace_input(x)

Enumerates input indices and constructs Tracers.

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,)
source

The following utilities can be used to extract input indices from Tracers:

The following utilities can be used to extract input indices from Tracers:

SparseConnectivityTracer.inputsFunction
inputs(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
source
SparseConnectivityTracer.sortedinputsFunction
sortedinputs(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
source
+ 0x04
source
diff --git a/dev/search_index.js b/dev/search_index.js index 9845aa85..1f863deb 100644 --- a/dev/search_index.js +++ b/dev/search_index.js @@ -1,3 +1,3 @@ var documenterSearchIndex = {"docs": -[{"location":"","page":"Home","title":"Home","text":"CurrentModule = SparseConnectivityTracer","category":"page"},{"location":"#SparseConnectivityTracer","page":"Home","title":"SparseConnectivityTracer","text":"","category":"section"},{"location":"","page":"Home","title":"Home","text":"Documentation for SparseConnectivityTracer.","category":"page"},{"location":"","page":"Home","title":"Home","text":"","category":"page"},{"location":"#API-reference","page":"Home","title":"API reference","text":"","category":"section"},{"location":"#Interface","page":"Home","title":"Interface","text":"","category":"section"},{"location":"","page":"Home","title":"Home","text":"connectivity","category":"page"},{"location":"#SparseConnectivityTracer.connectivity","page":"Home","title":"SparseConnectivityTracer.connectivity","text":"connectivity(f, x)\n\nEnumerates 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.\n\nExample\n\njulia> x = rand(3);\n\njulia> f(x) = [x[1]^2, 2 * x[1] * x[2]^2, sin(x[3])];\n\njulia> connectivity(f, x)\n3×3 SparseArrays.SparseMatrixCSC{Bool, UInt64} with 4 stored entries:\n 1 ⋅ ⋅\n 1 1 ⋅\n ⋅ ⋅ 1\n\n\n\n\n\nconnectivity(f!, y, x)\n\nEnumerates 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.\n\n\n\n\n\n","category":"function"},{"location":"#Internals","page":"Home","title":"Internals","text":"","category":"section"},{"location":"","page":"Home","title":"Home","text":"SparseConnectivityTracer works by pushing a Number type called Tracer through generic functions:","category":"page"},{"location":"","page":"Home","title":"Home","text":"Tracer\ntracer\ntrace_input","category":"page"},{"location":"#SparseConnectivityTracer.Tracer","page":"Home","title":"SparseConnectivityTracer.Tracer","text":"Tracer(indexset) <: Number\n\nNumber type keeping track of input indices of previous computations.\n\nSee also the convenience constructor tracer. For a higher-level interface, refer to connectivity.\n\nExamples\n\nBy enumerating inputs with tracers, we can keep track of input connectivities:\n\njulia> xt = [tracer(1), tracer(2), tracer(3)]\n3-element Vector{Tracer}:\n Tracer(1,)\n Tracer(2,)\n Tracer(3,)\n\njulia> f(x) = [x[1]^2, 2 * x[1] * x[2]^2, sin(x[3])];\n\njulia> yt = f(xt)\n3-element Vector{Tracer}:\n Tracer(1,)\n Tracer(1, 2)\n Tracer(3,)\n\nThis works via operator-overloading, which either keep input connectivities constant, compute unions or set connectivities to zero:\n\njulia> x = tracer(1, 2, 3)\nTracer(1, 2, 3)\n\njulia> sin(x) # Most operators don't modify input connectivities.\nTracer(1, 2, 3)\n\njulia> 2 * x^3\nTracer(1, 2, 3)\n\njulia> zero(x) # Tracer is strictly operator overloading... \nTracer()\n\njulia> 0 * x # ...and doesn't look at input values.\nTracer(1, 2, 3)\n\njulia> y = tracer(3, 5)\nTracer(3, 5)\n\njulia> x + y # Operations on two Tracers construct union sets\nTracer(1, 2, 3, 5)\n\njulia> x ^ y\nTracer(1, 2, 3, 5)\n\nTracer also supports random number generation and pre-allocations:\n\njulia> M = rand(Tracer, 3, 2)\n3×2 Matrix{Tracer}:\n Tracer() Tracer()\n Tracer() Tracer()\n Tracer() Tracer()\n\njulia> similar(M)\n3×2 Matrix{Tracer}:\n Tracer() Tracer()\n Tracer() Tracer()\n Tracer() Tracer()\n\njulia> M * [x, y]\n3-element Vector{Tracer}:\n Tracer(1, 2, 3, 5)\n Tracer(1, 2, 3, 5)\n Tracer(1, 2, 3, 5)\n\n\n\n\n\n","category":"type"},{"location":"#SparseConnectivityTracer.tracer","page":"Home","title":"SparseConnectivityTracer.tracer","text":"tracer(index)\ntracer(indices)\n\nConvenience constructor for Tracer from input indices.\n\n\n\n\n\n","category":"function"},{"location":"#SparseConnectivityTracer.trace_input","page":"Home","title":"SparseConnectivityTracer.trace_input","text":"trace_input(x)\n\nEnumerates input indices and constructs Tracers.\n\nExample\n\njulia> x = rand(3);\n\njulia> f(x) = [x[1]^2, 2 * x[1] * x[2]^2, sin(x[3])];\n\njulia> xt = trace_input(x)\n3-element Vector{Tracer}:\n Tracer(1,)\n Tracer(2,)\n Tracer(3,)\n\njulia> yt = f(xt)\n3-element Vector{Tracer}:\n Tracer(1,)\n Tracer(1, 2)\n Tracer(3,)\n\n\n\n\n\n","category":"function"},{"location":"","page":"Home","title":"Home","text":"The following utilities can be used to extract input indices from Tracers:","category":"page"},{"location":"","page":"Home","title":"Home","text":"inputs\nsortedinputs","category":"page"},{"location":"#SparseConnectivityTracer.inputs","page":"Home","title":"SparseConnectivityTracer.inputs","text":"inputs(tracer)\n\nReturn raw UInt64 input indices of a Tracer. See also sortedinputs.\n\nExample\n\njulia> t = tracer(1, 2, 4)\nTracer(1, 2, 4)\n\njulia> inputs(t)\n3-element Vector{UInt64}:\n 0x0000000000000004\n 0x0000000000000002\n 0x0000000000000001\n\n\n\n\n\n","category":"function"},{"location":"#SparseConnectivityTracer.sortedinputs","page":"Home","title":"SparseConnectivityTracer.sortedinputs","text":"sortedinputs(tracer)\nsortedinputs([T=Int], tracer)\n\nReturn sorted input indices of a Tracer. See also inputs.\n\nExample\n\njulia> t = tracer(1, 2, 4)\nTracer(1, 2, 4)\n\njulia> sortedinputs(t)\n3-element Vector{Int64}:\n 1\n 2\n 4\n\njulia> sortedinputs(UInt8, t)\n3-element Vector{UInt8}:\n 0x01\n 0x02\n 0x04\n\n\n\n\n\n","category":"function"}] +[{"location":"","page":"Home","title":"Home","text":"CurrentModule = SparseConnectivityTracer","category":"page"},{"location":"#SparseConnectivityTracer","page":"Home","title":"SparseConnectivityTracer","text":"","category":"section"},{"location":"","page":"Home","title":"Home","text":"Documentation for SparseConnectivityTracer.","category":"page"},{"location":"#API-reference","page":"Home","title":"API reference","text":"","category":"section"},{"location":"","page":"Home","title":"Home","text":"","category":"page"},{"location":"#Interface","page":"Home","title":"Interface","text":"","category":"section"},{"location":"","page":"Home","title":"Home","text":"connectivity","category":"page"},{"location":"#SparseConnectivityTracer.connectivity","page":"Home","title":"SparseConnectivityTracer.connectivity","text":"connectivity(f, x)\n\nEnumerates 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.\n\nExample\n\njulia> x = rand(3);\n\njulia> f(x) = [x[1]^2, 2 * x[1] * x[2]^2, sin(x[3])];\n\njulia> connectivity(f, x)\n3×3 SparseArrays.SparseMatrixCSC{Bool, UInt64} with 4 stored entries:\n 1 ⋅ ⋅\n 1 1 ⋅\n ⋅ ⋅ 1\n\n\n\n\n\nconnectivity(f!, y, x)\n\nEnumerates 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.\n\n\n\n\n\n","category":"function"},{"location":"#Internals","page":"Home","title":"Internals","text":"","category":"section"},{"location":"","page":"Home","title":"Home","text":"SparseConnectivityTracer works by pushing a Number type called Tracer through generic functions:","category":"page"},{"location":"","page":"Home","title":"Home","text":"Tracer\ntracer\ntrace_input","category":"page"},{"location":"#SparseConnectivityTracer.Tracer","page":"Home","title":"SparseConnectivityTracer.Tracer","text":"Tracer(indexset) <: Number\n\nNumber type keeping track of input indices of previous computations.\n\nSee also the convenience constructor tracer. For a higher-level interface, refer to connectivity.\n\nExamples\n\nBy enumerating inputs with tracers, we can keep track of input connectivities:\n\njulia> xt = [tracer(1), tracer(2), tracer(3)]\n3-element Vector{Tracer}:\n Tracer(1,)\n Tracer(2,)\n Tracer(3,)\n\njulia> f(x) = [x[1]^2, 2 * x[1] * x[2]^2, sin(x[3])];\n\njulia> yt = f(xt)\n3-element Vector{Tracer}:\n Tracer(1,)\n Tracer(1, 2)\n Tracer(3,)\n\nThis works by overloading operators to either keep input connectivities constant, compute unions or set connectivities to zero:\n\njulia> x = tracer(1, 2, 3)\nTracer(1, 2, 3)\n\njulia> sin(x) # Most operators don't modify input connectivities.\nTracer(1, 2, 3)\n\njulia> 2 * x^3\nTracer(1, 2, 3)\n\njulia> zero(x) # Tracer is strictly operator overloading... \nTracer()\n\njulia> 0 * x # ...and doesn't look at input values.\nTracer(1, 2, 3)\n\njulia> y = tracer(3, 5)\nTracer(3, 5)\n\njulia> x + y # Operations on two Tracers construct union sets\nTracer(1, 2, 3, 5)\n\njulia> x ^ y\nTracer(1, 2, 3, 5)\n\nTracer also supports random number generation and pre-allocations:\n\njulia> M = rand(Tracer, 3, 2)\n3×2 Matrix{Tracer}:\n Tracer() Tracer()\n Tracer() Tracer()\n Tracer() Tracer()\n\njulia> similar(M)\n3×2 Matrix{Tracer}:\n Tracer() Tracer()\n Tracer() Tracer()\n Tracer() Tracer()\n\njulia> M * [x, y]\n3-element Vector{Tracer}:\n Tracer(1, 2, 3, 5)\n Tracer(1, 2, 3, 5)\n Tracer(1, 2, 3, 5)\n\n\n\n\n\n","category":"type"},{"location":"#SparseConnectivityTracer.tracer","page":"Home","title":"SparseConnectivityTracer.tracer","text":"tracer(index)\ntracer(indices)\n\nConvenience constructor for Tracer from input indices.\n\n\n\n\n\n","category":"function"},{"location":"#SparseConnectivityTracer.trace_input","page":"Home","title":"SparseConnectivityTracer.trace_input","text":"trace_input(x)\n\nEnumerates input indices and constructs Tracers.\n\nExample\n\njulia> x = rand(3);\n\njulia> f(x) = [x[1]^2, 2 * x[1] * x[2]^2, sin(x[3])];\n\njulia> xt = trace_input(x)\n3-element Vector{Tracer}:\n Tracer(1,)\n Tracer(2,)\n Tracer(3,)\n\njulia> yt = f(xt)\n3-element Vector{Tracer}:\n Tracer(1,)\n Tracer(1, 2)\n Tracer(3,)\n\n\n\n\n\n","category":"function"},{"location":"","page":"Home","title":"Home","text":"The following utilities can be used to extract input indices from Tracers:","category":"page"},{"location":"","page":"Home","title":"Home","text":"inputs\nsortedinputs","category":"page"},{"location":"#SparseConnectivityTracer.inputs","page":"Home","title":"SparseConnectivityTracer.inputs","text":"inputs(tracer)\n\nReturn raw UInt64 input indices of a Tracer. See also sortedinputs.\n\nExample\n\njulia> t = tracer(1, 2, 4)\nTracer(1, 2, 4)\n\njulia> inputs(t)\n3-element Vector{UInt64}:\n 0x0000000000000004\n 0x0000000000000002\n 0x0000000000000001\n\n\n\n\n\n","category":"function"},{"location":"#SparseConnectivityTracer.sortedinputs","page":"Home","title":"SparseConnectivityTracer.sortedinputs","text":"sortedinputs(tracer)\nsortedinputs([T=Int], tracer)\n\nReturn sorted input indices of a Tracer. See also inputs.\n\nExample\n\njulia> t = tracer(1, 2, 4)\nTracer(1, 2, 4)\n\njulia> sortedinputs(t)\n3-element Vector{Int64}:\n 1\n 2\n 4\n\njulia> sortedinputs(UInt8, t)\n3-element Vector{UInt8}:\n 0x01\n 0x02\n 0x04\n\n\n\n\n\n","category":"function"}] }