Deep.Net


Expr

Namespace: SymTensor

expression module

Nested types and modules

TypeDescription
ArityT

arity of an op

BinaryOpT

ops with two exprs as arguments

ChannelT

a channel of a multi-channel op or loop

ExprRngSpecT

a simplified range specification of one dimension

ExprRngsSpecT

a simplified range specification of all dimensions

ExprT

an expression

FullExprRngSpecT
FullExprRngsSpecT
IOp

A mathematical operation in an expression. This models a mathematical function or operator that takes one or more tensors and returns one tensor.

LeafOpT

ops with no exprs as arguments

LoopInputT

a loop variable value specification

LoopSpecT

A loop specification. A loop provides iterative evaluation of one or multiple expresisons. A loop can slice over its arguments and reference values computed in previous loop iterations. A loop can compute multiple values at once. Each computed values is referred to as a channel.

LoopValueT

the value of a loop channel

MultiChannelOpT

an n-ary op with multiple output channels

NaryOpT

ops with an arbitrary exprs as arguments

PlusElems

start plus the specified number of (symbolic elements)

PreviousChannelT

references a loop channel of a previous iteration

SequenceArgSliceT

a slice of an argument to the loop

UnaryHeldOpT

an op that will expand into an expression once symbolic sizes have been substituted

UnaryOpT

ops with one expr as argument

Functions and values

Function or valueDescription
annotate ano a
Signature: ano:string -> a:ExprT -> ExprT

annotated expression

arange size
Signature: size:SizeSpecT -> ExprT
Type parameters: 'T

Vector counting from zero to given size minus one.

arangeOfType shp typ
Signature: shp:SizeSpecT -> typ:Type -> ExprT

Vector counting from zero to given size minus one.

argMaxAxis ax a
Signature: ax:int -> a:ExprT -> ExprT

index of maximum over given dimension

argMaxKeepingAxis ax a
Signature: ax:int -> a:ExprT -> ExprT

index of maximum over given dimension, while keeping the axis with one (broadcastable) element

argMinAxis ax a
Signature: ax:int -> a:ExprT -> ExprT

index of maximum over given dimension

argMinKeepingAxis ax a
Signature: ax:int -> a:ExprT -> ExprT

index of maximum over given dimension, while keeping the axis with one (broadcastable) element

assumeJacobian jac expr
Signature: jac:ExprT -> expr:ExprT -> ExprT

assumes the specified Jacobian when calculating derivatives

assumeZeroDerivative expr
Signature: expr:ExprT -> ExprT

nullifies the Jacobian when calculating derivatives

boxOption oo
Signature: oo:'?177823 option -> obj option
Type parameters: '?177823

boxes the contents of an option

broadcast ss a
Signature: ss:ShapeSpecT -> a:ExprT -> ExprT

broadcast of SizeBroadcast dimensions

broadcastIfNecessary ss expr
Signature: ss:ShapeSpecT -> expr:ExprT -> ExprT

Wraps the given op in a Broadcast op if its shape does not match ss.

broadcastToSame a b
Signature: a:ExprT -> b:ExprT -> ExprT * ExprT

pads and broadcasts a and b to same shape if possible

broadcastToSameMany es
Signature: es:ExprT list -> ExprT list

pads and broadcasts all arguments to same shape if possible

broadcastToShape shp a
Signature: shp:ShapeSpecT -> a:ExprT -> ExprT

pads from the left and broadcasts the argument to the given shape if possible

cage (minVal, maxVal) a
Signature: (minVal:'?178102 option * maxVal:'?178103 option) -> a:ExprT -> ExprT
Type parameters: '?178102, '?178103

Ensures that all elements are between Some minVal and Some maxVal.

canEvalAllSymSizes expr
Signature: expr:ExprT -> bool

true if all shapes in the expression can be evaluated to numeric shapes

check expr
Signature: expr:ExprT -> ExprT

Traverses the expression and checks ops' arguments for compatible shapes.

checkAxis ax expr
Signature: ax:int -> expr:ExprT -> unit

checks that given axis is valid for specified expression

checkedExprs
Signature: HashSet<ExprT>

expressions that were already checked for correctness

checkExpr expr
Signature: expr:ExprT -> unit

Checks ops' arguments for compatible shapes.

checkFinite name a
Signature: name:string -> a:ExprT -> ExprT

checks the value for NaNs and infinities, outputs their location and stops the computation

concat dim es
Signature: dim:int -> es:seq<ExprT> -> ExprT

concatenates the sequence of tensors in the specified dimension

