MCPcopy Index your code
hub / github.com/pytorch/pytorch / StringifyProto

Function StringifyProto

caffe2/python/workspace.py:148–170  ·  view source on GitHub ↗

Stringify a protocol buffer object. Inputs: obj: a protocol buffer object, or a Pycaffe2 object that has a Proto() function. Outputs: string: the output protobuf string. Raises: AttributeError: if the passed in object does not have the right attribute.

(obj)

Source from the content-addressed store, hash-verified

146
147
148def StringifyProto(obj):
149 """Stringify a protocol buffer object.
150
151 Inputs:
152 obj: a protocol buffer object, or a Pycaffe2 object that has a Proto()
153 function.
154 Outputs:
155 string: the output protobuf string.
156 Raises:
157 AttributeError: if the passed in object does not have the right attribute.
158 """
159 if isinstance(obj, basestring):
160 return obj
161 else:
162 if isinstance(obj, Message):
163 # First, see if this object is a protocol buffer, which we can
164 # simply serialize with the SerializeToString() call.
165 return obj.SerializeToString()
166 elif hasattr(obj, 'Proto'):
167 return obj.Proto().SerializeToString()
168 else:
169 raise ValueError("Unexpected argument to StringifyProto of type " +
170 type(obj).__name__)
171
172
173def ResetWorkspace(root_folder=None):

Callers 11

CreateNetFunction · 0.85
PredictorFunction · 0.85
GetOperatorCostFunction · 0.85
RunOperatorOnceFunction · 0.85
RunOperatorMultipleFunction · 0.85
RunNetOnceFunction · 0.85
RunPlanFunction · 0.85
RunPlanInBackgroundFunction · 0.85
InferShapesAndTypesFunction · 0.85
_Blob_feedFunction · 0.85

Calls 2

isinstanceFunction · 0.85
ProtoMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…