Liking cljdoc? Tell your friends :D

tvm-clj.api

Higher level API to build and compile tvm functions.

Higher level API to build and compile tvm functions.
raw docstring

*varname-prefix*clj


->call-typeclj

(->call-type ctype)

->operationclj

(->operation tens-or-op)

->stageclj

(->stage stage-or-schedule operation)

absclj

(abs lhs)

addclj

(add lhs rhs)

bind-argumentsclj

(bind-arguments arg-list bind-map build-config)

Given an arg-list and existing bind map, produce a new arg list and bind map with all arguments bound to input buffers with defined buffer layout. Bind map is a map of type NodeHandle->NodeHandle where the keys are tensors and the values are buffers. The default is to bind a compact, non-offset buffer so if you want a different buffer type than this then you need to bind it yourself.

Given an arg-list and existing bind map, produce a new arg list
and bind map with all arguments bound to input buffers with defined buffer layout.
Bind map is a map of type NodeHandle->NodeHandle where the keys are tensors and the
values are buffers.  The default is to bind a compact, non-offset buffer so if you want
a different buffer type than this then you need to bind it yourself.
raw docstring

callclj

(call ret-dtype fn-name fn-args call-type function-ref value-index)

Call a 'function', which is basically executing a statement. For instance, getting a value from the tensor is calling a halide function with the tensor's generating-op and value index.

Call a 'function', which is basically executing a statement.  For instance, getting a
value from the tensor is calling a halide function with the tensor's generating-op and
value index.
raw docstring

call-intrinclj

(call-intrin dtype func-name & args)

Build expression by calling an intrinsic function.

Intrinsics can be overloaded with multiple data types via the intrinsic translation rule.

Parameters

dtype : str The data type of the result.

func_name: str The intrinsic function name.

args : list Positional arguments.

Returns

call : Expr The call expression.

Build expression by calling an intrinsic function.

Intrinsics can be overloaded with multiple data types via
the intrinsic translation rule.

Parameters
----------
dtype : str
    The data type of the result.

func_name: str
    The intrinsic function name.

args : list
    Positional arguments.

Returns
-------
call : Expr
    The call expression.
raw docstring

call-pure-intrinclj

(call-pure-intrin dtype func-name & args)

Build expression by calling a pure intrinsic function.

Intrinsics can be overloaded with multiple data types via the intrinsic translation rule.

Parameters

dtype : str The data type of the result.

func_name: str The intrinsic function name.

args : list Positional arguments.

Returns

call : Expr The call expression.

Build expression by calling a pure intrinsic function.

Intrinsics can be overloaded with multiple data types via
the intrinsic translation rule.

Parameters
----------
dtype : str
    The data type of the result.

func_name: str
    The intrinsic function name.

args : list
    Positional arguments.

Returns
-------
call : Expr
    The call expression.
raw docstring

call-type-setclj


call-typesclj

Possible call types from Halide/IR.h

Possible call types from Halide/IR.h
raw docstring

castclj

(cast expr-node dtype)

See static cast redone to allow usage in ->

See static cast redone to allow usage in ->
raw docstring

ceilclj

(ceil lhs)

commutative-reduceclj

(commutative-reduce reduce-op identity-val dtype expr-seq axis-seq)

1 left hand side, first var of reduce operation N right hand sides, rest of the variables of the reduce operation identity-val - initialization of left hand side.n expr-ary - one for each (const) right hand side. dtype - datatype of all inputs to reduction

1 left hand side, first var of reduce operation
N right hand sides, rest of the variables of the reduce operation
identity-val - initialization of left hand side.n
expr-ary - one for each (const) right hand side.
dtype - datatype of all inputs to reduction
raw docstring

computeclj

(compute shape fcompute name & {:keys [tag attrs] :or {tag ""}})

Construct a new tensor by computing over the shape domain.

The compute rule is result[axis] = fcompute(axis)

Parameters

shape: Array of Expr The shape of the tensor

fcompute: lambda function of indices-> value Specifies the input source expression

name: str, optional The name hint of the tensor

tag: str, optional Additonal tag information about the compute.

attrs: dict, optional The additional auxiliary attributes about the compute.

Returns

The created compute node

Construct a new tensor by computing over the shape domain.

The compute rule is result[axis] = fcompute(axis)

Parameters
----------
shape: Array of Expr
    The shape of the tensor

fcompute: lambda function of indices-> value
    Specifies the input source expression

name: str, optional
    The name hint of the tensor

tag: str, optional
    Additonal tag information about the compute.

