flare.core

-InternalPTensorFactory

protocol

protocols for internal understanding of performance/correctness, not meant to be used except by ‘experts’

members

debug-info

(debug-info this)

map of debug/perf info

cache

(cache factory num-to-cache)

from

(from factory data)(from data)

coerce data into a tensor, should work with nested clojure seqs of numbers

guess-shape

(guess-shape nums)

init!

(init!)(init! num-to-cache)

Defaults the state of flare with following * eager? is true, so all graph ops eagerly compute forward * factory is neanderthal (only good tensor impl) * a cache with num-to-cache (defaults to 1,000)

PTensorFactory

protocol

A PTensorFactory knows how to make and manipulate tensors. The tensor type depends on the PTensorFactory, but there are some conventions tensors should have:

* Tensors should be seqable (might revisit this)
* Tensors are mutable objects (duh, performance)

For external API use, use the zeros and from wrappers below which can default the tensor factory

members

-from

(-from this data)

create a tensor from data (satisfies Tensor). Should minimally accept (nested) sequences of numbers, but can also effectively copy an existing tensor

-zeros

(-zeros this shape)

create a 0.0 filled tensor of a given shape

get-op

(get-op this op-key)

returns the TensorOp associated with the op-key

scalar-shape?

(scalar-shape? shape)

set!

(set! init-state)

state

(state)

Tensor

protocol

members

add

(add this other)(add this scale other)

return new tensor which adds this to other and possibly scales other by scalar scale

add!

(add! this other)(add! this scale other)

mutable version of add that updates this

copy!

(copy! this src-tensor-like)

copy from source to this tensor. The src should be same set of things accdepted by PTensorFactory/from

div

(div this denom)(div this denom-offset denom)(div this numer-offset other denom-offset)

return new tensor element-wise divide by denom possibly with offsets for numerator or denominator offset result = (this + numer-offset) / (other + denom-offset)

div!

(div! this denom)(div! this denom-offset denom)(div! this numer-offset other denom-offset)

mutable version of div

factory

(factory this)

returns PTensorFactory underlying this tensor

mult

(mult this other)

return new pointwise multiplication tensor

mult!

(mult! this other)

pointwise in-place multiplication

pow

(pow this exp)

element-wise exponeniate

pow!

(pow! this exp)

in-place element-wise exponetiationate

scale

(scale this alpha)

return sclaed tensor

scale!

(scale! this alpha)

mutate scale

select!

(select! this path)

live-link to sub-tensor @ path. The path length should be less than number of dimensions. The returned object should be linked to the parent and changes should be reflected.

shape

(shape this)

return the shape of the tennsor as integer (clojure) vector

transform

(transform this get-val)(transform this other-tensor get-val)

Create a new tensor using the get-val function, which can be a few different things

[this get-val] ============================== * A fixed double to fill tensor * A IFn$ODD primitive function taking (dims, existing) which returns new value for the position

[this other-tensor get-val] ================================ Assumes other-tensor shape matches tensor * IFn$DDD takes (cur-val, other-val) and returns new value * IFn$ODDD takes (position, cur-val, other-val) and position is the long-array of the location

transform!

(transform! this get-val)(transform! this other-tensor get-val)

mutable version of transform! that updates this

validate-shape!

(validate-shape! expected-shape given-shape)(validate-shape! key expected-shape given-shape)

vector-shape?

(vector-shape? shape)

zeros

(zeros shape)(zeros factory shape & {:keys [no-cache?]})

create a zero tensor with given shape using default tensor factory. Unless :no-cache? is passed in will use cache if avaialble