@@ -826,6 +826,23 @@ def _eval_expressions(self, symbol_table: dict[str, Any], *args, **kwargs):
826826 return evaluated , symbol_table
827827
828828
829+ class Adapter (EvalableModel ):
830+ """
831+ An adapter between or before (in the case of shared inputs) two or more
832+ Einsums.
833+ """
834+ name : EvalsTo [str ]
835+
836+ adapter_class : EvalsTo [str ]
837+ """
838+ The class of the adapter. Supported classes are:
839+ - copy
840+ - collective
841+ """
842+
843+ tensor : EvalsTo [str ]
844+
845+
829846class Workload (EvalableModel ):
830847 """
831848 The workload specification as a cascade of Einsums, with each Einsum being a
@@ -874,6 +891,11 @@ class Workload(EvalableModel):
874891 matching tensors as persistent. Example: "weight" or "~(Outputs | Intermediates)".
875892 """
876893
894+ adapters : EvalableList [Adapter ] = EvalableList ()
895+ """
896+ Adapters for shared tensors.
897+ """
898+
877899 def _for_einsum (self , einsum_name : EinsumName ) -> "Workload" :
878900 """Return a copy of the workload with only the Einsum with the given name."""
879901 new = self .model_copy (deep = False )
@@ -1312,3 +1334,9 @@ def get_compute_intensity(self, einsum_name: str) -> float:
13121334 self .get_tensor_size (tensor )
13131335 for tensor in self .einsums [einsum_name ].tensor_names
13141336 )
1337+
1338+ def get_adapter_for (self , tensor_name : TensorName ) -> Adapter :
1339+ for adapter in self .adapters :
1340+ if adapter .tensor == tensor_name :
1341+ return adapter
1342+ return ValueError (f"No adapter found for tensor { tensor_name } " )
0 commit comments