未验证 提交 4abf637f 编写于 作者: A Alex Hedges 提交者: GitHub

Remove mutable default parameter in init_inference() (#2540)

A mutable default value is dangerous because editing it will change the
value for all future calls to the function. The value is itself edited
later in the function, so this problem will likely be encountered sooner
or later.
Co-authored-by: NMichael Wyatt <michaelwyatt@microsoft.com>
上级 c5ee27f7
......@@ -230,7 +230,7 @@ def default_inference_config():
return DeepSpeedInferenceConfig().dict()
def init_inference(model, config={}, **kwargs):
def init_inference(model, config=None, **kwargs):
"""Initialize the DeepSpeed InferenceEngine.
Description: all four cases are valid and supported in DS init_inference() API.
......@@ -285,6 +285,8 @@ def init_inference(model, config={}, **kwargs):
ranks=[0])
# Load config_dict from config first
if config is None:
config = {}
if isinstance(config, str):
with open(config, "r") as f:
config_dict = json.load(f)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册