attrs: dict, optional
    The additional auxiliary attributes about the compute.

Returns
-------
The created compute node
raw docstring

constclj

(const numeric-value & [dtype])

Convert an item to a const (immediate) value

Convert an item to a const (immediate) value
raw docstring

create-scheduleclj

(create-schedule op-seq)

declare-bufferclj

(declare-buffer
  shape
  &
  {:keys [dtype name data strides elem-offset scope data-alignment]
   :or {name "buffer" dtype "float32" scope "" data-alignment -1}})

Decleare a new symbolic buffer.

Normally buffer is created automatically during lower and build. This is only needed if user want to specify their own buffer layout.

See the note below for detailed discussion on usage of buffer.

Parameters

shape : tuple of Expr The shape of the buffer.

dtype : str, optional The data type of the buffer.

name : str, optional The name of the buffer.

data : Var, optional The data pointer in the buffer.

strides: array of Expr The stride of the buffer.

elem_offset: Expr, optional The beginning offset of the array to data. In terms of number of elements of dtype.

scope: str, optional The storage scope of the buffer, if not global. If scope equals empty string, it means it is global memory.

data_alignment: int, optional The alignment of data pointer in bytes. If -1 is passed, the alignment will be set to TVM's internal default.

--CN - REMOVED - No one understands what this does. It is only referenced in the code in order to perform a check during argument binding. So the description below is accurate for what it is worth but it is hard to me to see how this is useful.

offset_factor: int, optional The factor of elem_offset field, when set, elem_offset is required to be multiple of offset_factor. If 0 is pssed, the alignment will be set to 1. if non-zero is passed, we will created a Var for elem_offset if elem_offset is not None.

--CN - END-REMOVED --

Returns

buffer : Buffer The created buffer

Note

Buffer data structure reflects the DLTensor structure in dlpack. While DLTensor data structure is very general, it is usually helpful to create function that only handles specific case of data structure and make compiled function benefit from it.

If user pass strides and elem_offset is passed as None when constructing the function, then the function will be specialized for the DLTensor that is compact and aligned. If user pass a fully generic symbolic array to the strides, then the resulting function becomes fully generic.

Decleare a new symbolic buffer.

  Normally buffer is created automatically during lower and build.
  This is only needed if user want to specify their own buffer layout.

  See the note below for detailed discussion on usage of buffer.

  Parameters
  ----------
  shape : tuple of Expr
      The shape of the buffer.

  dtype : str, optional
      The data type of the buffer.

  name : str, optional
      The name of the buffer.

  data : Var, optional
      The data pointer in the buffer.

  strides: array of Expr
      The stride of the buffer.

  elem_offset: Expr, optional
      The beginning offset of the array to data.
      In terms of number of elements of dtype.

  scope: str, optional
      The storage scope of the buffer, if not global.
      If scope equals empty string, it means it is global memory.

  data_alignment: int, optional
      The alignment of data pointer in bytes.
      If -1 is passed, the alignment will be set to TVM's internal default.

  --CN - REMOVED - No one understands what this does.  It is only referenced in the
code in order to perform a check during argument binding.  So the description below is
accurate for what it is worth but it is hard to me to see how this is useful.


  offset_factor: int, optional
      The factor of elem_offset field, when set,
      elem_offset is required to be multiple of offset_factor.
      If 0 is pssed, the alignment will be set to 1.
      if non-zero is passed, we will created a Var for elem_offset if elem_offset is
not None.

   --CN - END-REMOVED --

  Returns
  -------
  buffer : Buffer
      The created buffer

  Note
  ----
  Buffer data structure reflects the DLTensor structure in dlpack.
  While DLTensor data structure is very general, it is usually helpful
  to create function that only handles specific case of data structure
  and make compiled function benefit from it.

  If user pass strides and elem_offset is passed as None
  when constructing the function, then the function will be specialized
  for the DLTensor that is compact and aligned.
  If user pass a fully generic symbolic array to the strides,
  then the resulting function becomes fully generic.
raw docstring

def-bin-intrin-opcljmacro

(def-bin-intrin-op op-name)

def-bin-opcljmacro

(def-bin-op op-name make-name)

Define a binary operation

Define a binary operation
raw docstring

def-intrin-opcljmacro

(def-intrin-op op-name)

def-opcljmacro

(def-op op-name make-name)

Define a binary operation

Define a binary operation
raw docstring

default-build-configclj

Comments from tvm/build_module.h

Comments from tvm/build_module.h
raw docstring

