| 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 | """ |