constructElementwise op a b
Signature: op:BinaryOpT -> a:ExprT -> b:ExprT -> ExprT

emits an elementwise binary operation with broadcasting of the inputs if necessary

contains subExpr expr
Signature: subExpr:ExprT -> expr:ExprT -> bool

returns true if subExpr is contained in expr

countOps expr
Signature: expr:ExprT -> int

counts operators, including repeating subexpressions

countUniqueOps expr
Signature: expr:ExprT -> int

counts operators, not counting repeating subexpressions

diag a
Signature: a:ExprT -> ExprT

Extracts the diagonal of a matrix. If the expression has more than two dimensions, the diagonals are extracted along the last two dimensions.

diagAxis ax1 ax2 a
Signature: ax1:int -> ax2:int -> a:ExprT -> ExprT

Extracts the diagonal along the given axes.

diagMat a
Signature: a:ExprT -> ExprT

Creates a matrix with the given vector on its diagonal. All other elements are zeros. If the input has more than one dimension, the operation is performed batch-wise on the last dimension.

diagMatAxis ax1 ax2 a
Signature: ax1:int -> ax2:int -> a:ExprT -> ExprT

Creates a diagonal matrix by duplicating the given dimension.

disableBroadcast dim a
Signature: dim:int -> a:ExprT -> ExprT

disables broadcasting in the given dimension

discard es
Signature: es:ExprT list -> ExprT

computes specified expressions, but discards the result

dot a b
Signature: a:ExprT -> b:ExprT -> ExprT

Dot product. Behavior depends on the dimensionality of the arguments. Cases: (1, 1) -> vector-vector dot product resulting in a scalar (2, 1) -> matrix-vector dot product resulting in a vector (2, 2) -> matrix-matrix dot product resulting in a matrix (n, n) with n>2 -> batched matrix-matrix dot product resulting in a matrix (n+1, n) with n>2 -> batched matrix-vector dot product resulting in a vector.

dump name a
Signature: name:string -> a:ExprT -> ExprT

dumps the result into the active dump session HDF5 file

elements trgtShp elemExpr args
Signature: trgtShp:ShapeSpecT -> elemExpr:ElemExprT -> args:ExprT list -> ExprT

calculates a tensor elementwise using the given element expression and result shape

enableBroadcast dim a
Signature: dim:int -> a:ExprT -> ExprT

enables broadcasting in the given dimension, it must be of size one

extractVar expr
Signature: expr:ExprT -> VarSpecT

extract VarSpec from variable expression

extractVars expr
Signature: expr:ExprT -> Set<VarSpecT>

extract all variables from an expression

failOnNotEvalableSymSize expr
Signature: expr:ExprT -> unit

fails if the expression contains a shape that cannot be evaluated to a numeric shape

failshape op sa sb
Signature: op:'?177979 -> sa:'?177980 -> sb:'?177981 -> '?177982
Type parameters: '?177979, '?177980, '?177981, '?177982

Produces an error message about incompatible shapes.

filled shp value
Signature: shp:ShapeSpecT -> value:'?178132 -> ExprT
Type parameters: '?178132

tensor of given shape filled with specified value

gather indices a
Signature: indices:ExprT option list -> a:ExprT -> ExprT

select elements according to the specified index arrays

identity size
Signature: size:SizeSpecT -> ExprT
Type parameters: 'T

identity matrix of given size

identityOfSameType expr size
Signature: expr:ExprT -> size:SizeSpecT -> ExprT

identity matrix of given size and same type as given expression

ifThenElse cond ifTrue ifFalse
Signature: cond:ExprT -> ifTrue:ExprT -> ifFalse:ExprT -> ExprT

elementwise uses elements from ifTrue if cond is true, otherwise elements from ifFalse

insertBroadcastAxis dim a
Signature: dim:int -> a:ExprT -> ExprT

inserts a broadcast axis at the given dimension

interpolate interpolator e
Signature: interpolator:InterpolatorT -> e:ExprT list -> ExprT

Element-wise n-dimensional interpolation using the specified interpolator. The interpolator is created using the Interpolator.create function.

interpolate1D interpolator a
Signature: interpolator:InterpolatorT -> a:ExprT -> ExprT

Element-wise one-dimensional interpolation using the specified interpolator. The interpolator is created using the Interpolator.create function.

interpolate2D interpolator a b
Signature: interpolator:InterpolatorT -> a:ExprT -> b:ExprT -> ExprT

Element-wise two-dimensional interpolation using the specified interpolator. The interpolator is created using the Interpolator.create function.

