46#ifndef __CTX_GRAPH_H__
47#define __CTX_GRAPH_H__
74#define CTX_GRAPH_INVERSE_RMS_EPSILON 1.0e-6f
175 gzRefPointer<gzReference> m_state;
230 gzUInt32 m_maxDebugFeatures;
232 ctxOperationSchemaPtr m_schema;
382 gzUInt32 m_dimensions[4];
391 gzUInt32 height = 2, gzUInt32 depth = 3);
444 gzDynamicTypeContainer& attributes)
const;
464 gzBool m_derivatives;
465 ctxGraphOperationLowererPtr m_operationLowerer;
466 ctxGraphConnectionLowererPtr m_connectionLowerer;
534 gzArray<ctxParameterRole> m_roles;
557 gzUInt32 neuron, gzUInt32 signal);
567 gzBool bind(
const gzString& role, gzUInt32 element, gzUInt32 neuron, gzUInt32 signal);
568 gzUInt32 bindingIndex(gzUInt32 role, gzUInt32 element)
const;
569 ctxParameterOperationSchemaPtr m_schema;
570 gzDynamicArray<gzUInt32> m_neurons;
571 gzDynamicArray<gzUInt32> m_signals;
731 gzRefPointer<ctxGraphState> m_state;
732 gzUInt32 m_occurrenceID;
742 gzUInt32 sourceFeatureCount, gzUInt32 destinationFeatureIndex,
743 gzUInt32 destinationFeatureCount, gzUInt32 sourceWidth, gzUInt32 sourceHeight,
744 gzUInt32 sourceDepth, gzUInt32 kernelWidth, gzUInt32 kernelHeight, gzUInt32 kernelDepth = 1);
750 gzUInt32 top, gzUInt32 bottom, gzUInt32 front = 0, gzUInt32 back = 0)
const;
777 gzUInt32 x, gzUInt32 y, gzUInt32 z = 0)
const;
785 gzRefPointer<ctxGraphState> m_state;
786 gzUInt32 m_occurrenceID;
800 gzDynamicArray<ctxConvolutionMappingRef> m_mappings;
814 gzDynamicArray<ctxLayerRef> m_layers;
840 gzRefPointer<ctxGraphState> m_state;
841 gzUInt32 m_occurrenceID;
842 gzUInt32 m_nodeIndex;
856 gzDynamicArray<ctxNodeRef> m_nodes;
880 gzRefPointer<ctxGraphState> m_state;
881 gzUInt32 m_occurrenceID;
906 gzRefPointer<ctxGraphState> m_state;
907 gzUInt32 m_occurrenceID;
957 explicit ctxValue(
const gzString& error);
999 gzRefPointer<ctxGraphState> m_state;
1000 ctxOperationSchemaPtr m_boundarySchema;
1029 gzUInt32 x, gzUInt32 y, gzUInt32 z = 0)
const;
1037 gzRefPointer<ctxGraphState> m_state;
1038 gzUInt32 m_destinationOccurrenceID;
1039 gzUInt32 m_connectionID;
1053 gzDynamicArray<ctxConnectionRef> m_connections;
1080 gzUInt32 connectionID, gzUInt32 sourceOccurrenceID, gzUInt32 sourceIndex, gzUInt32 destinationIndex);
1082 gzRefPointer<ctxGraphState> m_state;
1084 gzUInt32 m_occurrenceID;
1085 gzUInt32 m_connectionID;
1086 gzUInt32 m_sourceOccurrenceID;
1087 gzUInt32 m_sourceIndex;
1088 gzUInt32 m_destinationIndex;
1110 gzUInt32 connectionID, gzUInt32 sourceOccurrenceID, gzUInt32 sourceCount,
1111 gzUInt32 destinationIndex, gzUInt32 destinationCount);
1113 gzRefPointer<ctxGraphState> m_state;
1115 gzUInt32 m_occurrenceID;
1116 gzUInt32 m_connectionID;
1117 gzUInt32 m_sourceOccurrenceID;
1118 gzUInt32 m_sourceCount;
1119 gzUInt32 m_destinationIndex;
1120 gzUInt32 m_destinationCount;
1203 gzBool sharedBias = TRUE, gzUInt32 maxDebugFeatures = 0);
1207 CTX_EXPORT gzBool
share(
const gzArray<ctxParameterRef>& first,
const gzArray<ctxParameterRef>& second);
1215 gzXmlCustomDataInterface* customDataInterface, gzBool
replace = FALSE);
1245 static gzBool loadXml(gzSerializeAdapter* adapter,
ctxGraph& graph, gzString* error);
1246 gzBool addOperation(
const ctxGraphOperation& operation, gzBool rejectDuplicatePath = TRUE);
1247 gzBool validateState(gzString& error)
const;
1252 gzRefPointer<ctxGraphState> m_state;
1271 gzUInt32 parameterCount, gzUInt32& parameterBase, gzString& error);
1280 gzDynamicArray<gzUInt32>* m_layerMapping;
1281 gzDynamicArray<gzUInt32> m_convolutionParameterGroupIDs;
1282 gzDynamicArray<gzUInt32> m_convolutionParameterBases;
1283 gzDynamicArray<gzUInt32> m_convolutionParameterCounts;
1377 const gzString& message);
1406 gzUInt32 modelID, gzUInt32 realizationID, gzUInt32 compilationID,
1407 gzUInt32 propagationID);
1412 gzUInt32 m_realizationID;
1413 gzUInt32 m_compilationID;
1414 gzUInt32 m_propagationID;
1522 ctxInputPtr m_input;
1523 ctxOutputPtr m_output;
1524 ctxCortexPtr m_cortex;
1569 gzUInt32 programMask);
1575 gzUInt32 m_programMask;
1755 const gzString& value)
const;
1782 gzUInt32 sample = 0, gzUInt32 pages = 1);
1840 ctxNeuronType outputType, gzBool isolateBindings, gzBool materialize,
1841 ctxCortexPtr& cortex, gzDynamicArray<gzUInt32>& layerMapping, gzString& error);
1842 gzBool materializeGeneric()
const;
1847 gzBool applyParameterSharing();
1848 gzVoid releaseDirectCortex();
1850 mutable ctxCortexPtr m_cortex;
1851 ctxTrainerPtr m_trainer;
1852 ctxOutputPtr m_buildOutputBinding;
1853 gzRefPointer<ctxGraphState> m_graphState;
1855 mutable gzDynamicArray<gzUInt32> m_layerMapping;
1856 gzDynamicArray<ctxValueRef> m_monitoredValues;
1861 gzDynamicArray<ctxExecutionTraceEntry> m_executionTrace;
1862 gzRefPointer<gzReference> m_semanticOriginSnapshot;
1863 gzString m_signature;
1864 mutable gzString m_error;
1867 gzUInt32 m_realizationID;
1868 gzUInt32 m_compilationID;
1869 gzUInt32 m_nextCompilationID;
1870 gzUInt32 m_propagationID;
ctxActivation(ctxNeuronType type=CTX_NEURON_TYPE_DEFAULT)
ctxNeuronType getType() const
Exact association of a lifecycle artifact with one model and graph revision.
ctxLifecycleSource getSource() const
gzUInt32 getPropagationID() const
gzBool operator==(const ctxArtifactIdentity &identity) const
gzBool operator!=(const ctxArtifactIdentity &identity) const
gzUInt32 getCompilationID() const
gzUInt32 getRealizationID() const
ctxGraphIdentity getGraphIdentity() const
gzUInt32 getModelID() const
Maps each output dimension to one input dimension: features=0, width=1, height=2, depth=3.
ctxAxisOrder(gzUInt32 features=0, gzUInt32 width=1, gzUInt32 height=2, gzUInt32 depth=3)
gzUInt32 getAxis(gzUInt32 outputDimension) const
ctxBackpropTrainingOptions()
Exact build ownership, captured operation contracts and layout policy.
ctxArtifactIdentity getArtifactIdentity() const
ctxBuildLayoutPolicy getLayoutPolicy() const
friend class ctxBuildRealization
gzBool operator!=(const ctxBuildIdentity &identity) const
ctxOperationRegistryRevision getOperationRegistryRevision() const
gzBool operator==(const ctxBuildIdentity &identity) const
Owned read-only semantic snapshot of a successful graph build, without CAL.
const ctxGraph & getGraph() const
ctxBuildIdentity getIdentity() const
ctxArtifactIdentity getArtifactIdentity() const
Immutable request to realize a graph revision or adapt a direct ctxCortex.
ctxGraphIdentity getGraphIdentity() const
ctxLifecycleSource getSource() const
ctxBuildRequest(const ctxGraph &graph, ctxInput *input, ctxOutput *output, ctxNeuronType outputType=CTX_NEURON_TYPE_DEFAULT)
ctxBuildRequest(ctxCortex *cortex)
ctxBuildRequest(const ctxBuildRealization &realization, ctxInput *input, ctxOutput *output, ctxNeuronType outputType=CTX_NEURON_TYPE_DEFAULT)
Rebinds retained graph semantics with new bindings/output policy; direct adapters are excluded.
ctxCortex * getCortex() const
ctxBuildRequest(const ctxBuildRequest &request)
ctxBuildRequest & operator=(const ctxBuildRequest &request)
ctxOutput * getOutput() const
ctxNeuronType getOutputType() const
const ctxGraph & getGraph() const
ctxInput * getInput() const
ctxLifecycleDiagnostic getDiagnostic() const
ctxArtifactIdentity getArtifactIdentity() const
ctxGraphIdentity getGraphIdentity() const
Immutable compile request tied to one successful build result.
ctxCompileRequest(const ctxBuildRealization &realization, const ctxCompileOptions &options=ctxCompileOptions())
ctxCompileOptions getOptions() const
ctxArtifactIdentity getBuildIdentity() const
ctxProgramProfile getProfile() const
ctxCompileRequest(const ctxBuildResult &build, const ctxCompileOptions &options=ctxCompileOptions())
ctxLifecycleDiagnostic getDiagnostic() const
ctxGraphIdentity getGraphIdentity() const
ctxExecutionProgram getProgram() const
ctxProgramProfile getProfile() const
ctxArtifactIdentity getArtifactIdentity() const
ctxNodeRef getSourceNode(gzUInt32 cell) const
Enumerates semantic projection cells, including permutations and reduction groups.
ctxNodeRef getSourceNode() const
ctxParameterRef weight(const ctxNodeRef &source, const ctxNodeRef &destination) const
ctxGraphProjectionKind getProjectionKind() const
Schema-aware inspection; does not change any raw connection record.
ctxGraphIdentity getGraphIdentity() const
ctxParameterSlice weights(const ctxNodeRef &destination) const
ctxParameterSlice kernel(gzUInt32 sourceFeature, gzUInt32 filterFeature) const
ctxNodeRangeRef getDestinationRange() const
ctxNodeRef getDestinationNode(gzUInt32 cell) const
ctxParameterRef kernelWeight(gzUInt32 sourceFeature, gzUInt32 filterFeature, gzUInt32 x, gzUInt32 y, gzUInt32 z=0) const
ctxNodeRangeRef getSourceRange() const
ctxParameterSlice weights() const
gzUInt32 getOccurrenceID() const
ctxLayerRef getDestination() const
ctxParameterRef weight(gzUInt32 sourceIndex, gzUInt32 destinationIndex) const
ctxNodeRef getDestinationNode() const
ctxConnectionRef get(gzUInt32 index) const
ctxConvolutionMapping origin(gzInt32 x, gzInt32 y, gzInt32 z=0) const
ctxConvolutionMapping destinationOrigin(gzUInt32 x, gzUInt32 y, gzUInt32 z=0) const
ctxConvolutionMapping(const ctxLayerRef &source, gzUInt32 sourceFeatureIndex, gzUInt32 sourceFeatureCount, gzUInt32 destinationFeatureIndex, gzUInt32 destinationFeatureCount, gzUInt32 sourceWidth, gzUInt32 sourceHeight, gzUInt32 sourceDepth, gzUInt32 kernelWidth, gzUInt32 kernelHeight, gzUInt32 kernelDepth=1)
ctxConvolutionMapping padding(gzUInt32 left, gzUInt32 right, gzUInt32 top, gzUInt32 bottom, gzUInt32 front=0, gzUInt32 back=0) const
ctxConvolutionMapping dilation(gzUInt32 x, gzUInt32 y, gzUInt32 z=1) const
ctxConvolutionMapping region(gzUInt32 width, gzUInt32 height, gzUInt32 depth=1) const
ctxConvolutionMapping stride(gzUInt32 x, gzUInt32 y, gzUInt32 z=1) const
ctxParameterRef kernelWeight(gzUInt32 sourceFeature, gzUInt32 destinationFeature, gzUInt32 x, gzUInt32 y, gzUInt32 z=0) const
ctxConvolutionMappingRef()
ctxGraphIdentity getGraphIdentity() const
ctxLayerRef getDestination() const
gzUInt32 getDestinationFeatureCount() const
gzUInt32 getParameterGroupID() const
gzUInt32 getSourceFeatureIndex() const
ctxParameterSlice kernel(gzUInt32 sourceFeature, gzUInt32 destinationFeature) const
gzUInt32 getDestinationFeatureIndex() const
gzUInt32 getSourceFeatureCount() const
ctxLayerRef getSource() const
gzUInt32 getOccurrenceID() const
friend class ctxConvolutionMappingRefList
ctxConvolutionMappingRefList()
ctxConvolutionMappingRef get(gzUInt32 index) const
Opt-in custom contract whose callbacks may run at first materialization.
ctxDeferredOperationSchema(const gzString &key, gzUInt32 version, ctxGraphOperationLowerer *operationLowerer, ctxGraphConnectionLowerer *connectionLowerer, gzBool derivatives)
ctxDeferredOperationSchema(const gzString &key, gzUInt32 version, ctxGraphOperationType role, ctxGraphOperationLowerer *operationLowerer, ctxGraphConnectionLowerer *connectionLowerer, gzBool derivatives)
Inspectable execution-program identity.
ctxExecutionMode getMode() const
gzBool hasProgram(ctxProgramType type) const
ctxInstrumentationFlags getInstrumentation() const
ctxProgramProfile getProfile() const
ctxArtifactIdentity getArtifactIdentity() const
gzUInt32 sourceOccurrenceID
gzUInt32 destinationNodeIndex
gzUInt32 getSize() const
Legacy ZIP-only size.
gzUInt32 destinationNodeCount
gzUInt32 destinationOccurrenceID
virtual gzBool useDeepCopy() override
virtual gzBool lower(const ctxGraphOperation &operation, ctxGraphLoweringContext &context, gzString &error)=0
gzUInt32 destinationOccurrenceID
gzUInt32 parameterGroupID
gzUInt32 sourceOccurrenceID
gzUInt32 sourceFeatureIndex
gzUInt32 destinationOriginX
gzUInt32 destinationFeatureCount
gzUInt32 destinationOriginZ
gzUInt32 sourceFeatureCount
gzUInt32 destinationOriginY
gzUInt32 destinationFeatureIndex
ctxGraphConvolutionMapping()
static gzBool registerXmlType(const gzString &elementName, gzXmlCustomDataInterface *customDataInterface, gzBool replace=FALSE)
ctxLayerRefList layers() const
ctxHandleStatus getHandleStatus(const ctxConvolutionMappingRef &mapping) const
static gzVoid unregisterConnectionLowerer(ctxGraphConnectionLowerer *lowerer)
ctxConvolutionMappingRef attachConvolutionMapping(const ctxLayerRef &convolution, const ctxConvolutionMapping &mapping)
gzBool share(const gzArray< ctxParameterRef > &first, const gzArray< ctxParameterRef > &second)
Shares every pair first[i]/second[i] in one validated commit; any invalid pair rejects all.
ctxLayerRef getLayer(gzUInt32 index) const
gzBool apply(const ctxLayer &layer, const ctxValue &left, const ctxValue &right, ctxValue &result)
Binary Add/Multiply accepts current or shape-preserving ancestor values.
gzString getError() const
gzBool unshare(const ctxParameterRef ¶meter)
gzBool save(const gzString &url) const
static ctxOperationSchemaPtr getBuiltinSchema(ctxGraphOperationType type)
Captures the currently installed legacy lowerers for subsequent authoring.
ctxConnectionRef connect(const ctxNodeRangeRef &source, const ctxNodeRangeRef &destination)
gzBool addLayer(const ctxLayer &layer)
gzBool apply(const ctxLayer &layer, const ctxValue &input, ctxValue &result)
Atomically authors occurrence and full explicit edge; result is unchanged on failure.
ctxLayerRefList layers(const gzString &name) const
ctxHandleStatus getHandleStatus(const ctxNodeRangeRef &nodes) const
gzBool share(const ctxParameterRef &first, const ctxParameterRef &second)
gzBool addMultiply(const gzString &path, gzUInt32 values, const ctxPortRef &left, const ctxPortRef &right)
Atomically authors Multiply and both whole ZIP inputs, including aliases.
static ctxGraphConnectionLowerer * getConnectionLowerer(ctxGraphOperationType type)
ctxConnectionRef connect(const ctxNodeRef &source, const ctxNodeRef &destination)
static gzBool unregisterOperationSchema(const gzString &key, gzUInt32 version)
static gzBool load(const gzString &url, ctxGraph &graph, gzString *error=NULL)
gzBool applyRmsNorm(const gzString &name, gzUInt32 axis, const ctxValue &input, ctxValue &result)
Atomically authors "name/rstd" = ReduceInverseRms(axis) over input and "name" = MultiplyBroadcast(axi...
gzBool addDenseFrom(const gzString &path, gzUInt32 neurons, const ctxPortRef &source, ctxNeuronType type=CTX_NEURON_TYPE_DEFAULT)
Stages DenseFrom and its complete selected source in one candidate.
gzBool remove(const ctxLayerRef &layer)
ctxHandleStatus getHandleStatus(const ctxValueRef &value) const
friend ctxGraph operator+(const ctxLayer &left, const ctxLayer &right)
static gzVoid unregisterOperationLowerer(ctxGraphOperationLowerer *lowerer)
const ctxGraphOperation * getOperationByID(gzUInt32 occurrenceID) const
ctxHandleStatus getHandleStatus(const ctxParameterRef ¶meter) const
gzBool shareConvolutionParameters(const ctxConvolutionMappingRef &first, const ctxConvolutionMappingRef &second)
gzBool addActivation(const gzString &path, gzUInt32 values, ctxNeuronType type=CTX_NEURON_TYPE_DEFAULT)
gzUInt32 getOperationIndex(gzUInt32 occurrenceID) const
gzBool addConvolution2D(const gzString &path, ctxIndexControl source, ctxIndexControl filter, ctxNeuronType type=CTX_NEURON_TYPE_DEFAULT, gzBool sharedBias=TRUE, gzUInt32 maxDebugFeatures=0)
gzBool disconnect(const ctxConnectionRef &connection)
gzUInt32 getOperationCount() const
friend ctxGraph operator+(const ctxGraph &graph, const ctxLayer &layer)
ctxValue value(const ctxPortRef &output) const
Rebinds a whole result to this revision; changed ancestor shapes fail.
gzBool addAdd(const gzString &path, gzUInt32 values, const ctxPortRef &left, const ctxPortRef &right)
Atomically authors Add and both full ZIP inputs; no bare Add is staged.
ctxHandleStatus getHandleStatus(const ctxValue &value) const
gzUInt32 getLayerCount(const gzString &name) const
ctxHandleStatus getHandleStatus(const ctxConnectionRef &connection) const
static gzBool registerOperationSchema(ctxOperationSchema *schema)
Duplicate definitions require a new version; unregister only disables lookup.
ctxGraphIdentity getIdentity() const
ctxHandleStatus getHandleStatus(const ctxPortRef &port) const
const ctxGraphOperation * getOperation(gzUInt32 index) const
gzBool addOutput(const gzString &path, gzUInt32 values, ctxNeuronType type=CTX_NEURON_TYPE_DEFAULT)
static gzBool registerOperationLowerer(ctxGraphOperationType type, ctxGraphOperationLowerer *lowerer, gzBool replace=FALSE)
gzBool apply(const ctxModule &module, const gzString &prefix, const ctxValue &input, ctxValue &result)
Copies a captured module atomically; graph and result remain unchanged on failure.
static gzVoid unregisterXmlType(gzXmlCustomDataInterface *customDataInterface)
ctxConnectionRef connect(const ctxPortRef &source, const ctxPortRef &destination)
static ctxGraphOperationLowerer * getOperationLowerer(ctxGraphOperationType type)
ctxHandleStatus getHandleStatus(const ctxParameterSlice ¶meters) const
ctxHandleStatus getHandleStatus(const ctxNodeRef &node) const
ctxLayerRef layer(const gzString &name) const
gzBool replace(const ctxLayerRef &layer, const ctxLayer &replacement)
Replaces a non-marker with Dense, or a unary occurrence with a same-shaped captured schema.
gzString getCanonicalSignature() const
gzBool share(const ctxParameterSlice &first, const ctxParameterSlice &second)
gzBool replaceConvolutionMapping(const ctxConvolutionMappingRef ¤t, const ctxConvolutionMapping &replacement)
gzBool addInput(const gzString &path, gzUInt32 values)
gzBool replaceConvolution2D(const ctxLayerRef &layer, ctxIndexControl source, ctxIndexControl filter, ctxNeuronType type=CTX_NEURON_TYPE_DEFAULT, gzBool sharedBias=TRUE, gzUInt32 maxDebugFeatures=0)
friend class ctxGraphDocument
gzBool addDense(const gzString &path, gzUInt32 neurons, ctxNeuronType type=CTX_NEURON_TYPE_DEFAULT)
static gzBool registerConnectionLowerer(ctxGraphOperationType type, ctxGraphConnectionLowerer *lowerer, gzBool replace=FALSE)
gzBool removeConvolutionMapping(const ctxConvolutionMappingRef &mapping)
static ctxOperationSchemaPtr getOperationSchema(const gzString &key, gzUInt32 version)
ctxConnectionRef connectionInto(const ctxLayerRef &layer) const
ctxHandleStatus getHandleStatus(const ctxLayerRef &layer) const
Identifies one immutable revision in a graph lineage.
gzUInt32 getGraphID() const
ctxGraphIdentity(gzUInt32 graphID, gzUInt32 revision)
gzBool operator!=(const ctxGraphIdentity &identity) const
friend class ctxBuildRequest
gzBool operator==(const ctxGraphIdentity &identity) const
gzUInt32 getRevision() const
ctxCortex * getCortex() const
ctxCortexLayer * getLayer(gzUInt32 occurrenceID) const
ctxInput * getInput() const
gzBool getConvolutionParameterBase(gzUInt32 parameterGroupID, gzUInt32 parameterCount, gzUInt32 ¶meterBase, gzString &error)
ctxOutput * getOutput() const
ctxGraphLoweringContext(const ctxGraphState *state, ctxCortex *cortex, ctxInput *input, ctxOutput *output, gzDynamicArray< gzUInt32 > &layerMapping)
const ctxGraphState * getGraphState() const
gzBool addLayer(gzUInt32 occurrenceID, ctxCortexLayer *layer, gzString &error)
ctxContext * getContext() const
ctxOperationSchemaPtr schema
gzUInt32 maxDebugFeatures
ctxGraphOperationType type
virtual gzBool useDeepCopy() override
virtual gzBool lower(const ctxGraphOperation &operation, ctxGraphLoweringContext &context, gzString &error)=0
gzUInt32 sourceOccurrenceID
gzUInt32 destinationIndex
ctxGraphParameterBinding()
ctxGraphState(const ctxGraphState ©)
gzDynamicArray< ctxGraphOperation > operations
virtual gzBool useDeepCopy() override
gzRefPointer< ctxGraphState > parentState
gzDynamicArray< ctxGraphConnection > connections
gzUInt32 nextConnectionID
gzDynamicArray< ctxGraphConvolutionMapping > convolutionMappings
gzDynamicArray< ctxGraphParameterBinding > parameterBindings
gzUInt32 nextMappingParameterGroupID
gzUInt32 nextOccurrenceID
friend ctxLayer Input(gzUInt32 values)
friend ctxLayer ReduceSum()
Parameter-free whole-value sum to one rank-one FLOAT result.
ctxLayer sharedBias(gzBool shared) const
ctxLayer activation(const ctxActivation &activation) const
friend ctxLayer Reshape(const ctxShape &shape)
Parameter-free rank-one/rank-four shape view preserving every flat value index.
friend ctxLayer ReduceSum(gzUInt32 axis)
Reduce one explicit rank-four axis (0..3), retaining that dimension at length one.
ctxValue operator()(const ctxValue &input) const
Authors one unary occurrence, including named FLOAT inventories or explicit DenseFrom.
friend ctxLayer ReduceInverseRms()
Parameter-free whole-value inverse root mean square to one rank-one FLOAT result: r = (sum(x*x)/N + C...
friend ctxLayer DenseFrom(gzUInt32 neurons, ctxNeuronType type)
Full Dense projection from one explicitly selected whole rank-one FLOAT value.
friend ctxLayer Convolution2D(ctxIndexControl source, ctxIndexControl filter, ctxNeuronType type)
friend ctxLayer RegisteredOperation(const gzString &key, gzUInt32 version, gzUInt32 values)
Creates an occurrence with its captured unary or explicit full-projection role.
ctxLayer debugFeatures(gzUInt32 features) const
ctxValue operator()(const ctxValue &left, const ctxValue &right) const
Authors Add or Multiply from two whole values bound to one common revision.
ctxLayer named(const gzString &name) const
friend ctxLayer RegisteredOperation(const gzString &key, gzUInt32 version, ctxIndexControl source, ctxIndexControl filter)
Creates a captured registered Convolution occurrence with checked source/filter controls.
friend ctxLayer ReduceInverseRms(gzUInt32 axis)
Inverse root mean square over one explicit rank-four axis (0..3), retaining that dimension at length ...
ctxLayer data(const ctxOperationData &data) const
Captures immutable occurrence data; the retained schema validates its contract.
friend ctxLayer ReduceMean(gzUInt32 axis)
friend ctxLayer ReduceMaximum()
Whole-value maximum; Backprop divides the derivative equally among ties.
friend ctxLayer ReduceMaximum(gzUInt32 axis)
friend ctxLayer ReduceMean()
Parameter-free whole-value arithmetic mean to one rank-one FLOAT result.
friend ctxLayer MultiplyBroadcast(gzUInt32 axis)
Parameter-free product of a rank-four left value and a right value of the same shape except length on...
friend ctxLayer Dense(gzUInt32 neurons, ctxNeuronType type)
friend ctxLayer Output(gzUInt32 values, ctxNeuronType type)
friend ctxLayer Multiply(gzUInt32 values)
Parameter-free element-wise product of two equal whole rank-one float values.
friend ctxLayer Activation(gzUInt32 values, const ctxActivation &activation)
friend ctxLayer Add(gzUInt32 values)
Parameter-free element-wise sum of two equal whole rank-one float values.
friend ctxLayer ReduceProduct(gzUInt32 axis)
friend ctxLayer ReduceProduct()
Whole-value product; derivatives remain defined when operands are zero.
friend ctxLayer Transpose(const ctxAxisOrder &axes)
Parameter-free rank-four permutation; axes use features/width/height/depth order.
ctxNeuronType getNeuronType() const
ctxConnectionRefList outgoingConnections() const
friend class ctxParameterRef
ctxOperationSchemaPtr getSchema() const
gzUInt32 getIndex() const
gzUInt32 getOccurrenceID() const
friend class ctxConvolutionMappingRef
ctxParameterSlice parameters(const gzString &role) const
Returns the complete captured named role, or an invalid slice for an unknown name.
ctxNodeRef node(gzUInt32 feature, gzUInt32 x, gzUInt32 y, gzUInt32 z=0) const
gzUInt32 getNeuronCount() const
ctxParameterSlice biases() const
ctxPortRef output() const
ctxNodeRefList nodes() const
ctxNodeRef node(gzUInt32 index) const
friend class ctxConnectionRef
gzBool getSemanticAttributes(gzDynamicTypeContainer &attributes) const
ctxGraphOperationType getType() const
ctxConnectionRefList incomingConnections() const
ctxGraphIdentity getGraphIdentity() const
ctxNodeRangeRef nodes(gzUInt32 first, gzUInt32 count) const
ctxShape getShape() const
ctxHandleStatus getStatus() const
ctxConvolutionMappingRefList convolutionMappings() const
friend class ctxNodeRangeRef
ctxLayerRef get(gzUInt32 index) const
Structured diagnostic returned by Generation 2 lifecycle operations.
ctxLifecycleError getCode() const
gzString getMessage() const
ctxLifecycleStage getStage() const
gzVoid debugProperty(const gzString &prefix, const gzString &name, const gzString &value) const
virtual gzString getDebugNodeName() const =0
gzVoid debug(ctxModelDebugFlags flags=CTX_MODEL_DEBUG_ALL) const
gzVoid debugRender(const gzString &prefix, gzBool last, ctxModelDebugFlags flags) const
virtual gzVoid debugChildren(const gzString &prefix, ctxModelDebugFlags flags) const =0
virtual gzString getDebugNodeType() const =0
virtual gzVoid debugProperties(const gzString &prefix, ctxModelDebugFlags flags) const =0
virtual ~ctxModelDebugNode()
virtual gzString getDebugNodeName() const override
gzUInt64 getCompactRealizationBytes() const
Allocated numeric lookup payload; excludes the retained graph and execution banks.
virtual gzString getDebugNodeType() const override
ctxInstrumentationFlags getInstrumentation() const
gzBool getValue(const ctxValueRef &value, gzFloat &result, gzUInt32 page=0)
gzBool compile(const ctxCompileOptions &options)
gzBool hasOptimizationIdentityMap() const
gzString getCanonicalSignature() const
ctxContext * getContext() const
Returns the live context, retaining its identity through compactRealization().
gzBool mapOptimizedValueIndex(gzUInt32 sourceIndex, gzUInt32 &optimizedIndex) const
gzBool getSemanticOrigins(gzDynamicArray< ctxSemanticOrigin > &origins) const
Materializes sorted captured Evaluate origins, then current derivative origins.
ctxTrainer * getTrainer() const
gzBool isProgramRequested(ctxProgramType type) const
gzBool getExecutionTrace(gzDynamicArray< ctxExecutionTraceEntry > &trace) const
ctxCortex * getCortex() const
Materializes generic objects before compaction; returns NULL after it until rebuild.
ctxProgramProfile getProgramProfile() const
gzBool train(const ctxBackpropTrainingOptions &options)
gzBool isMonitored(const ctxValueRef &value) const
gzBool setParameter(const ctxParameterRef ¶meter, gzFloat value)
ctxExecutionDiagnostics getExecutionDiagnostics() const
gzBool evaluate(const ctxExecutionProgram &program, gzUInt32 sample=0, gzUInt32 pages=1)
gzBool isGenericRealized() const
gzBool build(const ctxGraph &graph, ctxInput *input, ctxOutput *output, ctxNeuronType outputType=CTX_NEURON_TYPE_DEFAULT)
virtual gzVoid debugProperties(const gzString &prefix, ctxModelDebugFlags flags) const override
gzBool evaluate(gzUInt32 sample=0, gzUInt32 pages=1)
gzBool loadParameters(const gzString &url)
ctxCompileResult compile(const ctxCompileRequest &request)
gzBool compactRealization()
Retains semantic access and prepared CAL while releasing scalar construction objects.
gzBool installTrainer(ctxTrainer *trainer)
gzBool isCompactRealized() const
gzBool saveParameters(const gzString &url)
ctxArtifactIdentity getArtifactIdentity() const
ctxPropagateResult propagate(const ctxPropagateRequest &request)
gzString getError() const
ctxBuildRealization getBuildRealization() const
Returns an independent graph snapshot, or an invalid value before graph build.
gzBool setWeightedDropConnection(gzBool enabled, gzUInt64 &markedConnections)
Sets DropConnect on connected weighted synapses in the realized graph before compilation.
gzBool getParameter(const ctxParameterRef ¶meter, gzFloat &value)
ctxExecutionMode getExecutionMode() const
gzBool train(const ctxGeneticTrainingOptions &options)
gzBool monitor(const ctxValueRef &value)
virtual gzVoid debugChildren(const gzString &prefix, ctxModelDebugFlags flags) const override
gzBool compile(ctxOptimizeFlags optimize=CTX_OPTIMIZE_NONE)
friend class ctxGraphDocument
ctxBuildResult build(const ctxBuildRequest &request)
Immutable reusable graph with one explicit rank-one FLOAT Input and a whole final result,...
ctxShape getOutputShape() const
ctxValue operator()(const ctxValue &input, const gzString &prefix) const
The prefix is required; failure returns an invalid value with a diagnostic.
ctxShape getInputShape() const
gzString getError() const
ctxModule(const ctxGraph &graph, const ctxValue &output)
ctxLayerRef getLayer() const
gzUInt32 getFirstIndex() const
ctxNodeRef get(gzUInt32 index) const
ctxShape getShape() const
ctxGraphIdentity getGraphIdentity() const
friend class ctxConnectionRef
friend class ctxConvolutionMappingRef
ctxValueRef output() const
ctxLayerRef getLayer() const
friend class ctxConnectionRef
ctxGraphIdentity getGraphIdentity() const
gzUInt32 getOccurrenceID() const
ctxParameterRef bias() const
gzUInt32 getIndex() const
friend class ctxNodeRangeRef
ctxNodeRef get(gzUInt32 index) const
Owned immutable attributes for one operation occurrence.
gzBool getAttributes(gzDynamicTypeContainer &attributes) const
Copies attributes out; an invalid value preserves the caller's destination.
ctxOperationData(const gzDynamicTypeContainer &attributes)
gzString getDigest() const
SHA-256 of the canonical native packed container, or empty for no data.
gzString getError() const
Dependency-scoped registry revision: one captured immutable definition per graph occurrence,...
friend class ctxBuildIdentity
ctxOperationSchemaPtr getSchema(gzUInt32 index) const
ctxOperationRegistryRevision()
gzBool operator!=(const ctxOperationRegistryRevision &revision) const
gzBool operator==(const ctxOperationRegistryRevision &revision) const
Immutable operation contract and retained realization callbacks.
gzBool supportsDerivatives() const
gzBool validate(const ctxGraphOperation &operation, gzString &error) const
virtual gzBool useDeepCopy() override
ctxGraphOperationType getCompatibilityType() const
gzBool canSave() const
Whether the retained contract supports graph-only XML serialization.
gzUInt32 getVersion() const
gzBool supportsDeferredBuild() const
Whether the captured contract permits generic lowering after build.
ctxOperationSchema(const gzString &key, gzUInt32 version, ctxGraphOperationLowerer *operationLowerer, ctxGraphConnectionLowerer *connectionLowerer, gzBool derivatives)
virtual gzBool validateData(const ctxOperationData &data, gzString &error) const
Default contracts reject nonempty data; external definitions may opt in.
ctxGraphConnectionLowererPtr getConnectionLowerer() const
gzBool hasWeights() const
gzUInt32 getInputCount() const
Zero for Input, two for Add/Multiply, one for other compatibility contracts.
ctxGraphOperationLowererPtr getOperationLowerer() const
ctxOperationSchema(const gzString &key, gzUInt32 version, ctxGraphOperationType role, ctxGraphOperationLowerer *operationLowerer, ctxGraphConnectionLowerer *connectionLowerer, gzBool derivatives)
Explicit registered role: ACTIVATION, DENSE_FROM or CONVOLUTION_2D.
ctxValueType getValueType(ctxPortKind kind) const
gzBool getSemanticAttributes(const ctxGraphOperation &operation, gzDynamicTypeContainer &attributes) const
ctxShape getShape(const ctxGraphOperation &operation) const
gzString getPortName(ctxPortKind kind) const
Realization-local owner bindings for a named-parameter operation's flat native layer.
gzBool bindWeight(const gzString &role, gzUInt32 element, gzUInt32 neuron, gzUInt32 signal)
Binds one role element to a native ctxSynapseWeight; failure changes nothing.
virtual gzReference * clone() const override
gzBool bindBias(const gzString &role, gzUInt32 element, gzUInt32 neuron)
Binds one role element to a native neuron bias; failure changes nothing.
gzBool getParameterIndex(gzUInt32 role, gzUInt32 element, gzUInt32 &index) const
Resolves the current translated native owner; output is unchanged on failure.
ctxParameterLayer(ctxParameterOperationSchema *schema)
gzBool validateBindings(const ctxOperationSchema *schema, gzString &error) const
gzBool setParameterIndex(gzUInt32 role, gzUInt32 element, gzUInt32 index)
Used by semantic sharing before compilation, not a permanent bank binding.
Deferred rank-one unary FLOAT operation with a captured named parameter inventory.
gzUInt32 getRoleCount() const
ctxParameterOperationSchema(const gzString &key, gzUInt32 version, const gzArray< ctxParameterRole > &roles, ctxGraphOperationLowerer *operationLowerer, ctxGraphConnectionLowerer *connectionLowerer, gzBool derivatives)
ctxParameterRole getRole(gzUInt32 ordinal) const
gzBool hasValidInventory() const
gzUInt32 findRole(const gzString &name) const
ctxLayerRef getLayer() const
friend class ctxConvolutionMappingRef
friend class ctxParameterSlice
gzString getRoleName() const
Empty for builtin parameters; named elements use getSourceIndex as their flat index.
gzUInt32 getSourceIndex() const
gzUInt32 getDestinationIndex() const
friend class ctxConnectionRef
ctxParameterKind getKind() const
gzBool isSharedWith(const ctxParameterRef ¶meter) const
ctxGraphIdentity getGraphIdentity() const
One immutable named FLOAT parameter role; shapes are rank one or rank four.
ctxParameterRole(const gzString &name, const ctxShape &shape)
ctxShape getShape() const
gzBool isValid() const
Names contain 1..128 ASCII letters, digits, dots, underscores or hyphens.
ctxParameterRef get(gzUInt32 index) const
friend class ctxConvolutionMappingRef
ctxShape getShape() const
Named role shape; builtin slices expose their flattened element count.
friend class ctxConnectionRef
ctxGraphIdentity getGraphIdentity() const
ctxPortKind getKind() const
ctxGraphIdentity getGraphIdentity() const
ctxNodeRangeRef nodes() const
ctxShape getShape() const
ctxLayerRef getLayer() const
Immutable Backprop CAL-generation request tied to one compiled artifact.
ctxBackpropTrainingOptions getOptions() const
ctxExecutionProgram getProgram() const
ctxProgramProfile getProfile() const
ctxPropagateRequest(const ctxCompileResult &compile, const ctxBackpropTrainingOptions &options=ctxBackpropTrainingOptions())
ctxExecutionProgram getProgram() const
ctxArtifactIdentity getArtifactIdentity() const
ctxGraphIdentity getGraphIdentity() const
ctxLifecycleDiagnostic getDiagnostic() const
ctxProgramProfile getProfile() const
gzUInt32 getDimension(gzUInt32 index) const
ctxShape(gzUInt32 features, gzUInt32 width, gzUInt32 height, gzUInt32 depth)
gzUInt32 getElementCount() const
gzBool operator!=(const ctxShape &shape) const
gzBool operator==(const ctxShape &shape) const
Retained whole rank-one or rank-four gzFloat result of one graph revision.
ctxValueType getValueType() const
ctxPortRef getPort() const
ctxValueRef get(gzUInt32 index) const
friend ctxValue RmsNorm(const ctxValue &input, gzUInt32 axis, const gzString &name)
Per-page RMS normalization of a rank-four value along one explicit axis: authors "name/rstd" = Reduce...
gzBool getGraph(ctxGraph &graph) const
Binds directly to the retained state; failure leaves graph unchanged.
ctxGraphIdentity getGraphIdentity() const
ctxShape getShape() const
gzString getError() const
ctxNodeRef getNode() const
ctxGraphIdentity getGraphIdentity() const
@ CTX_NEURON_TYPE_DEFAULT
ctxLayer Input(gzUInt32 values)
ctxLayer ReduceSum()
Parameter-free whole-value sum to one rank-one FLOAT result.
@ CTX_EXECUTION_MODE_DEBUG
@ CTX_EXECUTION_MODE_PLAIN
@ CTX_EXECUTION_MODE_OPTIMIZED
@ CTX_PARAMETER_CONVOLUTION_WEIGHT
GZ_USE_BIT_LOGIC(ctxInstrumentationFlags)
@ CTX_INSTRUMENT_TRACE_POINTS
@ CTX_INSTRUMENT_GRAPH_IDENTITY
@ CTX_INSTRUMENT_VM_BACKEND_VERIFY
@ CTX_INSTRUMENT_REGISTER_IDENTITY
@ CTX_INSTRUMENT_SOURCE_CAL
@ CTX_INSTRUMENT_NUMERIC_CHECKS
ctxLayer Reshape(const ctxShape &shape)
Parameter-free rank-one/rank-four shape view preserving every flat value index.
ctxValue & operator+=(ctxValue &left, const ctxValue &right)
Assigns left + right and returns left; failure assigns the diagnostic invalid result.
ctxLifecycleSource
Identifies whether a lifecycle request originates from a graph revision or an already realized direct...
@ CTX_LIFECYCLE_SOURCE_NONE
@ CTX_LIFECYCLE_SOURCE_DIRECT_CORTEX
@ CTX_LIFECYCLE_SOURCE_GRAPH
ctxLayer ReduceInverseRms()
Parameter-free whole-value inverse root mean square to one rank-one FLOAT result: r = (sum(x*x)/N + C...
ctxLayer DenseFrom(gzUInt32 neurons, ctxNeuronType type=CTX_NEURON_TYPE_DEFAULT)
Full Dense projection from one explicitly selected whole rank-one FLOAT value.
@ CTX_LIFECYCLE_STAGE_COMPILE
@ CTX_LIFECYCLE_STAGE_PROPAGATE
@ CTX_LIFECYCLE_STAGE_NONE
@ CTX_LIFECYCLE_STAGE_BUILD
ctxLayer Convolution2D(ctxIndexControl source, ctxIndexControl filter, ctxNeuronType type=CTX_NEURON_TYPE_DEFAULT)
ctxLayer RegisteredOperation(const gzString &key, gzUInt32 version, gzUInt32 values)
Creates an occurrence with its captured unary or explicit full-projection role.
ctxValue operator*(const ctxValue &left, const ctxValue &right)
Calls Multiply over equal whole FLOAT values of one already-common revision.
ctxValue RmsNorm(const ctxValue &input, gzUInt32 axis, const gzString &name)
Per-page RMS normalization of a rank-four value along one explicit axis: authors "name/rstd" = Reduce...
ctxLayer ReduceMaximum()
Whole-value maximum; Backprop divides the derivative equally among ties.
@ CTX_GRAPH_OPERATION_DENSE_FROM
@ CTX_GRAPH_OPERATION_MULTIPLY
@ CTX_GRAPH_OPERATION_INPUT
@ CTX_GRAPH_OPERATION_ADD
@ CTX_GRAPH_OPERATION_OUTPUT
@ CTX_GRAPH_OPERATION_RESHAPE
@ CTX_GRAPH_OPERATION_REDUCE_PRODUCT
@ CTX_GRAPH_OPERATION_REDUCE_SUM
@ CTX_GRAPH_OPERATION_REDUCE_MEAN
@ CTX_GRAPH_OPERATION_DENSE
@ CTX_GRAPH_OPERATION_ACTIVATION
@ CTX_GRAPH_OPERATION_REDUCE_MAXIMUM
@ CTX_GRAPH_OPERATION_REDUCE_INVERSE_RMS
@ CTX_GRAPH_OPERATION_CONVOLUTION_2D
@ CTX_GRAPH_OPERATION_TRANSPOSE
ctxValueType
Element types of the supported retained graph-result contracts.
ctxLayer ReduceMean()
Parameter-free whole-value arithmetic mean to one rank-one FLOAT result.
ctxLayer MultiplyBroadcast(gzUInt32 axis)
Parameter-free product of a rank-four left value and a right value of the same shape except length on...
ctxValue & operator*=(ctxValue &left, const ctxValue &right)
Assigns left * right with the same retained-alias and invalid-result contract.
ctxLayer Dense(gzUInt32 neurons, ctxNeuronType type=CTX_NEURON_TYPE_DEFAULT)
@ CTX_LIFECYCLE_ERROR_FOREIGN_MODEL
@ CTX_LIFECYCLE_ERROR_NONE
@ CTX_LIFECYCLE_ERROR_PROPAGATE_FAILED
@ CTX_LIFECYCLE_ERROR_STALE_REVISION
@ CTX_LIFECYCLE_ERROR_INVALID_GRAPH
@ CTX_LIFECYCLE_ERROR_COMPILE_FAILED
@ CTX_LIFECYCLE_ERROR_PROFILE_MISMATCH
@ CTX_LIFECYCLE_ERROR_FOREIGN_GRAPH
@ CTX_LIFECYCLE_ERROR_INVALID_BINDING
@ CTX_LIFECYCLE_ERROR_BUILD_FAILED
@ CTX_LIFECYCLE_ERROR_INVALID_REQUEST
ctxLayer Output(gzUInt32 values, ctxNeuronType type=CTX_NEURON_TYPE_DEFAULT)
@ CTX_MODEL_DEBUG_DIAGNOSTICS
@ CTX_MODEL_DEBUG_TRAINER
@ CTX_MODEL_DEBUG_OPERATIONS
@ CTX_MODEL_DEBUG_SUMMARY
@ CTX_MODEL_DEBUG_CONTEXT
ctxLayer Multiply(gzUInt32 values)
Parameter-free element-wise product of two equal whole rank-one float values.
ctxHandleStatus
Describes why a graph-bound handle cannot be used with a graph revision.
@ CTX_HANDLE_STATUS_VALID
@ CTX_HANDLE_STATUS_OUT_OF_RANGE
@ CTX_HANDLE_STATUS_STALE_REVISION
@ CTX_HANDLE_STATUS_NOT_FOUND
@ CTX_HANDLE_STATUS_FOREIGN_GRAPH
@ CTX_HANDLE_STATUS_AMBIGUOUS
@ CTX_HANDLE_STATUS_EMPTY
@ CTX_HANDLE_STATUS_REMOVED
ctxLayer Activation(gzUInt32 values, const ctxActivation &activation)
ctxLayer Add(gzUInt32 values)
Parameter-free element-wise sum of two equal whole rank-one float values.
ctxGraphProjectionKind
Semantic projection kind; raw ctxGraphConnection::getSize remains ZIP-only.
@ CTX_GRAPH_PROJECTION_ZIP
@ CTX_GRAPH_PROJECTION_GROUPED_REDUCTION
@ CTX_GRAPH_PROJECTION_PERMUTATION
@ CTX_GRAPH_PROJECTION_BROADCAST
Each destination cell reads the source cell with its broadcast coordinate at zero.
@ CTX_GRAPH_PROJECTION_INVALID
@ CTX_GRAPH_PROJECTION_FULL
ctxLayer ReduceProduct()
Whole-value product; derivatives remain defined when operands are zero.
@ CTX_PROGRAM_PROFILE_BACKPROP
@ CTX_PROGRAM_PROFILE_EVALUATE_GENETIC
ctxBuildLayoutPolicy
Versioned logical scalar layout; cache readiness is not a layout change.
@ CTX_BUILD_LAYOUT_GENERIC_SCALAR_V1
@ CTX_BUILD_LAYOUT_INVALID
ctxActivation LeakyRelu()
ctxLayer Transpose(const ctxAxisOrder &axes)
Parameter-free rank-four permutation; axes use features/width/height/depth order.
ctxValue operator+(const ctxValue &left, const ctxValue &right)
Calls Add over equal whole FLOAT values of one already-common revision.
ctxProgramProfile profile
ctxInstrumentationFlags instrumentation
ctxOptimizeFlags optimize
gzUInt32 valueRegisterCount
gzUInt32 inputRegisterCount
ctxExecutionDiagnostics()
gzUInt32 checkedValueCount
ctxProgramType lastProgram
gzUInt32 vmBackendMismatchCount
gzFloat evaluationMilliseconds
gzUInt32 nonFiniteValueCount
gzUInt32 tempRegisterCount
gzUInt32 instructionCount
gzUInt32 connectionOccurrenceID
gzUInt32 mappingOccurrenceID
gzUInt32 parameterGroupID