numa/tensor
模块 zio.numa.tensor — generic CPU tensor client · 29 个符号
Generic CPU tensor client. Explicit caller-owned reference names identify tensors only inside an opaque backend handle; they confer no host authority. Operations use the zio.tensor.state/1 and RPC v1 backend contract. No datasets, objectives, teachers or application orchestration is hidden here. Results from the JSON backend have STRING keys; tensor-ref normalizes them.
概览
tensor-start
(defn tensor-start [config] …)
(tensor-start config) — starts a tensor backend with config via the host bindings; returns an opaque backend handle.
tensor-close
(defn tensor-close [backend] …)
(tensor-close backend) — closes a backend opened by tensor-start.
tensor-call
(defn tensor-call [backend operation] …)
(tensor-call backend operation) — sends an operation map to the backend over the RPC v1 contract; errors when operation is not a map.
tensor-ref
(defn tensor-ref [tensor] …)
(tensor-ref tensor) — normalizes a tensor reference: strings pass through, maps yield the "tensor"/:tensor key; anything else is an invalid-input error. Needed because JSON backend results use string keys.
tensor-create
(defn tensor-create [backend out data shape dtype requires-grad] …)
(tensor-create backend out data shape dtype requires-grad) — creates
tensor out from data with the given shape and dtype.
tensor-full
(defn tensor-full [backend out shape value dtype requires-grad] …)
(tensor-full backend out shape value dtype requires-grad) — creates
tensor out filled with value in the given shape and dtype.
tensor-kernel
(defn tensor-kernel [backend op out inputs attributes] …)
(tensor-kernel backend op out inputs attributes) — generic kernel dispatch: sends {:op op :out out :inputs refs} merged over attributes, where inputs are normalized via tensor-ref. Attributes cannot override op, out or inputs.
tensor-unary
(defn tensor-unary [backend op out input] …)
(tensor-unary backend op out input) — element-wise unary kernel on one input tensor.
tensor-binary
(defn tensor-binary [backend op out left right] …)
(tensor-binary backend op out left right) — element-wise binary kernel over two input tensors.
tensor-matmul
(defn tensor-matmul [backend out left right] …)
(tensor-matmul backend out left right) — matrix multiply of left and right into out.
tensor-linear
(defn tensor-linear [backend out input weight bias] …)
(tensor-linear backend out input weight bias) — affine layer input·weight (+ bias when bias is non-nil) into out.
tensor-reduce
(defn tensor-reduce [backend op out input dim keepdim] …)
(tensor-reduce backend op out input dim keepdim) — reduction kernel (e.g. sum/max) over input, optionally restricted to dim and keeping or dropping that dimension per keepdim.
tensor-reshape
(defn tensor-reshape [backend out input shape] …)
(tensor-reshape backend out input shape) — reshapes input to shape.
tensor-transpose
(defn tensor-transpose [backend out input dim0 dim1] …)
(tensor-transpose backend out input dim0 dim1) — transposes input, swapping dimensions dim0 and dim1.
tensor-value
(defn tensor-value [backend input] …)
(tensor-value backend input) — the concrete data values of input.
tensor-info
(defn tensor-info [backend input] …)
(tensor-info backend input) — metadata (shape, dtype, grad status) of input.
tensor-freeze
(defn tensor-freeze [backend input frozen] …)
(tensor-freeze backend input frozen) — marks input frozen (or unfrozen) so gradient tracking skips it.
tensor-assign
(defn tensor-assign [backend input data] …)
(tensor-assign backend input data) — overwrites input's data in place.
tensor-drop
(defn tensor-drop [backend inputs] …)
(tensor-drop backend inputs) — releases the referenced tensors from the backend.
tensor-backward
(defn tensor-backward [backend loss gradient retain-graph] …)
(tensor-backward backend loss gradient retain-graph) — backpropagates from loss; gradient optionally seeds the loss gradient, and retain-graph keeps the graph for further backward passes.
tensor-grad
(defn tensor-grad [backend out input] …)
(tensor-grad backend out input) — stores input's gradient in out.
tensor-zero-grad
(defn tensor-zero-grad [backend inputs] …)
(tensor-zero-grad backend inputs) — zeroes the gradients of the referenced tensors.
tensor-adam
(defn tensor-adam [backend name parameters config] …)
(tensor-adam backend name parameters config) — creates an Adam
optimizer named name over the referenced parameters with config
options (e.g. learning rate) merged in.
tensor-step
(defn tensor-step [backend optimizer] …)
(tensor-step backend optimizer) — applies one Adam update step.
tensor-drop-optimizer
(defn tensor-drop-optimizer [backend optimizer] …)
(tensor-drop-optimizer backend optimizer) — releases the optimizer and its state from the backend.
tensor-seed
(defn tensor-seed [backend seed] …)
(tensor-seed backend seed) — seeds the backend's random generator (used by sampling ops).
tensor-sample
(defn tensor-sample [backend operation out attributes] …)
(tensor-sample backend operation out attributes) — runs a sampling operation writing into out; attributes are merged under the op/out keys.
tensor-state-export
(defn tensor-state-export [backend] …)
(tensor-state-export backend) — exports the backend's full tensor state as a serializable value.
tensor-state-import
(defn tensor-state-import [backend state strict] …)
(tensor-state-import backend state strict) — imports state produced by tensor-state-export; strict mode rejects partial/unknown entries.