interpolate3D interpolator a b c
Signature: interpolator:InterpolatorT -> a:ExprT -> b:ExprT -> c:ExprT -> ExprT

Element-wise three-dimensional interpolation using the specified interpolator. The interpolator is created using the Interpolator.create function.

invert a
Signature: a:ExprT -> ExprT

Computes the inverse of a matrix. If the input has more than two dimensions, the inverses along the last two dimensions are returned. The inverse of a singular matrix is undefinied. No error is raised in that case.

isZero expr
Signature: expr:ExprT -> bool

True if expression is zero. False does not indicate that expression is non-zero.

loop spec channel args
Signature: spec:LoopSpecT -> channel:ChannelT -> args:ExprT list -> ExprT

A loop provides iterative evaluation of one or multiple expresisons.

loopNoLift spec channel args
Signature: spec:LoopSpecT -> channel:ChannelT -> args:ExprT list -> ExprT

A loop provides iterative evaluation of one or multiple expresisons. All variables occurs in the loop channel expressions must be defined as loop variables. The function loop performs automatic lifting of constants and thus allows for easy usage of variables external to the loop.

makeVar vs
Signature: vs:VarSpecT -> ExprT

make variable expression from VarSpec

mapOperands (...)
Signature: unaryMapping:(UnaryOpT -> ExprT -> ExprT) -> binaryMapping:(BinaryOpT -> ExprT -> ExprT -> ExprT * ExprT) -> naryMapping:(NaryOpT -> ExprT list -> ExprT list) -> expr:ExprT -> ExprT

Traverses the op tree and for each op calls a function on its arguments and replaces them by the function's return value(s).

maxAxis ax a
Signature: ax:int -> a:ExprT -> ExprT

maximum over given dimension

maxElemwise a b
Signature: a:ExprT -> b:ExprT -> ExprT

elementwise maximum

maxKeepingAxis ax a
Signature: ax:int -> a:ExprT -> ExprT

maximum over given dimension, while keeping the axis with one (broadcastable) element

mean a
Signature: a:ExprT -> ExprT

mean over all elements

meanAxis ax a
Signature: ax:int -> a:ExprT -> ExprT

mean over given dimension

meanKeepingAxis ax a
Signature: ax:int -> a:ExprT -> ExprT

mean over given dimension, while keeping the axis with one (broadcastable) element

minAxis ax a
Signature: ax:int -> a:ExprT -> ExprT

maximum over given dimension

minElemwise a b
Signature: a:ExprT -> b:ExprT -> ExprT

elementwise minimum

minKeepingAxis ax a
Signature: ax:int -> a:ExprT -> ExprT

maximum over given dimension, while keeping the axis with one (broadcastable) element

nDims expr
Signature: expr:ExprT -> int

number of dimensions of given expression

nElems expr
Signature: expr:ExprT -> SizeSpecT

number of elements of given expression

oneOfSameType expr
Signature: expr:ExprT -> ExprT

scalar 1 of the same type as given expression

padLeft a
Signature: a:ExprT -> ExprT

adds one broadcastable dimension to the left

padRight a
Signature: a:ExprT -> ExprT

adds one broadcastable dimension to the right

permuteAxes perm a
Signature: perm:int list -> a:ExprT -> ExprT

Permutes the axes as specified. Each entry in the specified permutation specifies the new position of the corresponding axis, i.e. to which position the axis should move.

print msg a
Signature: msg:string -> a:ExprT -> ExprT

print the result with the given message when evaluated

product a
Signature: a:ExprT -> ExprT

product of all elements

productAxis ax a
Signature: ax:int -> a:ExprT -> ExprT

product over given dimension

productKeepingAxis ax a
Signature: ax:int -> a:ExprT -> ExprT

product over given dimension, while keeping the axis with one (broadcastable) element

replicate dim reps a
Signature: dim:int -> reps:SizeSpecT -> a:ExprT -> ExprT

Replicates the tensor the given number of repetitions along the given axis.

replicateTo dim size a
Signature: dim:int -> size:SizeSpecT -> a:ExprT -> ExprT

Replicates the tensor along the given axis, so that after replication it has the specified size. If size is not a multiple of the current size of the tensor along the specified axis, the last replication is truncated appropriately.

reshape ss a
Signature: ss:ShapeSpecT -> a:ExprT -> ExprT

reshape (assuming C-continguous order) tensor; element count does not change

reshapeIfNecessary ss expr
Signature: ss:ShapeSpecT -> expr:ExprT -> ExprT

