MCPcopy Index your code
hub / github.com/OpenPPL/ppq / OperationMeta

Class OperationMeta

ppq/core/data.py:175–222  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

173
174
175class OperationMeta:
176 def __init__(self,
177 input_metas: List[TensorMeta], output_metas: List[TensorMeta],
178 operation_name: str, operation_type: str, executing_order: int) -> None:
179 """OperationMeta structure describes all related tensor metadata of an
180 operation.
181
182 It naturally is a collection of TensorMeta.
183 Take a look at TensorMeta to get more information.
184 Args:
185 input_metas (List[TensorMeta]):
186 A collection contains all input tensors' metadata.
187 ATTENTION: All parameters are considered as input in PPQ.
188 output_metas (List[TensorMeta]):
189 A collection contains all output tensors' metadata.
190 operation_name (str): Not yet used.
191 operation_type (str): Not yet used.
192 executing_order (int): a int value represents the executing order of this operation.
193 (order 0 means this operation is the first operation to be executed)
194 """
195 assert isinstance(input_metas, list), 'can only accept list object here.'
196 assert isinstance(output_metas, list), 'can only accept list object here.'
197
198 self.input_metas = input_metas
199 self.output_metas = output_metas
200
201 self.operation_name = operation_name
202 self.operation_type = operation_type
203 self.executing_order = executing_order
204
205 def __str__(self) -> str:
206 return 'Inputs: '.join(str([_ for _ in self.input_metas])) + \
207 'Outputs: '.join(str([_ for _ in self.input_metas]))
208
209 @ property
210 def num_of_input(self):
211 return len(self.input_metas)
212
213 @ property
214 def num_of_output(self):
215 return len(self.output_metas)
216
217 def copy(self):
218 return OperationMeta(
219 input_metas = [meta.copy() for meta in self.input_metas],
220 output_metas = [meta.copy() for meta in self.output_metas],
221 operation_name=self.operation_name, operation_type=self.operation_type,
222 executing_order=self.executing_order)
223
224
225def convert_any_to_python_primary_type(

Callers 1

copyMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected