mindspore_lite.ModelGroupFlag

class mindspore_lite.ModelGroupFlag[source]

The ModelGroupFlag class defines the type of the model group.

The ModelGroupFlag is used to define the flags used to construct a ModelGroup. Currently, supports:

1. ModelGroupFlag.SHARE_WEIGHT, multiple models share weights share workspace memory, default construction flag for ModelGroup.

2. ModelGroupFlag.SHARE_WORKSPACE, multiple models share weights(including constatns and variables) memory. Currently only supported in cloud side Ascend inference and the provider is GE.

Examples

>>> import mindspore_lite as mslite
>>> context = mslite.Context()
>>> context.target = ["Ascend"]
>>> context.ascend.device_id = 0
>>> context.ascend.rank_id = 0
>>> context.ascend.provider = "ge"
>>> model_group = mslite.ModelGroup(mslite.ModelGroupFlag.SHARE_WEIGHT)
>>> model0 = mslite.Model()
>>> model1 = mslite.Model()
>>> model_group.add_model([model0, model1])
>>> model0.build_from_file("seq_1024.mindir", mslite.ModelType.MINDIR, context, "config0.ini")
>>> model1.build_from_file("seq_1.mindir", mslite.ModelType.MINDIR, context, "config.ini")