Constant host::metadata::DOC_TEXT[][src]

pub const DOC_TEXT: &str = "(;; The size of a graph buffer. This is equivalent to `$size` in `typenames.witx` but renamed since `typenames.witx` is\nnot included here but is included in the overall ephemeral phase.\n ;) (typename $buffer_size u32)\n(;; Error codes returned by functions in this API. This is prefixed to avoid conflicts with the `$errno` in\n`typenames.witx`.\n ;) (typename $nn_errno (enum (@witx tag u16) (;; No error occurred.\n ;) $success (;; Caller module passed an invalid argument.\n ;) $invalid_argument (;; Caller module is missing a memory export.\n ;) $missing_memory (;; Device or resource busy.\n ;) $busy))\n(;; The dimensions of a tensor.\n\nThe array length matches the tensor rank and each element in the array\ndescribes the size of each dimension.\n ;) (typename $tensor_dimensions (list u32))\n(;; The type of the elements in a tensor.\n ;) (typename $tensor_type (enum (@witx tag u8) $f16 $f32 $u8 $i32))\n(;; The tensor data\n\nInitially conceived as a sparse representation, each empty cell would be filled with zeroes and\nthe array length must match the product of all of the dimensions and the number of bytes in the type (e.g. a 2x2\ntensor with 4-byte f32 elements would have a data array of length 16). Naturally, this representation requires\nsome knowledge of how to lay out data in memory--e.g. using row-major ordering--and could perhaps be improved\nby future witx features (TODO).\n ;) (typename $tensor_data (list u8))\n(;; A tensor.\n ;) (typename $tensor (record (;; Describe the size of the tensor (e.g. 2x2x2x2 -> [2, 2, 2, 2]). To represent a tensor containing a single value,\nuse `[1]` for the tensor dimensions.\n ;) (field $dimensions $tensor_dimensions) (field $type $tensor_type) (;; Contains the tensor data.\n ;) (field $data $tensor_data)))\n(;; The graph initialization data. This consists of an array of buffers because implementing backends may encode their\ngraph IR in parts (e.g. OpenVINO stores its IR and weights separately).\n ;) (typename $graph_builder (list u8))\n(typename $graph_builder_array (list $graph_builder))\n(;; An execution graph for performing inference (i.e. a model).\n ;) (typename $graph (handle))\n(;; Describes the encoding of the graph. This allows the API to be implemented by various backends that encode (i.e.\nserialize) their graph IR differently.\n ;) (typename $graph_encoding (enum (@witx tag u8) (;; TODO document buffer order\n ;) $openvino))\n(;; Define where the graph should be executed.\n ;) (typename $execution_target (enum (@witx tag u8) $cpu $gpu $tpu))\n(;; A $graph_execution_context allows for attaching inputs prior to calling `compute` on a graph and retrieving outputs after\nthe computation has completed. TODO a handle may not be the right type but we want it to be opaque to users.\n ;) (typename $graph_execution_context (handle))\n(module $wasi_ephemeral_nn (;; Linear memory to be accessed by WASI functions that need it.\n ;) (import \"memory\" (memory)) (;; Load an opaque sequence of bytes to use for inference.\n\nThis allows runtime implementations to support multiple graph encoding formats. For unsupported graph encodings,\nreturn `errno::inval`.\n ;) (@interface func (export \"load\") (;; The bytes necessary to build the graph.\n ;) (param $builder $graph_builder_array) (;; The encoding of the graph.\n ;) (param $encoding $graph_encoding) (;; Where to execute the graph.\n ;) (param $target $execution_target) (result $error (variant (@witx tag u32) (case $ok $graph) (case $err $nn_errno)))) (;; TODO Functions like `describe_graph_inputs` and `describe_graph_outputs` (returning\nan array of `$tensor_description`s) might be useful for introspecting the graph but are not yet included here.\nCreate an execution instance of a loaded graph.\nTODO this may need to accept flags that might affect the compilation or execution of the graph.\n ;) (@interface func (export \"init_execution_context\") (param $graph $graph) (result $error (variant (@witx tag u32) (case $ok $graph_execution_context) (case $err $nn_errno)))) (;; Define the inputs to use for inference.\n\nThis should return an $nn_errno (TODO define) if the input tensor does not match the expected dimensions and type.\n ;) (@interface func (export \"set_input\") (param $context $graph_execution_context) (;; The index of the input to change.\n ;) (param $index u32) (;; The tensor to set as the input.\n ;) (param $tensor $tensor) (result $error (variant (@witx tag u32) (case $ok) (case $err $nn_errno)))) (;; Extract the outputs after inference.\n\nThis should return an $nn_errno (TODO define) if the inference has not yet run.\n ;) (@interface func (export \"get_output\") (param $context $graph_execution_context) (;; The index of the output to retrieve.\n ;) (param $index u32) (;; An out parameter to which to copy the tensor data. The caller is responsible for allocating enough memory for\nthe tensor data or an error will be returned. Currently there is no dynamic way to extract the additional\ntensor metadata (i.e. dimension, element type) but this should be added at some point.\n ;) (param $out_buffer (@witx pointer u8)) (param $out_buffer_max_size $buffer_size) (;; The number of bytes of tensor data written to the `$out_buffer`.\n ;) (result $error (variant (@witx tag u32) (case $ok $buffer_size) (case $err $nn_errno)))) (;; Compute the inference on the given inputs (see `set_input`).\n\nThis should return an $nn_errno (TODO define) if the inputs are not all defined.\n ;) (@interface func (export \"compute\") (param $context $graph_execution_context) (result $error (variant (@witx tag u32) (case $ok) (case $err $nn_errno)))))\n";