Module furiosa.quantizer.furiosa_sdk_quantizer.interfaces.export_spec
Expand source code
from typing import List, Set, IO, Text
import collections
import yaml
from yaml import representer
from furiosa_sdk_quantizer.ir import spec
class ExportSpec:
def export(self) -> (List[spec.Spec], Set[str], Set[str]):
"""
Returns list of spec, list of supported op, list of unsupported op
"""
raise NotImplementedError()
def dump(self, output: IO[Text]):
specs, unsupported_ops = self.export()
if len(unsupported_ops) > 0:
raise Exception(f'You must add unsupported ops to operator spec: {unsupported_ops}')
specs = list(map(lambda s: s.as_dict(), specs))
# To remove process_tag (class name with '!!')
def noop(*args, **kwargs):
pass
yaml.emitter.Emitter.process_tag = noop
yaml.add_representer(collections.defaultdict, representer.Representer.represent_dict)
yaml.dump(specs, output, default_flow_style=False, sort_keys=False)
Classes
class ExportSpec
-
Expand source code
class ExportSpec: def export(self) -> (List[spec.Spec], Set[str], Set[str]): """ Returns list of spec, list of supported op, list of unsupported op """ raise NotImplementedError() def dump(self, output: IO[Text]): specs, unsupported_ops = self.export() if len(unsupported_ops) > 0: raise Exception(f'You must add unsupported ops to operator spec: {unsupported_ops}') specs = list(map(lambda s: s.as_dict(), specs)) # To remove process_tag (class name with '!!') def noop(*args, **kwargs): pass yaml.emitter.Emitter.process_tag = noop yaml.add_representer(collections.defaultdict, representer.Representer.represent_dict) yaml.dump(specs, output, default_flow_style=False, sort_keys=False)
Methods
def dump(self, output: IO[str])
-
Expand source code
def dump(self, output: IO[Text]): specs, unsupported_ops = self.export() if len(unsupported_ops) > 0: raise Exception(f'You must add unsupported ops to operator spec: {unsupported_ops}') specs = list(map(lambda s: s.as_dict(), specs)) # To remove process_tag (class name with '!!') def noop(*args, **kwargs): pass yaml.emitter.Emitter.process_tag = noop yaml.add_representer(collections.defaultdict, representer.Representer.represent_dict) yaml.dump(specs, output, default_flow_style=False, sort_keys=False)
def export(self) ‑> (typing.List[furiosa_sdk_quantizer.ir.spec.Spec], typing.Set[str], typing.Set[str])
-
Returns list of spec, list of supported op, list of unsupported op
Expand source code
def export(self) -> (List[spec.Spec], Set[str], Set[str]): """ Returns list of spec, list of supported op, list of unsupported op """ raise NotImplementedError()