MCPcopy Create free account
hub / github.com/apple/coremltools / _replace_custom_layer_name

Function _replace_custom_layer_name

coremltools/models/utils.py:927–951  ·  view source on GitHub ↗

Substitutes ``newname`` for ``oldname`` in the ``className`` field of custom layers. If there are no custom layers, or no layers with ``className`` = ``oldname``, then the spec is unchanged. Parameters ---------- spec: mlmodel spec oldname: str The custom layer ``

(spec, oldname, newname)

Source from the content-addressed store, hash-verified

925
926
927def _replace_custom_layer_name(spec, oldname, newname):
928 """
929
930 Substitutes ``newname`` for ``oldname`` in the ``className`` field of custom layers. If there are no custom layers, or no
931 layers with ``className`` = ``oldname``, then the spec is unchanged.
932
933 Parameters
934 ----------
935 spec: mlmodel spec
936
937 oldname: str
938 The custom layer ``className`` to be replaced.
939
940 newname: str
941 The new ``className`` value to replace ``oldname``.
942
943 Returns
944 -------
945 An mlmodel spec.
946
947 """
948 layers = _get_custom_layers(spec)
949 for layer in layers:
950 if layer.custom.className == oldname:
951 layer.custom.className = newname
952
953
954def _is_macos():

Callers 1

Calls 1

_get_custom_layersFunction · 0.85

Tested by 1