123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224# 1 "src/base/compute/owl_computation_symbol_sig.ml"(*
* OWL - OCaml Scientific Computing
* Copyright (c) 2016-2022 Liang Wang <liang@ocaml.xyz>
*)(* Functor of making the symbols of a computation graph. *)moduletypeSig=sigmoduleShape:Owl_computation_shape_sig.SigopenShapeopenTypeopenDevice(** {5 Core functions} *)valop_to_str:op->string(** return the name of the operator as string *)valis_random_variable:op->bool(** check if operator is randon variable *)valrefnum:'aOwl_graph.node->int(** return the reference number of the given node *)valnode_shape:attrOwl_graph.node->intarray(** return the shape of a node *)valnode_numel:attrOwl_graph.node->int(** return the number of elements of a node *)valis_shape_unknown:attrOwl_graph.node->bool(** check if the shape of the input node is unknown *)valinfer_shape_graph:attrOwl_graph.nodearray->unit(** automatically infer the shape of input node according to its descendents' shapes *)valshape_to_str:intarrayoptionarray->string(** helper function; return the input array in string format. *)valnode_to_str:attrOwl_graph.node->string(** print node's information to string *)valnode_to_arr:t->arr(** Wrap computation graph node in an array type *)valarr_to_node:arr->t(** Unwrap the array type to get the computation graph node within *)valnode_to_elt:t->elt(** Wrap computation graph node in an Elt type *)valelt_to_node:elt->t(** Unwrap the Elt type to get the computation graph node within *)valmake_node:?name:string->?value:valuearray->?shape:intarrayoptionarray->?freeze:bool->?reuse:bool->?state:state->op->attrOwl_graph.node(** crate a computation graph node *)valmake_then_connect:?shape:intarrayoptionarray->op->attrOwl_graph.nodearray->attrOwl_graph.node(** make nodes and then connect parents and children *)valvar_arr:?shape:intarray->string->arr(** creat a node and wrap in Arr type *)valvar_elt:string->elt(** creat a node and wrap in Elt type *)valconst_arr:string->A.arr->arr(** get ndarray value from input and create an node and wrap in Arr type *)valconst_elt:string->A.elt->elt(** get value from input and create an node and wrap in Elt type *)valnew_block_id:unit->int(** [new_block_id ()] returns an unused block id. *)valmake_empty_block:?block_id:int->int->block(** [make_empty_block s] returns an empty block of memory of size [s]. *)valmake_value_block:value->attrOwl_graph.node->unit(**
[make_value_block value node] creates a block of memory initialised with
[value] and links the new block to [node].
*)valget_block:attrOwl_graph.node->blockarray(**
[get_block node] returns the memory block allocated to [node].
If no block is allocated, throws an exception.
*)valadd_node_to_block:attrOwl_graph.node->block->unit(**
Link a node to a reusable block and initialises its memory on the memory of
the block.
*)valget_active_node:block->attrOwl_graph.nodeoption(** Return the node that is currently using the memory of the block. *)valset_active_node:block->attrOwl_graph.node->unit(** Update the node that is currently using the block of memory. *)valget_block_id:attrOwl_graph.node->int(**
[get_block_id node] returns the id of the block assigned to [node]. If
[node] has not been assigned yet, returns [-1].
*)valset_value:attrOwl_graph.node->valuearray->unit(** set the arrays of value to cgraph node *)valget_value:attrOwl_graph.node->valuearray(** get the arrays of value of cgraph node *)valset_operator:attrOwl_graph.node->op->unit(** set the operator of cgraph node *)valget_operator:attrOwl_graph.node->op(** get the operator of cgraph node *)valset_reuse:attrOwl_graph.node->bool->unit(** set reuse attribute in a node *)valget_reuse:attrOwl_graph.node->bool(** get reuse attribute in a node *)valis_shared:attrOwl_graph.node->bool(** check of the data block of memory is shared in a node *)valget_shared_nodes:attrOwl_graph.node->attrOwl_graph.nodearray(**
[get_shared_nodes node] returns the nodes sharing the same block of memory
as [node].
*)valis_var:attrOwl_graph.node->bool(** check if the node's operator is Var type *)valis_const:attrOwl_graph.node->bool(** check if the node's operator is Const type *)valis_node_arr:attrOwl_graph.node->bool(** check the shape of a node's attr and return if it indicates an ndarray *)valis_node_elt:attrOwl_graph.node->bool(** check the shape of a node's attr and return if it indicates an elt *)valis_assigned:attrOwl_graph.node->bool(**
[is_assigned node] checks if a block of memory has been assigned to
[node].
*)valcheck_assigned:attrOwl_graph.node->unit(**
[check_assigned node] throws an exception if [node] has not been
assigned to a block.
*)valis_valid:attrOwl_graph.node->bool(** check if the state attribute of a node is Valid *)valvalidate:attrOwl_graph.node->unit(** set Valid to the state attribute of a node *)valinvalidate:attrOwl_graph.node->unit(** set Invalid to the state attribute of a node *)valinvalidate_graph:attrOwl_graph.node->unit(** iteratively invalidate the nodes in a graph *)valis_freeze:attrOwl_graph.node->bool(** check the freeze attribute of a node *)valfreeze:attrOwl_graph.node->unit(** return the freeze attribute of a node *)valfreeze_descendants:attrOwl_graph.nodearray->unit(** iteratively freeze the descendants of a node *)valfreeze_ancestors:attrOwl_graph.nodearray->unit(** iteratively freeze the ancestors of a node *)valpack_arr:A.arr->arr(** pack an A.arr type input into Arr type *)valunpack_arr:arr->A.arr(** unpack input into A.arr type *)valpack_elt:A.elt->elt(** pack an A.elt type input into Elt type *)valunpack_elt:elt->A.elt(** unpack input into A.elt type *)valunsafe_assign_arr:arr->A.arr->unit(** assign Arr type value *)valassign_arr:arr->A.arr->unit(** assign Arr type value *)valassign_elt:elt->A.elt->unit(** assign Elt type value *)valfloat_to_elt:float->elt(** build an Elt type based on float value *)valelt_to_float:elt->float(** retrive a float value from an Elt type value *)end