MCPcopy Create free account
hub / github.com/pytorch/pytorch / get_ssa

Function get_ssa

caffe2/python/core.py:1210–1248  ·  view source on GitHub ↗

Given a net, return a structure containing the version of each input and output blob used by each operator. Args: net: either a Net or a NetDef blob_versions: (optional) map with current version number for given blob names. If not pro

(net, blob_versions=None)

Source from the content-addressed store, hash-verified

1208
1209
1210def get_ssa(net, blob_versions=None):
1211 """
1212 Given a net, return a structure containing the version of each input and
1213 output blob used by each operator.
1214
1215 Args:
1216 net: either a Net or a NetDef
1217 blob_versions: (optional) map with current version number for given
1218 blob names. If not provided or blob not found, start
1219 from version 0.
1220 Returns:
1221 Tuple (ssa, blob_versions)
1222 ssa: list of tuples (versioned_inputs, versioned_outputs)
1223 for each op in the net. A versioned input is a tuple
1224 (blob_name, version).
1225 blob_versions: updated map with latest version of each blob found in
1226 the net.
1227 """
1228 proto = net.Proto() if isinstance(net, Net) else net
1229 assert isinstance(proto, caffe2_pb2.NetDef)
1230 if blob_versions is None:
1231 blob_versions = {}
1232 if isinstance(net, list):
1233 return [get_ssa(n, blob_versions) for n in net], blob_versions
1234 for i in proto.external_input:
1235 if i not in blob_versions:
1236 blob_versions[str(i)] = 0
1237 ssa = []
1238 for op in proto.op:
1239 if not proto.external_input:
1240 for i in op.input:
1241 if i not in blob_versions:
1242 blob_versions[i] = 0
1243 inputs = [(str(i), blob_versions.get(str(i), 0)) for i in op.input]
1244 for o in op.output:
1245 blob_versions[str(o)] = blob_versions.get(str(o), 0) + 1
1246 outputs = [(str(o), blob_versions[str(o)]) for o in op.output]
1247 ssa.append((inputs, outputs))
1248 return ssa, blob_versions
1249
1250
1251def get_undefined_blobs(ssa):

Callers 2

clone_and_bind_netFunction · 0.85
ClonePartialMethod · 0.85

Calls 4

isinstanceFunction · 0.85
ProtoMethod · 0.45
getMethod · 0.45
appendMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…