divclj

(div lhs rhs)

eqclj

(eq lhs rhs)

expclj

(exp lhs)

floorclj

(floor lhs)

input-tensorsclj

(input-tensors compute-op)

int->lowered-function-type-mapclj


iteration-variableclj

(iteration-variable domain
                    name
                    iteration-type
                    &
                    {:keys [thread-tag] :or {thread-tag ""}})

Create a variable that controls iteration through the data. The iteration type affects the class of optimizations that the compiler is able to apply to the affected expressions,

Parameters
----------
dom : Range
    The domain of iteration.

name : str
    The name of iteration variable.

iteration-type : keyword
    The type of iteration.

thread-tag : str
    The thread tag of the iteration variable.
Create a variable that controls iteration through the data.  The iteration type
affects the class of optimizations that the compiler is able to apply to the affected
expressions,

    Parameters
    ----------
    dom : Range
        The domain of iteration.

    name : str
        The name of iteration variable.

    iteration-type : keyword
        The type of iteration.

    thread-tag : str
        The thread tag of the iteration variable.
raw docstring

iteration-variable-type-setclj


iteration-variable-typesclj

Iteration variable types defined in tvm/include/Expr.h

Iteration variable types defined in tvm/include/Expr.h
raw docstring

logclj

(log lhs)

lowered-function-type->int-mapclj


lowered-functions->moduleclj

(lowered-functions->module
  lowered-function-seq
  &
  {:keys [build-config target-name target-host]
   :or {target-name :llvm target-host :llvm build-config default-build-config}})

maxclj

(max lhs rhs)

minclj

(min lhs rhs)

modclj

(mod lhs rhs)

mulclj

(mul lhs rhs)

name->thread-axis-iteratorclj

(name->thread-axis-iterator axis-name)

Create a thread iter-var from a thread axis name

Create a thread iter-var from a thread axis name
raw docstring

node->strclj

(node->str node)

output-tensorsclj

(output-tensors compute-op)

placeholderclj

(placeholder shape name & {:keys [dtype] :or {dtype "float32"}})

Create a user-supplied tensor variable

Create a user-supplied tensor variable
raw docstring

popcountclj

(popcount lhs)

powerclj

(power lhs rhs)

rangeclj

(range start end)

Create a range with defined start inclusive and end exclusive

Create a range with defined start inclusive and end exclusive
raw docstring

roundclj

(round lhs)

safe-strclj

(safe-str str-name)

schedule->lowered-functionclj

(schedule->lowered-function schedule
                            args
                            name
                            &
                            {:keys [build-config bind-map simple-mode?]
                             :or {bind-map {}
                                  build-config default-build-config}})

Lowering step before build into target.

Parameters

schedule : tvm.Schedule The schedule to be builded

args : list of Buffer or Tensor or Var The argument lists to the function.

name : str, optional The name of result function.

bind-map: map of {:tensor :buffer}, optional mapping fuction or hash-map that maps the Tensor to Buffer which specified the data layout requirement of the function. By default, a new compact buffer is created for each tensor in the argument list.

simple-mode? : bool, optional (not currently implemented) Whether only output simple and compact statement, this will skip LoopPartition, api wrapper generation and Unrolling.

Returns

f : LoweredFunc or Stmt The result function, if with_api_wrapper=False Then the Stmt before make api is returned.

Lowering step before build into target.

  Parameters
  ----------
  schedule : tvm.Schedule
      The schedule to be builded

  args : list of Buffer or Tensor or Var
      The argument lists to the function.

  name : str, optional
      The name of result function.

  bind-map: map of {:tensor :buffer}, optional
      mapping fuction or hash-map that maps the Tensor to Buffer which specified the
data layout
      requirement of the function. By default, a new compact buffer is created
      for each tensor in the argument list.

  simple-mode? : bool, optional (not currently implemented)
      Whether only output simple and compact statement, this will skip
      LoopPartition, api wrapper generation and Unrolling.

  Returns
  -------
  f : LoweredFunc or Stmt
     The result function, if with_api_wrapper=False
     Then the Stmt before make api is returned.
  
raw docstring

schedule->strclj

(schedule->str schedule arg-list fn-name)

schedule-cache-readclj

(schedule-cache-read schedule tensor cache-type readers)

schedule-cache-writeclj

(schedule-cache-write schedule tensor cache-type)

Returns a new tensor

Returns a new tensor
raw docstring

schedules->fnsclj

