CorTeX Core ABI 7
ToolTech Software · C++ library reference
Loading...
Searching...
No Matches
ctxGraph.h
Go to the documentation of this file.
1//*****************************************************************************
2// File : ctxGraph.h
3// Description : Object-oriented graph and expression authoring facade
4// Author : Anders Moden
5// Product : CorTeX
6//
7// Copyright (c) 2015- Anders Moden, Sweden
8//
9// Revision History...
10//
11// Who Date Description
12//
13// AMO 261115 Declare weighted DropConnect selection for realized graphs (2.0.20)
14// AMO 261114 Declare compact prepared realization and semantic runtime access (2.0.19)
15// AMO 261110 Declared inverse-RMS reduction, broadcast Multiply and atomic RmsNorm (2.0.18)
16// AMO 261109 Declared atomic batch sharing of parameter pairs (2.0.17)
17// AMO 261024 Declared immutable named FLOAT inventories and native coordinate bindings (2.0.16)
18// AMO 261024 Declared retained registered Convolution roles and checked control authoring (2.0.15)
19// AMO 261024 Declared immutable reusable graph modules without changing existing layouts (2.0.14)
20// AMO 261024 Owned compact origin snapshots and deferred public inspection under ABI6 (2.0.13)
21// AMO 261024 Declared registered full-projection parameter roles without layout changes (2.0.12)
22// AMO 261023 Added owned occurrence attributes and explicit schema validation (2.0.11)
23// AMO 261023 Added explicit retained-dimension reduction axes and grouped cells (2.0.10)
24// AMO 261023 Added explicit rank-four axis order and permutation-cell inspection (2.0.9)
25// AMO 261023 Added whole-value Sum/Mean/Maximum/Product reduction contracts (2.0.8)
26// AMO 261023 Added explicit whole-value rank-one/rank-four Reshape authoring (2.0.7)
27// AMO 261023 Added captured build identities and opt-in deferred custom contracts (2.0.6)
28// AMO 261023 Added compact build snapshots and lazy generic realization (2.0.5)
29// AMO 261020 Added retained Add and Multiply compound assignment (2.0.4)
30// AMO 261020 Added retained Add and Multiply expression overloads (2.0.3)
31// AMO 261020 Declared parameter-free whole-value Multiply authoring (2.0.2)
32// AMO 261020 Declared additive DenseFrom full-source authoring (2.0.1)
33// AMO 261019 Declared layout-preserving two-input Add authoring (2.0.1)
34// AMO 261019 Documented same-shaped captured unary replacement (2.0.1)
35// AMO 261017 Documented exact registered schema identity in graph-only XML8
36// AMO 261016 Granted retained documents access without changing object layout
37// AMO 261015 Added retained shaped values and atomic unary authoring
38// AMO 261015 Added pinned immutable operation schemas and unary registration
39// AMO 261016 Rename whole-session training to typed train overloads
40// AMO 260828 Added Generation 2 semantic graph resolution support
41// AMO 260828 Added Generation 2 identity and lifecycle API
42// AMO 260826 Fixed VS18 interface keyword compatibility
43// AMO 260823 Added common graph authoring facade
44//
45//*****************************************************************************
46#ifndef __CTX_GRAPH_H__
47#define __CTX_GRAPH_H__
48
49#include "ctxCortex.h"
50#include "ctxCortexTrainer.h"
51#include "gzXML.h"
52#include "gzDynamic.h"
53
72
74#define CTX_GRAPH_INVERSE_RMS_EPSILON 1.0e-6f
75
87
92{
93public:
94
96 CTX_EXPORT ctxGraphIdentity(gzUInt32 graphID, gzUInt32 revision);
97 CTX_EXPORT gzBool isValid() const;
98 CTX_EXPORT gzUInt32 getGraphID() const;
99 CTX_EXPORT gzUInt32 getRevision() const;
100 CTX_EXPORT gzBool operator==(const ctxGraphIdentity& identity) const;
101 CTX_EXPORT gzBool operator!=(const ctxGraphIdentity& identity) const;
102
103private:
104
105 friend class ctxGraph;
106 friend class ctxModel;
107 friend class ctxBuildRequest;
108
109 gzUInt32 m_graphID;
110 gzUInt32 m_revision;
111};
112
127
129{
130public:
131
134
135private:
136
137 ctxNeuronType m_type;
138};
139
144
146GZ_DECLARE_REFPTR(ctxOperationSchema);
147
148class ctxValue;
149class ctxModule;
150class ctxShape;
151class ctxAxisOrder;
152
160{
161public:
162
164 CTX_EXPORT explicit ctxOperationData(const gzDynamicTypeContainer& attributes);
165 CTX_EXPORT gzBool isValid() const;
166 CTX_EXPORT gzBool isEmpty() const;
167 CTX_EXPORT gzString getError() const;
169 CTX_EXPORT gzBool getAttributes(gzDynamicTypeContainer& attributes) const;
171 CTX_EXPORT gzString getDigest() const;
172
173private:
174
175 gzRefPointer<gzReference> m_state;
176};
177
179{
180public:
181
183 CTX_EXPORT ctxLayer named(const gzString& name) const;
185 CTX_EXPORT ctxLayer sharedBias(gzBool shared) const;
186 CTX_EXPORT ctxLayer debugFeatures(gzUInt32 features) const;
192 CTX_EXPORT ctxValue operator()(const ctxValue& left, const ctxValue& right) const;
193
194private:
195
196 friend class ctxGraph;
197 friend CTX_EXPORT ctxLayer Input(gzUInt32 values);
198 friend CTX_EXPORT ctxLayer Dense(gzUInt32 neurons, ctxNeuronType type);
199 friend CTX_EXPORT ctxLayer DenseFrom(gzUInt32 neurons, ctxNeuronType type);
200 friend CTX_EXPORT ctxLayer Activation(gzUInt32 values, const ctxActivation& activation);
201 friend CTX_EXPORT ctxLayer Add(gzUInt32 values);
202 friend CTX_EXPORT ctxLayer Multiply(gzUInt32 values);
203 friend CTX_EXPORT ctxLayer Reshape(const ctxShape& shape);
209 friend CTX_EXPORT ctxLayer ReduceSum(gzUInt32 axis);
210 friend CTX_EXPORT ctxLayer ReduceMean(gzUInt32 axis);
211 friend CTX_EXPORT ctxLayer ReduceMaximum(gzUInt32 axis);
212 friend CTX_EXPORT ctxLayer ReduceProduct(gzUInt32 axis);
214 friend CTX_EXPORT ctxLayer ReduceInverseRms(gzUInt32 axis);
215 friend CTX_EXPORT ctxLayer MultiplyBroadcast(gzUInt32 axis);
217 ctxNeuronType type);
218 friend CTX_EXPORT ctxLayer Output(gzUInt32 values, ctxNeuronType type);
219 friend CTX_EXPORT ctxLayer RegisteredOperation(const gzString& key, gzUInt32 version,
220 gzUInt32 values);
221 friend CTX_EXPORT ctxLayer RegisteredOperation(const gzString& key, gzUInt32 version,
222 ctxIndexControl source, ctxIndexControl filter);
223
225 gzString m_name;
226 ctxNeuronType m_neuronType;
227 gzUInt32 m_neurons;
228 ctxIndexControl m_source;
229 ctxIndexControl m_filter;
230 gzUInt32 m_maxDebugFeatures;
231 gzBool m_sharedBias;
232 ctxOperationSchemaPtr m_schema;
233 ctxOperationData m_data;
234};
235
239CTX_EXPORT ctxLayer Activation(gzUInt32 values, const ctxActivation& activation);
241CTX_EXPORT ctxLayer Add(gzUInt32 values);
243CTX_EXPORT ctxLayer Multiply(gzUInt32 values);
284CTX_EXPORT ctxValue RmsNorm(const ctxValue& input, gzUInt32 axis, const gzString& name);
285CTX_EXPORT ctxLayer Input(gzUInt32 values);
290CTX_EXPORT ctxLayer RegisteredOperation(const gzString& key, gzUInt32 version, gzUInt32 values);
292CTX_EXPORT ctxLayer RegisteredOperation(const gzString& key, gzUInt32 version,
293 ctxIndexControl source, ctxIndexControl filter);
294
313
315
316class ctxGraphOperationLowerer : public gzReference
317{
318public:
319
320 GZ_DECLARE_TYPE_INTERFACE_EXPORT(CTX_EXPORT);
321
322 CTX_EXPORT virtual gzBool useDeepCopy() override;
323 CTX_EXPORT virtual gzBool lower(const ctxGraphOperation& operation,
324 ctxGraphLoweringContext& context, gzString& error) = 0;
325};
326
327GZ_DECLARE_REFPTR(ctxGraphOperationLowerer);
328
329class ctxGraphConnectionLowerer : public gzReference
330{
331public:
332
333 GZ_DECLARE_TYPE_INTERFACE_EXPORT(CTX_EXPORT);
334
335 CTX_EXPORT virtual gzBool useDeepCopy() override;
336 CTX_EXPORT virtual gzBool lower(const ctxGraphOperation& operation,
337 ctxGraphLoweringContext& context, gzString& error) = 0;
338};
339
340GZ_DECLARE_REFPTR(ctxGraphConnectionLowerer);
341
350
357
364
366{
367public:
368
370 CTX_EXPORT explicit ctxShape(gzUInt32 size);
371 CTX_EXPORT ctxShape(gzUInt32 features, gzUInt32 width, gzUInt32 height, gzUInt32 depth);
372 CTX_EXPORT gzBool isValid() const;
373 CTX_EXPORT gzUInt32 getRank() const;
374 CTX_EXPORT gzUInt32 getDimension(gzUInt32 index) const;
375 CTX_EXPORT gzUInt32 getElementCount() const;
376 CTX_EXPORT gzBool operator==(const ctxShape& shape) const;
377 CTX_EXPORT gzBool operator!=(const ctxShape& shape) const;
378
379private:
380
381 gzUInt32 m_rank;
382 gzUInt32 m_dimensions[4];
383};
384
387{
388public:
389
390 CTX_EXPORT ctxAxisOrder(gzUInt32 features = 0, gzUInt32 width = 1,
391 gzUInt32 height = 2, gzUInt32 depth = 3);
392 CTX_EXPORT gzBool isValid() const;
393 CTX_EXPORT gzUInt32 getAxis(gzUInt32 outputDimension) const;
394
395private:
396
397 gzUInt32 m_axes[4];
398};
399
413class ctxOperationSchema : public gzReference
414{
415public:
416
417 GZ_DECLARE_TYPE_INTERFACE_EXPORT(CTX_EXPORT);
418
419 CTX_EXPORT ctxOperationSchema(const gzString& key, gzUInt32 version,
420 ctxGraphOperationLowerer* operationLowerer,
421 ctxGraphConnectionLowerer* connectionLowerer, gzBool derivatives);
423 CTX_EXPORT ctxOperationSchema(const gzString& key, gzUInt32 version,
424 ctxGraphOperationType role, ctxGraphOperationLowerer* operationLowerer,
425 ctxGraphConnectionLowerer* connectionLowerer, gzBool derivatives);
426 CTX_EXPORT virtual gzBool useDeepCopy() override;
427 CTX_EXPORT gzString getKey() const;
428 CTX_EXPORT gzUInt32 getVersion() const;
430 CTX_EXPORT gzBool isBuiltin() const;
432 CTX_EXPORT gzBool canSave() const;
436 CTX_EXPORT gzBool hasBias() const;
437 CTX_EXPORT gzBool hasWeights() const;
439 CTX_EXPORT gzUInt32 getInputCount() const;
440 CTX_EXPORT gzString getPortName(ctxPortKind kind) const;
444 gzDynamicTypeContainer& attributes) const;
445 CTX_EXPORT gzBool validate(const ctxGraphOperation& operation, gzString& error) const;
447 CTX_EXPORT virtual gzBool validateData(const ctxOperationData& data, gzString& error) const;
448 CTX_EXPORT ctxGraphOperationLowererPtr getOperationLowerer() const;
449 CTX_EXPORT ctxGraphConnectionLowererPtr getConnectionLowerer() const;
450
451private:
452
453 friend class ctxGraph;
454 ctxOperationSchema(const gzString& key, ctxGraphOperationType type,
455 ctxGraphOperationLowerer* operationLowerer,
456 ctxGraphConnectionLowerer* connectionLowerer);
458 ctxOperationSchema& operator=(const ctxOperationSchema&);
459
460 gzString m_key;
461 gzUInt32 m_version;
463 gzBool m_builtin;
464 gzBool m_derivatives;
465 ctxGraphOperationLowererPtr m_operationLowerer;
466 ctxGraphConnectionLowererPtr m_connectionLowerer;
467};
468
477{
478public:
479
480 GZ_DECLARE_TYPE_INTERFACE_EXPORT(CTX_EXPORT);
481
482 CTX_EXPORT ctxDeferredOperationSchema(const gzString& key, gzUInt32 version,
483 ctxGraphOperationLowerer* operationLowerer,
484 ctxGraphConnectionLowerer* connectionLowerer, gzBool derivatives);
485 CTX_EXPORT ctxDeferredOperationSchema(const gzString& key, gzUInt32 version,
486 ctxGraphOperationType role, ctxGraphOperationLowerer* operationLowerer,
487 ctxGraphConnectionLowerer* connectionLowerer, gzBool derivatives);
488};
489
490GZ_DECLARE_REFPTR(ctxDeferredOperationSchema);
491
494{
495public:
496
498 CTX_EXPORT ctxParameterRole(const gzString& name, const ctxShape& shape);
500 CTX_EXPORT gzBool isValid() const;
501 CTX_EXPORT gzString getName() const;
503
504private:
505
506 gzString m_name;
507 ctxShape m_shape;
508};
509
519{
520public:
521
522 GZ_DECLARE_TYPE_INTERFACE_EXPORT(CTX_EXPORT);
523
524 CTX_EXPORT ctxParameterOperationSchema(const gzString& key, gzUInt32 version,
525 const gzArray<ctxParameterRole>& roles, ctxGraphOperationLowerer* operationLowerer,
526 ctxGraphConnectionLowerer* connectionLowerer, gzBool derivatives);
528 CTX_EXPORT gzUInt32 getRoleCount() const;
529 CTX_EXPORT ctxParameterRole getRole(gzUInt32 ordinal) const;
530 CTX_EXPORT gzUInt32 findRole(const gzString& name) const;
531
532private:
533
534 gzArray<ctxParameterRole> m_roles;
535};
536
537GZ_DECLARE_REFPTR(ctxParameterOperationSchema);
538
547{
548public:
549
550 GZ_DECLARE_TYPE_INTERFACE_EXPORT(CTX_EXPORT);
551
554 CTX_EXPORT gzBool bindBias(const gzString& role, gzUInt32 element, gzUInt32 neuron);
556 CTX_EXPORT gzBool bindWeight(const gzString& role, gzUInt32 element,
557 gzUInt32 neuron, gzUInt32 signal);
558 CTX_EXPORT gzBool validateBindings(const ctxOperationSchema* schema, gzString& error) const;
560 CTX_EXPORT gzBool getParameterIndex(gzUInt32 role, gzUInt32 element, gzUInt32& index) const;
562 CTX_EXPORT gzBool setParameterIndex(gzUInt32 role, gzUInt32 element, gzUInt32 index);
563 CTX_EXPORT virtual gzReference* clone() const override;
564
565private:
566
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;
572};
573
574GZ_DECLARE_REFPTR(ctxParameterLayer);
575
592
607
650
654
655class ctxGraphState : public gzReference
656{
657public:
658
661 virtual gzBool useDeepCopy() override;
662
663 gzUInt32 graphID;
664 gzUInt32 revision;
667 gzUInt32 nextShareID;
670 gzRefPointer<ctxGraphState> parentState;
671 gzDynamicArray<ctxGraphOperation> operations;
672 gzDynamicArray<ctxGraphConnection> connections;
673 gzDynamicArray<ctxGraphParameterBinding> parameterBindings;
674 gzDynamicArray<ctxGraphConvolutionMapping> convolutionMappings;
675};
676
677class ctxGraph;
678class ctxLayerRefList;
679class ctxNodeRef;
680class ctxNodeRefList;
681class ctxNodeRangeRef;
682class ctxPortRef;
683class ctxValueRef;
684class ctxConnectionRef;
686class ctxParameterRef;
688
690{
691public:
692
694 CTX_EXPORT gzBool isValid() const;
697 CTX_EXPORT gzUInt32 getIndex() const;
698 CTX_EXPORT gzUInt32 getOccurrenceID() const;
699 CTX_EXPORT gzString getName() const;
702 CTX_EXPORT ctxOperationSchemaPtr getSchema() const;
703 CTX_EXPORT gzBool getSemanticAttributes(gzDynamicTypeContainer& attributes) const;
704 CTX_EXPORT gzUInt32 getNeuronCount() const;
706 CTX_EXPORT ctxNodeRef node(gzUInt32 index) const;
707 CTX_EXPORT ctxNodeRef node(gzUInt32 feature, gzUInt32 x, gzUInt32 y, gzUInt32 z = 0) const;
709 CTX_EXPORT ctxNodeRangeRef nodes(gzUInt32 first, gzUInt32 count) const;
714 CTX_EXPORT ctxParameterSlice parameters(const gzString& role) const;
718
719private:
720
721 friend class ctxGraph;
722 friend class ctxNodeRef;
723 friend class ctxNodeRangeRef;
724 friend class ctxPortRef;
725 friend class ctxConnectionRef;
727 friend class ctxParameterRef;
728 ctxLayerRef(ctxGraphState* state, gzUInt32 occurrenceID,
730
731 gzRefPointer<ctxGraphState> m_state;
732 gzUInt32 m_occurrenceID;
733 ctxHandleStatus m_status;
734};
735
737{
738public:
739
741 CTX_EXPORT ctxConvolutionMapping(const ctxLayerRef& source, gzUInt32 sourceFeatureIndex,
742 gzUInt32 sourceFeatureCount, gzUInt32 destinationFeatureIndex,
743 gzUInt32 destinationFeatureCount, gzUInt32 sourceWidth, gzUInt32 sourceHeight,
744 gzUInt32 sourceDepth, gzUInt32 kernelWidth, gzUInt32 kernelHeight, gzUInt32 kernelDepth = 1);
745 CTX_EXPORT ctxConvolutionMapping region(gzUInt32 width, gzUInt32 height, gzUInt32 depth = 1) const;
746 CTX_EXPORT ctxConvolutionMapping destinationOrigin(gzUInt32 x, gzUInt32 y, gzUInt32 z = 0) const;
747 CTX_EXPORT ctxConvolutionMapping origin(gzInt32 x, gzInt32 y, gzInt32 z = 0) const;
748 CTX_EXPORT ctxConvolutionMapping stride(gzUInt32 x, gzUInt32 y, gzUInt32 z = 1) const;
749 CTX_EXPORT ctxConvolutionMapping padding(gzUInt32 left, gzUInt32 right,
750 gzUInt32 top, gzUInt32 bottom, gzUInt32 front = 0, gzUInt32 back = 0) const;
751 CTX_EXPORT ctxConvolutionMapping dilation(gzUInt32 x, gzUInt32 y, gzUInt32 z = 1) const;
752
753private:
754
755 friend class ctxGraph;
756 ctxLayerRef m_source;
758};
759
761{
762public:
763
765 CTX_EXPORT gzBool isValid() const;
767 CTX_EXPORT gzUInt32 getOccurrenceID() const;
775 CTX_EXPORT ctxParameterSlice kernel(gzUInt32 sourceFeature, gzUInt32 destinationFeature) const;
776 CTX_EXPORT ctxParameterRef kernelWeight(gzUInt32 sourceFeature, gzUInt32 destinationFeature,
777 gzUInt32 x, gzUInt32 y, gzUInt32 z = 0) const;
778
779private:
780
781 friend class ctxGraph;
782 friend class ctxLayerRef;
784 ctxConvolutionMappingRef(ctxGraphState* state, gzUInt32 occurrenceID);
785 gzRefPointer<ctxGraphState> m_state;
786 gzUInt32 m_occurrenceID;
787};
788
790{
791public:
792
794 CTX_EXPORT gzUInt32 getSize() const;
796
797private:
798
799 friend class ctxLayerRef;
800 gzDynamicArray<ctxConvolutionMappingRef> m_mappings;
801};
802
804{
805public:
806
808 CTX_EXPORT gzUInt32 getSize() const;
809 CTX_EXPORT ctxLayerRef get(gzUInt32 index) const;
810
811private:
812
813 friend class ctxGraph;
814 gzDynamicArray<ctxLayerRef> m_layers;
815};
816
818{
819public:
820
822 CTX_EXPORT gzBool isValid() const;
825 CTX_EXPORT gzUInt32 getIndex() const;
826 CTX_EXPORT gzUInt32 getOccurrenceID() const;
829
830private:
831
832 friend class ctxLayerRef;
833 friend class ctxNodeRangeRef;
834 friend class ctxConnectionRef;
836 friend class ctxGraph;
837 friend class ctxModel;
838 ctxNodeRef(ctxGraphState* state, gzUInt32 occurrenceID, gzUInt32 nodeIndex);
839
840 gzRefPointer<ctxGraphState> m_state;
841 gzUInt32 m_occurrenceID;
842 gzUInt32 m_nodeIndex;
843};
844
846{
847public:
848
850 CTX_EXPORT gzUInt32 getSize() const;
851 CTX_EXPORT ctxNodeRef get(gzUInt32 index) const;
852
853private:
854
855 friend class ctxLayerRef;
856 gzDynamicArray<ctxNodeRef> m_nodes;
857};
858
860{
861public:
862
864 CTX_EXPORT gzBool isValid() const;
868 CTX_EXPORT gzUInt32 getFirstIndex() const;
869 CTX_EXPORT gzUInt32 getSize() const;
870 CTX_EXPORT ctxNodeRef get(gzUInt32 index) const;
871
872private:
873
874 friend class ctxLayerRef;
875 friend class ctxPortRef;
876 friend class ctxGraph;
877 friend class ctxConnectionRef;
878 ctxNodeRangeRef(ctxGraphState* state, gzUInt32 occurrenceID, gzUInt32 first, gzUInt32 count);
879
880 gzRefPointer<ctxGraphState> m_state;
881 gzUInt32 m_occurrenceID;
882 gzUInt32 m_first;
883 gzUInt32 m_count;
884};
885
887{
888public:
889
891 CTX_EXPORT gzBool isValid() const;
894 CTX_EXPORT gzString getName() const;
898
899private:
900
901 friend class ctxLayerRef;
902 friend class ctxGraph;
903 friend class ctxValue;
904 ctxPortRef(ctxGraphState* state, gzUInt32 occurrenceID, ctxPortKind kind);
905
906 gzRefPointer<ctxGraphState> m_state;
907 gzUInt32 m_occurrenceID;
908 ctxPortKind m_kind;
909};
910
912{
913public:
914
916 CTX_EXPORT gzBool isValid() const;
919
920private:
921
922 friend class ctxNodeRef;
923 friend class ctxGraph;
924 friend class ctxModel;
925 ctxValueRef(const ctxNodeRef& node);
926
927 ctxNodeRef m_node;
928};
929
936{
937public:
938
940 CTX_EXPORT gzBool isValid() const;
941 CTX_EXPORT gzString getError() const;
946 CTX_EXPORT ctxValueRef get(gzUInt32 index) const;
948 CTX_EXPORT gzBool getGraph(ctxGraph& graph) const;
949
950private:
951
952 friend class ctxGraph;
953 friend class ctxLayer;
954 friend class ctxModule;
955 friend CTX_EXPORT ctxValue RmsNorm(const ctxValue& input, gzUInt32 axis, const gzString& name);
956 explicit ctxValue(const ctxPortRef& port);
957 explicit ctxValue(const gzString& error);
958
959 ctxPortRef m_port;
960 gzString m_error;
961};
962
964CTX_EXPORT ctxValue operator+(const ctxValue& left, const ctxValue& right);
966CTX_EXPORT ctxValue operator*(const ctxValue& left, const ctxValue& right);
974
984{
985public:
986
988 CTX_EXPORT ctxModule(const ctxGraph& graph, const ctxValue& output);
989 CTX_EXPORT gzBool isValid() const;
990 CTX_EXPORT gzString getError() const;
994 CTX_EXPORT ctxValue operator()(const ctxValue& input, const gzString& prefix) const;
995
996private:
997
998 friend class ctxGraph;
999 gzRefPointer<ctxGraphState> m_state;
1000 ctxOperationSchemaPtr m_boundarySchema;
1001 gzString m_error;
1002};
1003
1005{
1006public:
1007
1009 CTX_EXPORT gzBool isValid() const;
1011 CTX_EXPORT gzUInt32 getOccurrenceID() const;
1020 CTX_EXPORT gzUInt32 getSize() const;
1023 CTX_EXPORT ctxParameterRef weight(gzUInt32 sourceIndex, gzUInt32 destinationIndex) const;
1024 CTX_EXPORT ctxParameterRef weight(const ctxNodeRef& source, const ctxNodeRef& destination) const;
1027 CTX_EXPORT ctxParameterSlice kernel(gzUInt32 sourceFeature, gzUInt32 filterFeature) const;
1028 CTX_EXPORT ctxParameterRef kernelWeight(gzUInt32 sourceFeature, gzUInt32 filterFeature,
1029 gzUInt32 x, gzUInt32 y, gzUInt32 z = 0) const;
1030
1031private:
1032
1033 friend class ctxGraph;
1034 friend class ctxLayerRef;
1035 ctxConnectionRef(ctxGraphState* state, gzUInt32 destinationOccurrenceID, gzUInt32 connectionID = 0);
1036
1037 gzRefPointer<ctxGraphState> m_state;
1038 gzUInt32 m_destinationOccurrenceID;
1039 gzUInt32 m_connectionID;
1040};
1041
1043{
1044public:
1045
1047 CTX_EXPORT gzUInt32 getSize() const;
1048 CTX_EXPORT ctxConnectionRef get(gzUInt32 index) const;
1049
1050private:
1051
1052 friend class ctxLayerRef;
1053 gzDynamicArray<ctxConnectionRef> m_connections;
1054};
1055
1057{
1058public:
1059
1061 CTX_EXPORT gzBool isValid() const;
1065 CTX_EXPORT gzUInt32 getSourceIndex() const;
1068 CTX_EXPORT gzString getRoleName() const;
1069 CTX_EXPORT gzBool isSharedWith(const ctxParameterRef& parameter) const;
1070
1071private:
1072
1073 friend class ctxNodeRef;
1074 friend class ctxConnectionRef;
1076 friend class ctxGraph;
1077 friend class ctxModel;
1078 friend class ctxParameterSlice;
1079 ctxParameterRef(ctxGraphState* state, ctxParameterKind kind, gzUInt32 occurrenceID,
1080 gzUInt32 connectionID, gzUInt32 sourceOccurrenceID, gzUInt32 sourceIndex, gzUInt32 destinationIndex);
1081
1082 gzRefPointer<ctxGraphState> m_state;
1083 ctxParameterKind m_kind;
1084 gzUInt32 m_occurrenceID;
1085 gzUInt32 m_connectionID;
1086 gzUInt32 m_sourceOccurrenceID;
1087 gzUInt32 m_sourceIndex;
1088 gzUInt32 m_destinationIndex;
1089};
1090
1092{
1093public:
1094
1098 CTX_EXPORT gzBool isValid() const;
1100 CTX_EXPORT gzUInt32 getSize() const;
1101 CTX_EXPORT ctxParameterRef get(gzUInt32 index) const;
1102
1103private:
1104
1105 friend class ctxLayerRef;
1106 friend class ctxConnectionRef;
1108 friend class ctxGraph;
1109 ctxParameterSlice(ctxGraphState* state, ctxParameterKind kind, gzUInt32 occurrenceID,
1110 gzUInt32 connectionID, gzUInt32 sourceOccurrenceID, gzUInt32 sourceCount,
1111 gzUInt32 destinationIndex, gzUInt32 destinationCount);
1112
1113 gzRefPointer<ctxGraphState> m_state;
1114 ctxParameterKind m_kind;
1115 gzUInt32 m_occurrenceID;
1116 gzUInt32 m_connectionID;
1117 gzUInt32 m_sourceOccurrenceID;
1118 gzUInt32 m_sourceCount;
1119 gzUInt32 m_destinationIndex;
1120 gzUInt32 m_destinationCount;
1121};
1122
1124{
1125public:
1126
1128
1130 CTX_EXPORT gzBool addInput(const gzString& path, gzUInt32 values);
1131 CTX_EXPORT gzBool addDense(const gzString& path, gzUInt32 neurons, ctxNeuronType type = CTX_NEURON_TYPE_DEFAULT);
1133 CTX_EXPORT gzBool addDenseFrom(const gzString& path, gzUInt32 neurons,
1134 const ctxPortRef& source, ctxNeuronType type = CTX_NEURON_TYPE_DEFAULT);
1135 CTX_EXPORT gzBool addActivation(const gzString& path, gzUInt32 values,
1138 CTX_EXPORT gzBool addAdd(const gzString& path, gzUInt32 values,
1139 const ctxPortRef& left, const ctxPortRef& right);
1141 CTX_EXPORT gzBool addMultiply(const gzString& path, gzUInt32 values,
1142 const ctxPortRef& left, const ctxPortRef& right);
1143 CTX_EXPORT gzBool addConvolution2D(const gzString& path, ctxIndexControl source, ctxIndexControl filter,
1144 ctxNeuronType type = CTX_NEURON_TYPE_DEFAULT, gzBool sharedBias = TRUE, gzUInt32 maxDebugFeatures = 0);
1145 CTX_EXPORT gzBool addOutput(const gzString& path, gzUInt32 values,
1147
1150 CTX_EXPORT const ctxGraphOperation* getOperation(gzUInt32 index) const;
1151 CTX_EXPORT const ctxGraphOperation* getOperationByID(gzUInt32 occurrenceID) const;
1152 CTX_EXPORT gzUInt32 getOperationIndex(gzUInt32 occurrenceID) const;
1153 CTX_EXPORT ctxLayerRef getLayer(gzUInt32 index) const;
1154 CTX_EXPORT ctxLayerRef layer(const gzString& name) const;
1156 CTX_EXPORT ctxLayerRefList layers(const gzString& name) const;
1157 CTX_EXPORT gzUInt32 getLayerCount(const gzString& name) const;
1165 CTX_EXPORT ctxValue value(const ctxPortRef& output) const;
1167 CTX_EXPORT gzBool apply(const ctxLayer& layer, const ctxValue& input, ctxValue& result);
1169 CTX_EXPORT gzBool apply(const ctxLayer& layer, const ctxValue& left,
1170 const ctxValue& right, ctxValue& result);
1175 CTX_EXPORT gzBool applyRmsNorm(const gzString& name, gzUInt32 axis,
1176 const ctxValue& input, ctxValue& result);
1178 CTX_EXPORT gzBool apply(const ctxModule& module, const gzString& prefix,
1179 const ctxValue& input, ctxValue& result);
1185 CTX_EXPORT ctxConnectionRef connect(const ctxNodeRef& source, const ctxNodeRef& destination);
1187 CTX_EXPORT ctxConnectionRef connect(const ctxPortRef& source, const ctxPortRef& destination);
1189 const ctxConvolutionMapping& mapping);
1191 const ctxConvolutionMapping& replacement);
1194 const ctxConvolutionMappingRef& second);
1195 CTX_EXPORT gzBool disconnect(const ctxConnectionRef& connection);
1200 CTX_EXPORT gzBool replace(const ctxLayerRef& layer, const ctxLayer& replacement);
1203 gzBool sharedBias = TRUE, gzUInt32 maxDebugFeatures = 0);
1204 CTX_EXPORT gzBool share(const ctxParameterRef& first, const ctxParameterRef& second);
1205 CTX_EXPORT gzBool share(const ctxParameterSlice& first, const ctxParameterSlice& second);
1207 CTX_EXPORT gzBool share(const gzArray<ctxParameterRef>& first, const gzArray<ctxParameterRef>& second);
1208 CTX_EXPORT gzBool unshare(const ctxParameterRef& parameter);
1211 CTX_EXPORT gzString getError() const;
1212 CTX_EXPORT gzBool save(const gzString& url) const;
1213 CTX_EXPORT static gzBool load(const gzString& url, ctxGraph& graph, gzString* error = NULL);
1214 CTX_EXPORT static gzBool registerXmlType(const gzString& elementName,
1215 gzXmlCustomDataInterface* customDataInterface, gzBool replace = FALSE);
1216 CTX_EXPORT static gzVoid unregisterXmlType(gzXmlCustomDataInterface* customDataInterface);
1218 ctxGraphOperationLowerer* lowerer, gzBool replace = FALSE);
1220 ctxGraphConnectionLowerer* lowerer, gzBool replace = FALSE);
1231 CTX_EXPORT static gzBool unregisterOperationSchema(const gzString& key, gzUInt32 version);
1232 CTX_EXPORT static ctxOperationSchemaPtr getOperationSchema(const gzString& key, gzUInt32 version);
1234 CTX_EXPORT static ctxOperationSchemaPtr getBuiltinSchema(ctxGraphOperationType type);
1235
1236private:
1237
1238 friend CTX_EXPORT ctxGraph operator+(const ctxLayer& left, const ctxLayer& right);
1239 friend CTX_EXPORT ctxGraph operator+(const ctxGraph& graph, const ctxLayer& layer);
1240 friend class ctxModel;
1241 friend class ctxValue;
1242 friend class ctxGraphDocument;
1243 friend class ctxModule;
1244
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;
1248 ctxGraphState* getState() const;
1249 gzVoid commitCandidate(ctxGraphState* candidate);
1250 gzVoid detach();
1251
1252 gzRefPointer<ctxGraphState> m_state;
1253 gzString m_error;
1254};
1255
1257{
1258public:
1259
1261 ctxInput* input, ctxOutput* output, gzDynamicArray<gzUInt32>& layerMapping);
1267 CTX_EXPORT ctxCortexLayer* getLayer(gzUInt32 occurrenceID) const;
1268 CTX_EXPORT gzBool addLayer(gzUInt32 occurrenceID, ctxCortexLayer* layer,
1269 gzString& error);
1270 CTX_EXPORT gzBool getConvolutionParameterBase(gzUInt32 parameterGroupID,
1271 gzUInt32 parameterCount, gzUInt32& parameterBase, gzString& error);
1272
1273private:
1274
1275 friend class ctxModel;
1276 const ctxGraphState* m_state;
1277 ctxCortex* m_cortex;
1278 ctxInput* m_input;
1279 ctxOutput* m_output;
1280 gzDynamicArray<gzUInt32>* m_layerMapping;
1281 gzDynamicArray<gzUInt32> m_convolutionParameterGroupIDs;
1282 gzDynamicArray<gzUInt32> m_convolutionParameterBases;
1283 gzDynamicArray<gzUInt32> m_convolutionParameterCounts;
1284};
1285
1287
1288CTX_EXPORT ctxGraph operator+(const ctxLayer& left, const ctxLayer& right);
1289CTX_EXPORT ctxGraph operator+(const ctxGraph& graph, const ctxLayer& layer);
1290
1296
1303
1314
1316
1326
1337
1345
1360
1365{
1366public:
1367
1371 CTX_EXPORT gzString getMessage() const;
1372
1373private:
1374
1375 friend class ctxModel;
1377 const gzString& message);
1378
1379 ctxLifecycleStage m_stage;
1380 ctxLifecycleError m_code;
1381 gzString m_message;
1382};
1383
1388{
1389public:
1390
1392 CTX_EXPORT gzBool isValid() const;
1395 CTX_EXPORT gzUInt32 getModelID() const;
1399 CTX_EXPORT gzBool operator==(const ctxArtifactIdentity& identity) const;
1400 CTX_EXPORT gzBool operator!=(const ctxArtifactIdentity& identity) const;
1401
1402private:
1403
1404 friend class ctxModel;
1405 ctxArtifactIdentity(ctxLifecycleSource source, const ctxGraphIdentity& graphIdentity,
1406 gzUInt32 modelID, gzUInt32 realizationID, gzUInt32 compilationID,
1407 gzUInt32 propagationID);
1408
1409 ctxLifecycleSource m_source;
1410 ctxGraphIdentity m_graphIdentity;
1411 gzUInt32 m_modelID;
1412 gzUInt32 m_realizationID;
1413 gzUInt32 m_compilationID;
1414 gzUInt32 m_propagationID;
1415};
1416
1423{
1424public:
1425
1427 CTX_EXPORT gzBool isValid() const;
1428 CTX_EXPORT gzUInt32 getSize() const;
1429 CTX_EXPORT ctxOperationSchemaPtr getSchema(gzUInt32 index) const;
1432
1433private:
1434
1435 friend class ctxBuildIdentity;
1437
1438 ctxGraph m_graph;
1439};
1440
1447
1470
1476{
1477public:
1478
1480 CTX_EXPORT gzBool isValid() const;
1484
1485private:
1486
1487 friend class ctxModel;
1488 ctxBuildRealization(const ctxGraph& graph, const ctxArtifactIdentity& identity);
1489
1490 ctxGraph m_graph;
1491 ctxArtifactIdentity m_identity;
1492};
1493
1498{
1499public:
1500
1505 ctxOutput* output, ctxNeuronType outputType = CTX_NEURON_TYPE_DEFAULT);
1516
1517private:
1518
1519 friend class ctxModel;
1520 ctxLifecycleSource m_source;
1521 ctxGraph m_graph;
1522 ctxInputPtr m_input;
1523 ctxOutputPtr m_output;
1524 ctxCortexPtr m_cortex;
1525 ctxNeuronType m_outputType;
1526};
1527
1529{
1530public:
1531
1533 CTX_EXPORT gzBool isSuccess() const;
1537
1538private:
1539
1540 friend class ctxModel;
1541 ctxBuildResult(gzBool success, const ctxArtifactIdentity& identity,
1542 const ctxLifecycleDiagnostic& diagnostic);
1543
1544 gzBool m_success;
1545 ctxArtifactIdentity m_identity;
1546 ctxLifecycleDiagnostic m_diagnostic;
1547};
1548
1553{
1554public:
1555
1557 CTX_EXPORT gzBool isValid() const;
1563
1564private:
1565
1566 friend class ctxModel;
1568 ctxExecutionMode mode, ctxInstrumentationFlags instrumentation,
1569 gzUInt32 programMask);
1570
1571 ctxArtifactIdentity m_identity;
1572 ctxProgramProfile m_profile;
1573 ctxExecutionMode m_mode;
1574 ctxInstrumentationFlags m_instrumentation;
1575 gzUInt32 m_programMask;
1576};
1577
1582{
1583public:
1584
1586 const ctxCompileOptions& options = ctxCompileOptions());
1588 const ctxCompileOptions& options = ctxCompileOptions());
1592
1593private:
1594
1595 friend class ctxModel;
1596 ctxArtifactIdentity m_buildIdentity;
1597 ctxCompileOptions m_options;
1598 gzBool m_valid;
1599};
1600
1602{
1603public:
1604
1606 CTX_EXPORT gzBool isSuccess() const;
1612
1613private:
1614
1615 friend class ctxModel;
1616 ctxCompileResult(gzBool success, const ctxExecutionProgram& program,
1617 const ctxLifecycleDiagnostic& diagnostic);
1618
1619 gzBool m_success;
1620 ctxExecutionProgram m_program;
1621 ctxLifecycleDiagnostic m_diagnostic;
1622};
1623
1644
1646{
1647public:
1648
1650 CTX_EXPORT gzBool isSuccess() const;
1656
1657private:
1658
1659 friend class ctxModel;
1660 ctxPropagateResult(gzBool success, const ctxExecutionProgram& program,
1661 const ctxLifecycleDiagnostic& diagnostic);
1662
1663 gzBool m_success;
1664 ctxExecutionProgram m_program;
1665 ctxLifecycleDiagnostic m_diagnostic;
1666};
1667
1684
1692
1718
1731
1733
1735{
1736public:
1737
1739 {
1740 }
1741
1743 CTX_EXPORT gzVoid debugRender(const gzString& prefix, gzBool last,
1744 ctxModelDebugFlags flags) const;
1745
1746protected:
1747
1748 virtual gzString getDebugNodeType() const = 0;
1749 virtual gzString getDebugNodeName() const = 0;
1750 virtual gzVoid debugProperties(const gzString& prefix,
1751 ctxModelDebugFlags flags) const = 0;
1752 virtual gzVoid debugChildren(const gzString& prefix,
1753 ctxModelDebugFlags flags) const = 0;
1754 CTX_EXPORT gzVoid debugProperty(const gzString& prefix, const gzString& name,
1755 const gzString& value) const;
1756};
1757
1758class ctxModel : public gzReference, public ctxModelDebugNode
1759{
1760public:
1761
1762 GZ_DECLARE_TYPE_INTERFACE_EXPORT(CTX_EXPORT);
1763
1766
1768 CTX_EXPORT gzBool build(const ctxGraph& graph, ctxInput* input, ctxOutput* output,
1776 CTX_EXPORT gzBool setWeightedDropConnection(gzBool enabled, gzUInt64& markedConnections);
1779 CTX_EXPORT gzBool compile(const ctxCompileOptions& options);
1782 gzUInt32 sample = 0, gzUInt32 pages = 1);
1783 CTX_EXPORT gzBool evaluate(gzUInt32 sample = 0, gzUInt32 pages = 1);
1789 CTX_EXPORT gzBool getParameter(const ctxParameterRef& parameter, gzFloat& value);
1790 CTX_EXPORT gzBool setParameter(const ctxParameterRef& parameter, gzFloat value);
1791 CTX_EXPORT gzBool getValue(const ctxValueRef& value, gzFloat& result, gzUInt32 page = 0);
1792 CTX_EXPORT gzBool monitor(const ctxValueRef& value);
1793 CTX_EXPORT gzBool isMonitored(const ctxValueRef& value) const;
1794 CTX_EXPORT gzBool saveParameters(const gzString& url);
1795 CTX_EXPORT gzBool loadParameters(const gzString& url);
1796
1817 CTX_EXPORT gzBool getExecutionTrace(gzDynamicArray<ctxExecutionTraceEntry>& trace) const;
1819 CTX_EXPORT gzBool getSemanticOrigins(gzDynamicArray<ctxSemanticOrigin>& origins) const;
1821 CTX_EXPORT gzBool mapOptimizedValueIndex(gzUInt32 sourceIndex, gzUInt32& optimizedIndex) const;
1825 CTX_EXPORT gzString getError() const;
1826 CTX_EXPORT virtual gzString getDebugNodeType() const override;
1827 CTX_EXPORT virtual gzString getDebugNodeName() const override;
1828 CTX_EXPORT virtual gzVoid debugProperties(const gzString& prefix,
1829 ctxModelDebugFlags flags) const override;
1830 CTX_EXPORT virtual gzVoid debugChildren(const gzString& prefix,
1831 ctxModelDebugFlags flags) const override;
1832
1833private:
1834
1835 friend class ctxGraphDocument;
1836
1837 gzBool buildInternal(const ctxGraph& graph, ctxInput* input, ctxOutput* output,
1838 ctxNeuronType outputType, gzBool isolateBindings);
1839 static gzBool stageGraphCortex(const ctxGraph& graph, ctxInput* input, ctxOutput* output,
1840 ctxNeuronType outputType, gzBool isolateBindings, gzBool materialize,
1841 ctxCortexPtr& cortex, gzDynamicArray<gzUInt32>& layerMapping, gzString& error);
1842 gzBool materializeGeneric() const;
1843 gzVoid completeBuild(ctxLifecycleSource source);
1844 gzBool compileInternal(const ctxCompileOptions& options);
1845 gzBool matches(const ctxArtifactIdentity& identity, gzBool requireCompilation,
1846 ctxLifecycleDiagnostic& diagnostic) const;
1847 gzBool applyParameterSharing();
1848 gzVoid releaseDirectCortex();
1849
1850 mutable ctxCortexPtr m_cortex;
1851 ctxTrainerPtr m_trainer;
1852 ctxOutputPtr m_buildOutputBinding;
1853 gzRefPointer<ctxGraphState> m_graphState;
1854 // A compact native build has no scalar mapping until generic materialization.
1855 mutable gzDynamicArray<gzUInt32> m_layerMapping;
1856 gzDynamicArray<ctxValueRef> m_monitoredValues;
1857 ctxProgramProfile m_programProfile;
1858 ctxExecutionMode m_executionMode;
1859 ctxInstrumentationFlags m_instrumentation;
1860 ctxExecutionDiagnostics m_executionDiagnostics;
1861 gzDynamicArray<ctxExecutionTraceEntry> m_executionTrace;
1862 gzRefPointer<gzReference> m_semanticOriginSnapshot;
1863 gzString m_signature;
1864 mutable gzString m_error;
1865 ctxLifecycleSource m_lifecycleSource;
1866 gzUInt32 m_modelID;
1867 gzUInt32 m_realizationID;
1868 gzUInt32 m_compilationID;
1869 gzUInt32 m_nextCompilationID;
1870 gzUInt32 m_propagationID;
1871};
1872
1873GZ_DECLARE_REFPTR(ctxModel);
1874
1875#endif //__CTX_GRAPH_H__
ctxActivation(ctxNeuronType type=CTX_NEURON_TYPE_DEFAULT)
ctxNeuronType getType() const
Exact association of a lifecycle artifact with one model and graph revision.
Definition ctxGraph.h:1388
ctxLifecycleSource getSource() const
gzUInt32 getPropagationID() const
gzBool isValid() const
gzBool operator==(const ctxArtifactIdentity &identity) const
gzBool operator!=(const ctxArtifactIdentity &identity) const
friend class ctxModel
Definition ctxGraph.h:1404
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.
Definition ctxGraph.h:387
ctxAxisOrder(gzUInt32 features=0, gzUInt32 width=1, gzUInt32 height=2, gzUInt32 depth=3)
gzUInt32 getAxis(gzUInt32 outputDimension) const
gzBool isValid() const
Exact build ownership, captured operation contracts and layout policy.
Definition ctxGraph.h:1450
gzBool isValid() const
ctxArtifactIdentity getArtifactIdentity() const
ctxBuildLayoutPolicy getLayoutPolicy() const
friend class ctxBuildRealization
Definition ctxGraph.h:1463
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.
Definition ctxGraph.h:1476
const ctxGraph & getGraph() const
ctxBuildIdentity getIdentity() const
friend class ctxModel
Definition ctxGraph.h:1487
ctxArtifactIdentity getArtifactIdentity() const
gzBool isValid() const
Immutable request to realize a graph revision or adapt a direct ctxCortex.
Definition ctxGraph.h:1498
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)
friend class ctxModel
Definition ctxGraph.h:1519
ctxOutput * getOutput() const
ctxNeuronType getOutputType() const
const ctxGraph & getGraph() const
ctxInput * getInput() const
ctxLifecycleDiagnostic getDiagnostic() const
ctxArtifactIdentity getArtifactIdentity() const
friend class ctxModel
Definition ctxGraph.h:1540
ctxGraphIdentity getGraphIdentity() const
gzBool isSuccess() const
Immutable compile request tied to one successful build result.
Definition ctxGraph.h:1582
ctxCompileRequest(const ctxBuildRealization &realization, const ctxCompileOptions &options=ctxCompileOptions())
ctxCompileOptions getOptions() const
ctxArtifactIdentity getBuildIdentity() const
ctxProgramProfile getProfile() const
friend class ctxModel
Definition ctxGraph.h:1595
ctxCompileRequest(const ctxBuildResult &build, const ctxCompileOptions &options=ctxCompileOptions())
ctxLifecycleDiagnostic getDiagnostic() const
gzBool isSuccess() const
ctxGraphIdentity getGraphIdentity() const
friend class ctxModel
Definition ctxGraph.h:1615
ctxExecutionProgram getProgram() const
ctxProgramProfile getProfile() const
ctxArtifactIdentity getArtifactIdentity() const
ctxNodeRef getSourceNode(gzUInt32 cell) const
Enumerates semantic projection cells, including permutations and reduction groups.
friend class ctxLayerRef
Definition ctxGraph.h:1034
ctxNodeRef getSourceNode() const
friend class ctxGraph
Definition ctxGraph.h:1033
gzUInt32 getSize() 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
gzBool isValid() const
friend class ctxLayerRef
Definition ctxGraph.h:1052
gzUInt32 getSize() const
ctxConnectionRef get(gzUInt32 index) const
friend class ctxGraph
Definition ctxGraph.h:755
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
friend class ctxLayerRef
Definition ctxGraph.h:782
friend class ctxGraph
Definition ctxGraph.h:781
gzBool isValid() const
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
Definition ctxGraph.h:783
ctxConvolutionMappingRef get(gzUInt32 index) const
Opt-in custom contract whose callbacks may run at first materialization.
Definition ctxGraph.h:477
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.
Definition ctxGraph.h:1553
ctxExecutionMode getMode() const
gzBool hasProgram(ctxProgramType type) const
ctxInstrumentationFlags getInstrumentation() const
friend class ctxModel
Definition ctxGraph.h:1566
ctxProgramProfile getProfile() const
ctxArtifactIdentity getArtifactIdentity() const
gzBool isValid() const
gzUInt32 sourceOccurrenceID
Definition ctxGraph.h:585
gzUInt32 occurrenceID
Definition ctxGraph.h:584
gzUInt32 sourceNodeIndex
Definition ctxGraph.h:586
gzUInt32 destinationNodeIndex
Definition ctxGraph.h:589
gzUInt32 getSize() const
Legacy ZIP-only size.
gzUInt32 sourceNodeCount
Definition ctxGraph.h:587
gzUInt32 destinationNodeCount
Definition ctxGraph.h:590
gzUInt32 destinationOccurrenceID
Definition ctxGraph.h:588
virtual gzBool useDeepCopy() override
virtual gzBool lower(const ctxGraphOperation &operation, ctxGraphLoweringContext &context, gzString &error)=0
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 &parameter)
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 &parameter) 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 class ctxModule
Definition ctxGraph.h:1243
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)
friend class ctxModel
Definition ctxGraph.h:1240
ctxConnectionRef connect(const ctxPortRef &source, const ctxPortRef &destination)
static ctxGraphOperationLowerer * getOperationLowerer(ctxGraphOperationType type)
ctxHandleStatus getHandleStatus(const ctxParameterSlice &parameters) const
ctxHandleStatus getHandleStatus(const ctxNodeRef &node) const
friend class ctxValue
Definition ctxGraph.h:1241
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.
gzBool validate()
gzString getCanonicalSignature() const
gzBool share(const ctxParameterSlice &first, const ctxParameterSlice &second)
gzBool replaceConvolutionMapping(const ctxConvolutionMappingRef &current, 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
Definition ctxGraph.h:1242
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.
Definition ctxGraph.h:92
friend class ctxGraph
Definition ctxGraph.h:105
gzUInt32 getGraphID() const
ctxGraphIdentity(gzUInt32 graphID, gzUInt32 revision)
gzBool operator!=(const ctxGraphIdentity &identity) const
friend class ctxModel
Definition ctxGraph.h:106
friend class ctxBuildRequest
Definition ctxGraph.h:107
gzBool operator==(const ctxGraphIdentity &identity) const
gzUInt32 getRevision() const
gzBool isValid() const
ctxCortex * getCortex() const
ctxCortexLayer * getLayer(gzUInt32 occurrenceID) const
ctxInput * getInput() const
gzBool getConvolutionParameterBase(gzUInt32 parameterGroupID, gzUInt32 parameterCount, gzUInt32 &parameterBase, gzString &error)
ctxOutput * getOutput() const
friend class ctxModel
Definition ctxGraph.h:1275
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
ctxOperationData data
Definition ctxGraph.h:311
gzUInt32 occurrenceID
Definition ctxGraph.h:309
ctxOperationSchemaPtr schema
Definition ctxGraph.h:310
ctxNeuronType neuronType
Definition ctxGraph.h:303
gzUInt32 neurons
Definition ctxGraph.h:304
gzUInt32 maxDebugFeatures
Definition ctxGraph.h:307
ctxIndexControl source
Definition ctxGraph.h:305
ctxIndexControl filter
Definition ctxGraph.h:306
ctxGraphOperationType type
Definition ctxGraph.h:301
virtual gzBool useDeepCopy() override
virtual gzBool lower(const ctxGraphOperation &operation, ctxGraphLoweringContext &context, gzString &error)=0
ctxParameterKind kind
Definition ctxGraph.h:599
ctxGraphState(const ctxGraphState &copy)
gzUInt32 nextMappingID
Definition ctxGraph.h:668
gzDynamicArray< ctxGraphOperation > operations
Definition ctxGraph.h:671
virtual gzBool useDeepCopy() override
gzRefPointer< ctxGraphState > parentState
Definition ctxGraph.h:670
gzDynamicArray< ctxGraphConnection > connections
Definition ctxGraph.h:672
gzUInt32 graphID
Definition ctxGraph.h:663
gzUInt32 nextConnectionID
Definition ctxGraph.h:666
gzDynamicArray< ctxGraphConvolutionMapping > convolutionMappings
Definition ctxGraph.h:674
gzDynamicArray< ctxGraphParameterBinding > parameterBindings
Definition ctxGraph.h:673
gzUInt32 nextMappingParameterGroupID
Definition ctxGraph.h:669
gzUInt32 nextOccurrenceID
Definition ctxGraph.h:665
gzUInt32 revision
Definition ctxGraph.h:664
gzUInt32 nextShareID
Definition ctxGraph.h:667
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 class ctxGraph
Definition ctxGraph.h:196
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
Definition ctxGraph.h:727
ctxOperationSchemaPtr getSchema() const
friend class ctxGraph
Definition ctxGraph.h:721
gzUInt32 getIndex() const
gzUInt32 getOccurrenceID() const
friend class ctxConvolutionMappingRef
Definition ctxGraph.h:726
ctxParameterSlice parameters(const gzString &role) const
Returns the complete captured named role, or an invalid slice for an unknown name.
ctxPortRef input() const
ctxNodeRef node(gzUInt32 feature, gzUInt32 x, gzUInt32 y, gzUInt32 z=0) const
gzUInt32 getNeuronCount() const
ctxParameterSlice biases() const
friend class ctxNodeRef
Definition ctxGraph.h:722
gzBool isValid() const
ctxPortRef output() const
ctxNodeRefList nodes() const
ctxNodeRef node(gzUInt32 index) const
friend class ctxConnectionRef
Definition ctxGraph.h:725
gzBool getSemanticAttributes(gzDynamicTypeContainer &attributes) const
ctxGraphOperationType getType() const
ctxConnectionRefList incomingConnections() const
gzString getName() const
ctxGraphIdentity getGraphIdentity() const
ctxNodeRangeRef nodes(gzUInt32 first, gzUInt32 count) const
ctxShape getShape() const
ctxHandleStatus getStatus() const
friend class ctxPortRef
Definition ctxGraph.h:724
ctxConvolutionMappingRefList convolutionMappings() const
friend class ctxNodeRangeRef
Definition ctxGraph.h:723
friend class ctxGraph
Definition ctxGraph.h:813
gzUInt32 getSize() const
ctxLayerRef get(gzUInt32 index) const
Structured diagnostic returned by Generation 2 lifecycle operations.
Definition ctxGraph.h:1365
ctxLifecycleError getCode() const
gzString getMessage() const
ctxLifecycleStage getStage() const
friend class ctxModel
Definition ctxGraph.h:1375
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()
Definition ctxGraph.h:1738
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)
virtual ~ctxModel()
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 &parameter, 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 &parameter, gzFloat &value)
ctxExecutionMode getExecutionMode() const
gzBool train(const ctxGeneticTrainingOptions &options)
gzBool monitor(const ctxValueRef &value)
gzBool train()
virtual gzVoid debugChildren(const gzString &prefix, ctxModelDebugFlags flags) const override
gzBool compile(ctxOptimizeFlags optimize=CTX_OPTIMIZE_NONE)
friend class ctxGraphDocument
Definition ctxGraph.h:1835
ctxBuildResult build(const ctxBuildRequest &request)
Immutable reusable graph with one explicit rank-one FLOAT Input and a whole final result,...
Definition ctxGraph.h:984
friend class ctxGraph
Definition ctxGraph.h:998
ctxShape getOutputShape() const
ctxValue operator()(const ctxValue &input, const gzString &prefix) const
The prefix is required; failure returns an invalid value with a diagnostic.
gzBool isValid() const
ctxShape getInputShape() const
gzString getError() const
ctxModule(const ctxGraph &graph, const ctxValue &output)
friend class ctxLayerRef
Definition ctxGraph.h:874
gzBool isValid() const
friend class ctxGraph
Definition ctxGraph.h:876
ctxLayerRef getLayer() const
gzUInt32 getSize() const
gzUInt32 getFirstIndex() const
ctxNodeRef get(gzUInt32 index) const
ctxShape getShape() const
ctxGraphIdentity getGraphIdentity() const
friend class ctxConnectionRef
Definition ctxGraph.h:877
friend class ctxPortRef
Definition ctxGraph.h:875
friend class ctxLayerRef
Definition ctxGraph.h:832
friend class ctxGraph
Definition ctxGraph.h:836
friend class ctxConvolutionMappingRef
Definition ctxGraph.h:835
ctxValueRef output() const
ctxLayerRef getLayer() const
gzBool isValid() const
friend class ctxConnectionRef
Definition ctxGraph.h:834
friend class ctxModel
Definition ctxGraph.h:837
ctxGraphIdentity getGraphIdentity() const
gzUInt32 getOccurrenceID() const
ctxParameterRef bias() const
gzUInt32 getIndex() const
friend class ctxNodeRangeRef
Definition ctxGraph.h:833
friend class ctxLayerRef
Definition ctxGraph.h:855
gzUInt32 getSize() const
ctxNodeRef get(gzUInt32 index) const
Owned immutable attributes for one operation occurrence.
Definition ctxGraph.h:160
gzBool isValid() const
gzBool isEmpty() const
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,...
Definition ctxGraph.h:1423
ctxOperationSchemaPtr getSchema(gzUInt32 index) const
gzBool operator!=(const ctxOperationRegistryRevision &revision) const
gzBool operator==(const ctxOperationRegistryRevision &revision) const
Immutable operation contract and retained realization callbacks.
Definition ctxGraph.h:414
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)
friend class ctxGraph
Definition ctxGraph.h:453
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
gzBool hasBias() const
gzString getPortName(ctxPortKind kind) const
gzString getKey() const
gzBool isBuiltin() const
Realization-local owner bindings for a named-parameter operation's flat native layer.
Definition ctxGraph.h:547
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.
Definition ctxGraph.h:519
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 ctxGraph
Definition ctxGraph.h:1076
friend class ctxConvolutionMappingRef
Definition ctxGraph.h:1075
friend class ctxParameterSlice
Definition ctxGraph.h:1078
gzString getRoleName() const
Empty for builtin parameters; named elements use getSourceIndex as their flat index.
gzUInt32 getSourceIndex() const
gzUInt32 getDestinationIndex() const
friend class ctxNodeRef
Definition ctxGraph.h:1073
friend class ctxConnectionRef
Definition ctxGraph.h:1074
ctxParameterKind getKind() const
friend class ctxModel
Definition ctxGraph.h:1077
gzBool isSharedWith(const ctxParameterRef &parameter) const
ctxGraphIdentity getGraphIdentity() const
gzBool isValid() const
One immutable named FLOAT parameter role; shapes are rank one or rank four.
Definition ctxGraph.h:494
ctxParameterRole(const gzString &name, const ctxShape &shape)
ctxShape getShape() const
gzBool isValid() const
Names contain 1..128 ASCII letters, digits, dots, underscores or hyphens.
gzString getName() const
friend class ctxLayerRef
Definition ctxGraph.h:1105
ctxParameterRef get(gzUInt32 index) const
friend class ctxGraph
Definition ctxGraph.h:1108
gzUInt32 getSize() const
friend class ctxConvolutionMappingRef
Definition ctxGraph.h:1107
gzBool isValid() const
ctxShape getShape() const
Named role shape; builtin slices expose their flattened element count.
friend class ctxConnectionRef
Definition ctxGraph.h:1106
ctxGraphIdentity getGraphIdentity() const
ctxPortKind getKind() const
friend class ctxLayerRef
Definition ctxGraph.h:901
ctxGraphIdentity getGraphIdentity() const
ctxNodeRangeRef nodes() const
friend class ctxGraph
Definition ctxGraph.h:902
ctxShape getShape() const
gzString getName() const
gzBool isValid() const
ctxLayerRef getLayer() const
friend class ctxValue
Definition ctxGraph.h:903
Immutable Backprop CAL-generation request tied to one compiled artifact.
Definition ctxGraph.h:1628
ctxBackpropTrainingOptions getOptions() const
ctxExecutionProgram getProgram() const
friend class ctxModel
Definition ctxGraph.h:1639
ctxProgramProfile getProfile() const
ctxPropagateRequest(const ctxCompileResult &compile, const ctxBackpropTrainingOptions &options=ctxBackpropTrainingOptions())
gzBool isSuccess() const
ctxExecutionProgram getProgram() const
ctxArtifactIdentity getArtifactIdentity() const
ctxGraphIdentity getGraphIdentity() const
friend class ctxModel
Definition ctxGraph.h:1659
ctxLifecycleDiagnostic getDiagnostic() const
ctxProgramProfile getProfile() const
gzBool isValid() const
gzUInt32 getDimension(gzUInt32 index) const
gzUInt32 getRank() const
ctxShape(gzUInt32 features, gzUInt32 width, gzUInt32 height, gzUInt32 depth)
ctxShape(gzUInt32 size)
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.
Definition ctxGraph.h:936
ctxValueType getValueType() const
friend class ctxGraph
Definition ctxGraph.h:952
ctxPortRef getPort() const
gzBool isValid() const
friend class ctxModule
Definition ctxGraph.h:954
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.
friend class ctxLayer
Definition ctxGraph.h:953
ctxGraphIdentity getGraphIdentity() const
ctxShape getShape() const
gzString getError() const
friend class ctxGraph
Definition ctxGraph.h:923
gzBool isValid() const
ctxNodeRef getNode() const
friend class ctxNodeRef
Definition ctxGraph.h:922
ctxGraphIdentity getGraphIdentity() const
friend class ctxModel
Definition ctxGraph.h:924
#define CTX_EXPORT
Definition ctxBase.h:68
ctxNeuronType
@ CTX_NEURON_TYPE_DEFAULT
ctxLayer Input(gzUInt32 values)
ctxLayer ReduceSum()
Parameter-free whole-value sum to one rank-one FLOAT result.
ctxActivation Relu()
ctxExecutionMode
Definition ctxGraph.h:1298
@ CTX_EXECUTION_MODE_DEBUG
Definition ctxGraph.h:1299
@ CTX_EXECUTION_MODE_PLAIN
Definition ctxGraph.h:1300
@ CTX_EXECUTION_MODE_OPTIMIZED
Definition ctxGraph.h:1301
ctxParameterKind
Definition ctxGraph.h:343
@ CTX_PARAMETER_CONVOLUTION_WEIGHT
Definition ctxGraph.h:347
@ CTX_PARAMETER_INVALID
Definition ctxGraph.h:344
@ CTX_PARAMETER_NAMED
Definition ctxGraph.h:348
@ CTX_PARAMETER_WEIGHT
Definition ctxGraph.h:345
@ CTX_PARAMETER_BIAS
Definition ctxGraph.h:346
GZ_USE_BIT_LOGIC(ctxInstrumentationFlags)
ctxInstrumentationFlags
Definition ctxGraph.h:1305
@ CTX_INSTRUMENT_TRACE_POINTS
Definition ctxGraph.h:1311
@ CTX_INSTRUMENT_GRAPH_IDENTITY
Definition ctxGraph.h:1308
@ CTX_INSTRUMENT_VM_BACKEND_VERIFY
Definition ctxGraph.h:1312
@ CTX_INSTRUMENT_REGISTER_IDENTITY
Definition ctxGraph.h:1309
@ CTX_INSTRUMENT_SOURCE_CAL
Definition ctxGraph.h:1307
@ CTX_INSTRUMENT_NONE
Definition ctxGraph.h:1306
@ CTX_INSTRUMENT_NUMERIC_CHECKS
Definition ctxGraph.h:1310
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...
Definition ctxGraph.h:1332
@ CTX_LIFECYCLE_SOURCE_NONE
Definition ctxGraph.h:1333
@ CTX_LIFECYCLE_SOURCE_DIRECT_CORTEX
Definition ctxGraph.h:1335
@ CTX_LIFECYCLE_SOURCE_GRAPH
Definition ctxGraph.h:1334
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.
ctxLifecycleStage
Definition ctxGraph.h:1339
@ CTX_LIFECYCLE_STAGE_COMPILE
Definition ctxGraph.h:1342
@ CTX_LIFECYCLE_STAGE_PROPAGATE
Definition ctxGraph.h:1343
@ CTX_LIFECYCLE_STAGE_NONE
Definition ctxGraph.h:1340
@ CTX_LIFECYCLE_STAGE_BUILD
Definition ctxGraph.h:1341
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.
ctxGraph ctxGraf
Definition ctxGraph.h:1286
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...
ctxActivation Tanh()
ctxLayer ReduceMaximum()
Whole-value maximum; Backprop divides the derivative equally among ties.
ctxGraphOperationType
Definition ctxGraph.h:55
@ CTX_GRAPH_OPERATION_DENSE_FROM
Definition ctxGraph.h:62
@ CTX_GRAPH_OPERATION_MULTIPLY
Definition ctxGraph.h:63
@ CTX_GRAPH_OPERATION_INPUT
Definition ctxGraph.h:56
@ CTX_GRAPH_OPERATION_ADD
Definition ctxGraph.h:61
@ CTX_GRAPH_OPERATION_OUTPUT
Definition ctxGraph.h:59
@ CTX_GRAPH_OPERATION_RESHAPE
Definition ctxGraph.h:64
@ CTX_GRAPH_OPERATION_REDUCE_PRODUCT
Definition ctxGraph.h:68
@ CTX_GRAPH_OPERATION_REDUCE_SUM
Definition ctxGraph.h:65
@ CTX_GRAPH_OPERATION_REDUCE_MEAN
Definition ctxGraph.h:66
@ CTX_GRAPH_OPERATION_DENSE
Definition ctxGraph.h:57
@ CTX_GRAPH_OPERATION_ACTIVATION
Definition ctxGraph.h:60
@ CTX_GRAPH_OPERATION_REDUCE_MAXIMUM
Definition ctxGraph.h:67
@ CTX_GRAPH_OPERATION_REDUCE_INVERSE_RMS
Definition ctxGraph.h:70
@ CTX_GRAPH_OPERATION_CONVOLUTION_2D
Definition ctxGraph.h:58
@ CTX_GRAPH_OPERATION_TRANSPOSE
Definition ctxGraph.h:69
ctxValueType
Element types of the supported retained graph-result contracts.
Definition ctxGraph.h:360
@ CTX_VALUE_TYPE_INVALID
Definition ctxGraph.h:361
@ CTX_VALUE_TYPE_FLOAT
Definition ctxGraph.h:362
ctxPortKind
Definition ctxGraph.h:352
@ CTX_PORT_OUTPUT
Definition ctxGraph.h:355
@ CTX_PORT_INPUT
Definition ctxGraph.h:354
@ CTX_PORT_INVALID
Definition ctxGraph.h:353
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)
ctxLifecycleError
Definition ctxGraph.h:1347
@ CTX_LIFECYCLE_ERROR_FOREIGN_MODEL
Definition ctxGraph.h:1352
@ CTX_LIFECYCLE_ERROR_NONE
Definition ctxGraph.h:1348
@ CTX_LIFECYCLE_ERROR_PROPAGATE_FAILED
Definition ctxGraph.h:1358
@ CTX_LIFECYCLE_ERROR_STALE_REVISION
Definition ctxGraph.h:1354
@ CTX_LIFECYCLE_ERROR_INVALID_GRAPH
Definition ctxGraph.h:1350
@ CTX_LIFECYCLE_ERROR_COMPILE_FAILED
Definition ctxGraph.h:1357
@ CTX_LIFECYCLE_ERROR_PROFILE_MISMATCH
Definition ctxGraph.h:1355
@ CTX_LIFECYCLE_ERROR_FOREIGN_GRAPH
Definition ctxGraph.h:1353
@ CTX_LIFECYCLE_ERROR_INVALID_BINDING
Definition ctxGraph.h:1351
@ CTX_LIFECYCLE_ERROR_BUILD_FAILED
Definition ctxGraph.h:1356
@ CTX_LIFECYCLE_ERROR_INVALID_REQUEST
Definition ctxGraph.h:1349
ctxActivation Linear()
ctxLayer Output(gzUInt32 values, ctxNeuronType type=CTX_NEURON_TYPE_DEFAULT)
ctxModelDebugFlags
Definition ctxGraph.h:1720
@ CTX_MODEL_DEBUG_DIAGNOSTICS
Definition ctxGraph.h:1728
@ CTX_MODEL_DEBUG_TRAINER
Definition ctxGraph.h:1727
@ CTX_MODEL_DEBUG_NONE
Definition ctxGraph.h:1721
@ CTX_MODEL_DEBUG_CORTEX
Definition ctxGraph.h:1725
@ CTX_MODEL_DEBUG_GRAPH
Definition ctxGraph.h:1723
@ CTX_MODEL_DEBUG_ALL
Definition ctxGraph.h:1729
@ CTX_MODEL_DEBUG_OPERATIONS
Definition ctxGraph.h:1724
@ CTX_MODEL_DEBUG_SUMMARY
Definition ctxGraph.h:1722
@ CTX_MODEL_DEBUG_CONTEXT
Definition ctxGraph.h:1726
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.
Definition ctxGraph.h:117
@ CTX_HANDLE_STATUS_VALID
Definition ctxGraph.h:118
@ CTX_HANDLE_STATUS_OUT_OF_RANGE
Definition ctxGraph.h:122
@ CTX_HANDLE_STATUS_STALE_REVISION
Definition ctxGraph.h:124
@ CTX_HANDLE_STATUS_NOT_FOUND
Definition ctxGraph.h:120
@ CTX_HANDLE_STATUS_FOREIGN_GRAPH
Definition ctxGraph.h:123
@ CTX_HANDLE_STATUS_AMBIGUOUS
Definition ctxGraph.h:121
@ CTX_HANDLE_STATUS_EMPTY
Definition ctxGraph.h:119
@ CTX_HANDLE_STATUS_REMOVED
Definition ctxGraph.h:125
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.
Definition ctxGraph.h:78
@ CTX_GRAPH_PROJECTION_ZIP
Definition ctxGraph.h:80
@ CTX_GRAPH_PROJECTION_GROUPED_REDUCTION
Definition ctxGraph.h:83
@ CTX_GRAPH_PROJECTION_PERMUTATION
Definition ctxGraph.h:82
@ CTX_GRAPH_PROJECTION_BROADCAST
Each destination cell reads the source cell with its broadcast coordinate at zero.
Definition ctxGraph.h:85
@ CTX_GRAPH_PROJECTION_INVALID
Definition ctxGraph.h:79
@ CTX_GRAPH_PROJECTION_FULL
Definition ctxGraph.h:81
ctxLayer ReduceProduct()
Whole-value product; derivatives remain defined when operands are zero.
ctxProgramProfile
Definition ctxGraph.h:1292
@ CTX_PROGRAM_PROFILE_BACKPROP
Definition ctxGraph.h:1294
@ CTX_PROGRAM_PROFILE_EVALUATE_GENETIC
Definition ctxGraph.h:1293
ctxBuildLayoutPolicy
Versioned logical scalar layout; cache readiness is not a layout change.
Definition ctxGraph.h:1443
@ CTX_BUILD_LAYOUT_GENERIC_SCALAR_V1
Definition ctxGraph.h:1445
@ CTX_BUILD_LAYOUT_INVALID
Definition ctxGraph.h:1444
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.
ctxProgramType
Definition ctxTypes.h:91
ctxOptimizeFlags
@ CTX_OPTIMIZE_NONE
ctxProgramProfile profile
Definition ctxGraph.h:1321
ctxInstrumentationFlags instrumentation
Definition ctxGraph.h:1324
ctxExecutionMode mode
Definition ctxGraph.h:1322
ctxOptimizeFlags optimize
Definition ctxGraph.h:1323
ctxProgramType lastProgram
Definition ctxGraph.h:1671
gzUInt32 vmBackendMismatchCount
Definition ctxGraph.h:1675
gzUInt32 instructionCount
Definition ctxGraph.h:1688
ctxProgramType program
Definition ctxGraph.h:1687
ctxExecutionTraceEntry()
gzUInt32 connectionOccurrenceID
Definition ctxGraph.h:1711
gzUInt32 occurrenceID
Definition ctxGraph.h:1706
gzUInt32 sourceIndex
Definition ctxGraph.h:1708
gzUInt32 nodeIndex
Definition ctxGraph.h:1707
ctxProgramType program
Definition ctxGraph.h:1712
gzUInt32 mappingOccurrenceID
Definition ctxGraph.h:1709
gzUInt32 startIndex
Definition ctxGraph.h:1713
gzUInt32 parameterGroupID
Definition ctxGraph.h:1710