MCPcopy
hub / github.com/OpenPPL/ppq / format_cast

Method format_cast

ppq/IR/morph.py:317–326  ·  view source on GitHub ↗

cast op 的参数 to 默认为 int,使用该函数将其封装为 ppq.core.DataType.

(self)

Source from the content-addressed store, hash-verified

315 operation.attributes.pop('indices')
316
317 def format_cast(self) -> None:
318 """cast op 的参数 to 默认为 int,使用该函数将其封装为 ppq.core.DataType."""
319 interested_ops = []
320 for _, operation in self.graph.operations.items():
321 assert isinstance(operation, Operation)
322 if operation.type == 'Cast': interested_ops.append(operation)
323 for operation in interested_ops:
324 assert isinstance(operation, Operation)
325 assert 'to' in operation.attributes
326 operation.attributes['to'] = DataType.convert_from_numpy(operation.attributes['to'])
327
328 def format_int64_constant(self) -> None:
329 """convert all int64 constants to int32, check if direct dtype cast is

Callers 1

processMethod · 0.95

Calls 2

convert_from_numpyMethod · 0.80
appendMethod · 0.45

Tested by

no test coverage detected