Liking cljdoc? Tell your friends :D

tech.compute.tensor.dimensions

Compute tensors dimensions control the shape and stride of the tensor along with offsetting into the actual data buffer. This allows multiple backends to share a single implementation of a system that will allow transpose, reshape, etc. assuming the backend correctly interprets the shape and stride of the dimension objects.

Shape vectors may have an index buffer in them at a specific dimension instead of a number. This means that that dimension should be indexed indirectly. If a shape has any index buffers then it is considered an indirect shape.

Compute tensors dimensions control the shape and stride of the tensor along with
offsetting into the actual data buffer.  This allows multiple backends to share a
single implementation of a system that will allow transpose, reshape, etc. assuming
the backend correctly interprets the shape and stride of the dimension objects.

Shape vectors may have an index buffer in them at a specific dimension instead of a
number.  This means that that dimension should be indexed indirectly.  If a shape has
any index buffers then it is considered an indirect shape.
raw docstring

->2d-shapeclj

(->2d-shape {:keys [shape]})

Given dimensions, return new dimensions with the lowest (fastest-changing) dimension unchanged and the rest of the dimensions multiplied into the higher dimension.

Given dimensions, return new dimensions with the lowest (fastest-changing) dimension
unchanged and the rest of the dimensions multiplied into the higher dimension.
sourceraw docstring

->batch-shapeclj

(->batch-shape {:keys [shape]})

Given dimensions, return new dimensions with the lowest (fastest-changing) dimension unchanged and the rest of the dimensions multiplied into the higher dimension.

Given dimensions, return new dimensions with the lowest (fastest-changing) dimension
unchanged and the rest of the dimensions multiplied into the higher dimension.
sourceraw docstring

->least-rapidly-changing-dimensionclj

(->least-rapidly-changing-dimension {:keys [shape]})

Get the size of the least rapidly changing dimension

Get the size of the least rapidly changing dimension
sourceraw docstring

->most-rapidly-changing-dimensionclj

(->most-rapidly-changing-dimension {:keys [shape]})

Get the size of the most rapidly changing dimension

Get the size of the most rapidly changing dimension
sourceraw docstring

->reverse-dataclj

(->reverse-data {:keys [shape strides]} max-shape)

Lots of algorithms (elem-idx->addr) require the shape and strides to be reversed for the most efficient implementation.

Lots of algorithms (elem-idx->addr) require the shape and strides
to be reversed for the most efficient implementation.
sourceraw docstring

access-increasing?clj

(access-increasing? {:keys [shape strides] :as dims})

Are these dimensions setup such a naive seq through the data will be accessing memory in order. This is necessary for external library interfaces (blas, cudnn). An example would be after any nontrivial transpose that is not made concrete (copied) this condition will not hold.

Are these dimensions setup such a naive seq through the data will be accessing memory
in order.  This is necessary for external library interfaces (blas, cudnn).  An
example would be after any nontrivial transpose that is not made concrete (copied)
this condition will not hold.
sourceraw docstring

dense?clj

(dense? {:keys [shape strides]})
source

dimension-seq->max-shapeclj

(dimension-seq->max-shape & args)

