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

Method Const

caffe2/python/core.py:1622–1651  ·  view source on GitHub ↗
(self, array, blob_out=None, dtype=None)

Source from the content-addressed store, hash-verified

1620 return self.Name()
1621
1622 def Const(self, array, blob_out=None, dtype=None):
1623 if isinstance(array, bool):
1624 return self.ConstantFill(
1625 [],
1626 blob_out or 1,
1627 dtype=DataType.BOOL,
1628 value=array)
1629
1630 if dtype is None:
1631 array = np.array(array)
1632 else:
1633 array = np.array(array, dtype=dtype)
1634
1635 def do_set(operator):
1636 return operator(
1637 [],
1638 blob_out or 1,
1639 shape=array.shape,
1640 values=array.flatten().tolist())
1641
1642 if array.dtype == np.int32:
1643 return do_set(self.GivenTensorIntFill)
1644 elif array.dtype == np.int64:
1645 return do_set(self.GivenTensorInt64Fill)
1646 elif array.dtype == str:
1647 return do_set(self.GivenTensorStringFill)
1648 elif array.dtype == bool:
1649 return do_set(self.GivenTensorBoolFill)
1650 else:
1651 return do_set(self.GivenTensorFill)
1652
1653 def BlobIsDefined(self, blob):
1654 """

Callers 15

test_net_multi_useMethod · 0.95
test_dequeue_manyMethod · 0.95
test_enforce_finiteMethod · 0.95
transform_varFunction · 0.80
z3_types.pyFile · 0.80
test_bmmMethod · 0.80
test_bmm2Method · 0.80
test_transposeMethod · 0.80
test_index_selectMethod · 0.80
test_get_attrMethod · 0.80
test_expandMethod · 0.80

Calls 1

isinstanceFunction · 0.85

Tested by 15

test_net_multi_useMethod · 0.76
test_dequeue_manyMethod · 0.76
test_enforce_finiteMethod · 0.76
test_bmmMethod · 0.64
test_bmm2Method · 0.64
test_transposeMethod · 0.64
test_index_selectMethod · 0.64
test_get_attrMethod · 0.64
test_expandMethod · 0.64
test_getitem_tensorMethod · 0.64
test_getitem_tensor2Method · 0.64