MCPcopy Create free account
hub / github.com/apache/singa / _create_constant_of_shape

Method _create_constant_of_shape

python/singa/sonnx.py:1369–1385  ·  view source on GitHub ↗

get the ConstantOfShape operator from onnx node Args: onnx_node (OnnxNode): a given onnx node operator (Operator Class): a singa operator class opset_version (int): the opset version Returns: singa operator instance

(cls,
                                  onnx_node,
                                  operator,
                                  opset_version=_opset_version)

Source from the content-addressed store, hash-verified

1367
1368 @classmethod
1369 def _create_constant_of_shape(cls,
1370 onnx_node,
1371 operator,
1372 opset_version=_opset_version):
1373 """
1374 get the ConstantOfShape operator from onnx node
1375 Args:
1376 onnx_node (OnnxNode): a given onnx node
1377 operator (Operator Class): a singa operator class
1378 opset_version (int): the opset version
1379 Returns:
1380 singa operator instance
1381 """
1382 value = onnx_node.getattr("value", 0)
1383 if isinstance(value, onnx.TensorProto):
1384 value = numpy_helper.to_array(value)[0].item()
1385 return operator(value)
1386
1387 @classmethod
1388 def _create_transpose(cls,

Callers

nothing calls this directly

Calls 1

getattrMethod · 0.80

Tested by

no test coverage detected