Given a sequence of dimensions return a map of: {:max-shape - the maximum dim across shapes for all dims :dimensions - new dimensions with their shape 1-extended to be equal lengths and their strides max-extended to be the same length as the new shape.

Given a sequence of dimensions return a map of:
{:max-shape - the maximum dim across shapes for all dims
 :dimensions -  new dimensions with their shape 1-extended to be equal lengths
     and their strides max-extended to be the same length as the new shape.
sourceraw docstring

dimensionsclj

(dimensions shape & {:keys [names strides]})

A dimension is a map with at least a shape (vector of integers or index buffers) and potentially another vector of dimension names. By convention the first member of the shape is the slowest changing and the last member of the shape is the most rapidly changing. There can also be optionally a companion vector of names which name each dimension. Names are used when doing things that are dimension aware such as a 2d convolution. Shape is the same as a core-matrix shape.

A dimension is a map with at least a shape (vector of integers or index buffers) and
potentially another vector of dimension names.  By convention the first member of the
shape is the slowest changing and the last member of the shape is the most rapidly
changing.  There can also be optionally a companion vector of names which name each
dimension.  Names are used when doing things that are dimension aware such as a 2d
convolution.  Shape is the same as a core-matrix shape.
sourceraw docstring

dimensions->column-strideclj

(dimensions->column-stride {:keys [shape strides]})
source

direct?clj

(direct? {:keys [shape]})
source

ecountclj

(ecount {:keys [shape]})

Return the element count indicated by the dimension map

Return the element count indicated by the dimension map
sourceraw docstring

elem-idx->addrclj

(elem-idx->addr rev-shape rev-strides rev-max-shape arg)

Given an arbitary logical element index, return the address of the element as calculated by waking through the shape from most rapidly changing to least rapidly changing and summing the shape index by the stride.

Precondition: rev-shape, rev-max-shape, strides are same length. rev-max-shape: maxes of all shapes passed in, reversed rev-shape: reverse shape. rev-strides: reverse strides. arg: >= 0.

Given an arbitary logical element index, return the address of the element as
calculated by waking through the shape from most rapidly changing to least rapidly
changing and summing the shape index by the stride.

Precondition:  rev-shape, rev-max-shape, strides are same length.
rev-max-shape: maxes of all shapes passed in, reversed
rev-shape: reverse shape.
rev-strides: reverse strides.
arg: >= 0.
sourceraw docstring

extend-stridesclj

(extend-strides shape strides)
source

in-place-reshapeclj

(in-place-reshape existing-dims shape)

Return new dimensions that correspond to an in-place reshape. This is a very difficult algorithm to get correct as it needs to take into account changing strides and dense vs non-dense dimensions.

Return new dimensions that correspond to an in-place reshape.  This is a very
difficult algorithm to get correct as it needs to take into account changing strides
and dense vs non-dense dimensions.
sourceraw docstring

indirect?clj

(indirect? dims)
source

left-pad-onesclj

(left-pad-ones shape-vec max-shape-vec)
source

matrix-column-strideclj

(matrix-column-stride {:keys [shape strides] :as dims})

Returns the larger of the 2 strides

Returns the larger of the 2 strides
sourceraw docstring

matrix-element-strideclj

(matrix-element-stride {:keys [shape strides] :as dims})
source

minimizeclj

(minimize dimensions)

Make the dimensions of smaller rank by doing some minimization - a. If the dimension is 1, strip it and associated stride. b. Combine densely-packed dimensions (not as simple).

Make the dimensions of smaller rank by doing some minimization -
a. If the dimension is 1, strip it and associated stride.
b. Combine densely-packed dimensions (not as simple).
sourceraw docstring

selectclj

(select dimensions & args)

Expanded implementation of the core.matrix select function call. Each dimension must have an entry and each entry may be: :all (identity) :lla (reverse) persistent-vector: [0 1 2 3 4 4 5] (not supported by all backends) map: {:type [:+ :-] :min-item 0 :max-item 50} Monotonically increasing/decreasing bounded (inclusive) sequences

tensor : int32, dense vector only. Not supported by all backends.

;;Some examples https://cloojure.github.io/doc/core.matrix/clojure.core.matrix.html#var-select

Expanded implementation of the core.matrix select function call.  Each dimension must
  have an entry and each entry may be:
:all (identity)
:lla (reverse)
persistent-vector: [0 1 2 3 4 4 5] (not supported by all backends)
map: {:type [:+ :-]
      :min-item 0
      :max-item 50}
  Monotonically increasing/decreasing bounded (inclusive) sequences

tensor : int32, dense vector only.  Not supported by all backends.

;;Some examples
https://cloojure.github.io/doc/core.matrix/clojure.core.matrix.html#var-select
sourceraw docstring

shapeclj

(shape {:keys [shape]})
source

stridesclj

(strides {:keys [strides]})
source

trans-2d-shapeclj

(trans-2d-shape trans-a? dims)
source

transposeclj

(transpose {:keys [shape strides]} reorder-vec)

Transpose the dimensions. Returns a new dimensions that will access memory in a transposed order. Dimension 0 is the leftmost (greatest) dimension:

(transpose tens (range (count (shape tens))))

is the identity operation.

Transpose the dimensions.  Returns a new dimensions that will access memory in a
transposed order.
Dimension 0 is the leftmost (greatest) dimension:

(transpose tens (range (count (shape tens))))

is the identity operation.
sourceraw docstring

cljdoc is a website building & hosting documentation for Clojure/Script libraries

× close