Wraps the given op in a Reshape op if its shape does not match ss.

reverseAxis dim a
Signature: dim:int -> a:ExprT -> ExprT

reverses the tensor in the given dimension

scalar f
Signature: f:'?178014 -> ExprT
Type parameters: '?178014

scalar constant of given value

scalarOfSameType expr f
Signature: expr:ExprT -> f:'a -> ExprT
Type parameters: 'a

scalar of given value converted to same type as given expression

scatter indices trgtShp a
Signature: indices:ExprT option list -> trgtShp:ShapeSpecT -> a:ExprT -> ExprT

select elements according to the specified index arrays

setSubtensor a b
Signature: a:ExprT -> b:ExprT -> ExprT

expression a with the specified subtensor replaced with b

shapeOf expr
Signature: expr:ExprT -> ShapeSpecT

Returns the shape of the given expression.

signt a
Signature: a:ExprT -> ExprT

sign keeping type

sizeValue size
Signature: size:SizeSpecT -> ExprT
Type parameters: 'T

scalar with value of given size converted to the given type

sizeValueOfSameType expr size
Signature: expr:ExprT -> size:SizeSpecT -> ExprT

scalar with value of given size converted to the same type as given expression

sqrtt a
Signature: a:ExprT -> ExprT

square root

storeToVar ve a
Signature: ve:ExprT -> a:ExprT -> ExprT

store to variable

subst replacements expr
Signature: replacements:Map<ExprT,ExprT> -> expr:ExprT -> ExprT

Replaces all occurences of the map key with its value in the specified expression. Does not replace subexpressions within loop channel value expressions.

substSymSizes symSizes expr
Signature: symSizes:Map<SizeSymbolT,SizeSpecT> -> expr:ExprT -> ExprT

substitues the given symbol sizes into the expression

sum a
Signature: a:ExprT -> ExprT

summaiton of all elements

sumAxis ax a
Signature: ax:int -> a:ExprT -> ExprT

summation over given dimension

sumKeepingAxis ax a
Signature: ax:int -> a:ExprT -> ExprT

summation over given dimension, while keeping the axis with one (broadcastable) element

swapDim ax1 ax2 a
Signature: ax1:int -> ax2:int -> a:ExprT -> ExprT

swaps two dimensions of a tensor

tensorProduct a b
Signature: a:ExprT -> b:ExprT -> ExprT

tensor product

trace a
Signature: a:ExprT -> ExprT

Computes the trace of a matrix. If the input has more than two dimensions, the traces along the last two dimensions are returned.

traceAxis ax1 ax2 a
Signature: ax1:int -> ax2:int -> a:ExprT -> ExprT

Computes the traces along the given axes.

transpose a
Signature: a:ExprT -> ExprT

Transpose matrix. If the input has more than two dimensions, the last two axes are transposed.

twoOfSameType expr
Signature: expr:ExprT -> ExprT

scalar 2 of the same type as given expression

typename expr
Signature: expr:ExprT -> TypeNameT

Returns the type of the given expression.

var name ss
Signature: name:string -> ss:ShapeSpecT -> ExprT
Type parameters: 'T

variable of given name and shape

varOfType name typ ss
Signature: name:string -> typ:Type -> ss:ShapeSpecT -> ExprT

variable of given name, type and shape

zeroOfSameType expr
Signature: expr:ExprT -> ExprT

scalar 0 of the same type as given expression

zeros shp
Signature: shp:ShapeSpecT -> ExprT
Type parameters: 'T

zero tensor of given shape

zerosLike expr
Signature: expr:ExprT -> ExprT

zero tensor with same shape and type as given tensor

zerosOfSameType expr shp
Signature: expr:ExprT -> shp:ShapeSpecT -> ExprT

zero tensor of given shape and same type as given expression

zerosOfType typ shp
Signature: typ:Type -> shp:ShapeSpecT -> ExprT

zero tensor of given type and shape

Active patterns

Active patternDescription
( |BinaryElemwiseOp|_| ) bop
Signature: bop:BinaryOpT -> unit option

matches all binary ops that work elementwise

CompiledName: |BinaryElemwiseOp|_|

( |UnaryElemwiseOp|_| ) uop
Signature: uop:UnaryOpT -> unit option

matches all unary ops that work elementwise

CompiledName: |UnaryElemwiseOp|_|

( |ZeroExpr|_| ) expr
Signature: expr:ExprT -> unit option

Matches expressions with value zero.

CompiledName: |ZeroExpr|_|

Fork me on GitHub