(schedules->fns
  sched-data-seq
  &
  {:keys [build-config target-name target-host]
   :or {build-config default-build-config target-name :llvm target-host :llvm}})

Given a sequence of schedule-data, return a map of name to clojure callable function. A module is created and added to the resource context transparently. Schedule data: {:name :fn-name :arglist arguments :schedule schedule :bind-map (optional) bind-map } returns: {:module module :fn-map map of name->IFn (clojure callable function.)

Given a sequence of schedule-data, return a map of name to clojure
callable function.
A module is created and added to the resource context transparently.
Schedule data:
{:name :fn-name
 :arglist arguments
 :schedule schedule
 :bind-map (optional) bind-map
}
returns:
{:module module
 :fn-map map of name->IFn (clojure callable function.)
raw docstring

selectclj

(select bool-stmt true-stmt false-stmt)

Select between two expressions based on a condition. Thus works similar to the clojure 'if' statement.

Select between two expressions based on a condition.  Thus works similar to the
clojure 'if' statement.
raw docstring

sigmoidclj

(sigmoid lhs)

sqrtclj

(sqrt lhs)

stage-bindclj

(stage-bind stage iter-var thread-ivar)

Bind an iter-var to a stage variable

Bind an iter-var to a stage variable
raw docstring

stage-bind-gpuclj

(stage-bind-gpu stage block-axis-seq thread-axis-seq)

Bind the gpu-defined axis to the tvm axis. GPU (cuda, opencl) define a roughly level stage breakdown of axis: block and thread. Threads run on the same block and can share a special kind of memory (called shared memory). There can be up to 3 tvm axis per block or thread and these are labeled (outer iterator to inner iterator): [z y x]

Bind the gpu-defined axis to the tvm axis.
GPU (cuda, opencl) define a roughly level stage breakdown of axis: block and thread.
Threads run on the same block and can share a special kind of memory (called shared
memory).  There can be up to 3 tvm axis per block or thread and these are labeled
(outer iterator to inner iterator):
[z y x]
raw docstring

stage-compute-atclj

(stage-compute-at src-stage dst-stage dst-axis)

Compute src stage at dst stage dst axis

Compute src stage at dst stage dst axis
raw docstring

stage-cpu-injectiveclj

(stage-cpu-injective stage op & {:keys [axis]})

stage-fuseclj

(stage-fuse stage axis-args)

Fuse n-axis together, returns single new axis

Fuse n-axis together, returns single new axis
raw docstring

stage-gpu-injectiveclj

(stage-gpu-injective stage
                     op
                     &
                     {:keys [thread-count axis] :or {thread-count 16}})

stage-inlineclj

(stage-inline stage)

stage-parallelclj

(stage-parallel stage axis)

Indicate that this axis has complete parallelism

Indicate that this axis has complete parallelism
raw docstring

stage-reorderclj

(stage-reorder stage axis-seq)

stage-split-axisclj

(stage-split-axis stage iter-var factor)

stage-tileclj

(stage-tile stage outer-axis inner-axis outer-dim inner-dim)

stage-unrollclj

(stage-unroll stage axis)

stage-vectorizeclj

(stage-vectorize stage axis)

static-castclj

(static-cast dtype expr-node)

Cast an item from one datatype to another

Cast an item from one datatype to another
raw docstring

subclj

(sub lhs rhs)

tanhclj

(tanh lhs)

target-infoclj

(target-info target-name)

target-name->propsclj


target-name->thread-warp-sizeclj

(target-name->thread-warp-size target-name)

tgetclj

(tget tensor indices)

Get an item from a tensor

Get an item from a tensor
raw docstring

throw-nilclj

(throw-nil item key-val)

truncclj

(trunc lhs)

tvm-fncljmacro

(tvm-fn arg-vec & body)

Like (fn) but retains the arglists. Lambda in clojure unfortunately does not.

Like (fn) but retains the arglists.  Lambda in clojure unfortunately does not.
raw docstring

tvm-letcljmacro

(tvm-let expr-pairs body)

Lets in tvm must be nested. This leads to an exciting macro. Pairs must be of the form var val-expr. Body is not an implicit do!!

Lets in tvm must be nested.  This leads to an exciting macro.
Pairs must be of the form var val-expr.  Body is *not* an implicit
do!!
raw docstring

variableclj

(variable name & {:keys [dtype] :or {dtype "int32"}})

Create a scalar variable. Returns a node handle

Create a scalar variable.  Returns a node handle
raw docstring

when-not-errorcljmacro

(when-not-error condition throw-clause)

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

× close