Module furiosa.quantizer.frontend.onnx.transformer.polish_model
Expand source code
import onnx
from furiosa_sdk_quantizer.frontend.onnx.transformer.extract_constant_to_initializer import ExtractConstantToInitializer
from furiosa_sdk_quantizer.frontend.onnx.transformer.convert_clip_attr_to_input import ConvertClipAttrToInput
from furiosa_sdk_quantizer.frontend.onnx.transformer.convert_2d_sum_to_add import Convert2dSumToAdd
from furiosa_sdk_quantizer.frontend.onnx.utils.inference_shape import InferenceShape
from furiosa_sdk_quantizer.frontend.onnx.transformer import utils
from furiosa_sdk_quantizer.interfaces.transformer import Transformer
class PolishModel(Transformer[onnx.ModelProto]):
"""
Essential graph transformer/optimizers
"""
def transform(self, model: onnx.ModelProto) -> onnx.ModelProto:
model = utils.name_nodes(model)
model = utils.make_conv_bias_name_unique(model)
model = utils.fix_batch_size_as_one(model)
model = ExtractConstantToInitializer().transform(model)
model = ConvertClipAttrToInput().transform(model)
model = Convert2dSumToAdd().transform(model)
model = InferenceShape(model).inference_shape()
return model
Classes
class PolishModel (*args, **kwds)
-
Essential graph transformer/optimizers
Expand source code
class PolishModel(Transformer[onnx.ModelProto]): """ Essential graph transformer/optimizers """ def transform(self, model: onnx.ModelProto) -> onnx.ModelProto: model = utils.name_nodes(model) model = utils.make_conv_bias_name_unique(model) model = utils.fix_batch_size_as_one(model) model = ExtractConstantToInitializer().transform(model) model = ConvertClipAttrToInput().transform(model) model = Convert2dSumToAdd().transform(model) model = InferenceShape(model).inference_shape() return model
Ancestors
- furiosa_sdk_quantizer.interfaces.transformer.Transformer
- typing.Generic
Methods
def transform(self, model: onnx.onnx_ml_pb2.ModelProto) ‑> onnx.onnx_ml_pb2.ModelProto
-
Expand source code
def transform(self, model: onnx.ModelProto) -> onnx.ModelProto: model = utils.name_nodes(model) model = utils.make_conv_bias_name_unique(model) model = utils.fix_batch_size_as_one(model) model = ExtractConstantToInitializer().transform(model) model = ConvertClipAttrToInput().transform(model) model = Convert2dSumToAdd().transform(model) model = InferenceShape(model).inference_shape() return model