Returns true if the flat_tensor header appears to be well-formed.
(self)
| 173 | ) |
| 174 | |
| 175 | def is_valid(self) -> bool: |
| 176 | """Returns true if the flat_tensor header appears to be well-formed.""" |
| 177 | return ( |
| 178 | self.magic == FlatTensorHeader.EXPECTED_MAGIC |
| 179 | and self.length >= FlatTensorHeader.EXPECTED_LENGTH |
| 180 | ) |
| 181 | |
| 182 | def to_bytes(self) -> bytes: |
| 183 | """Returns the binary representation of the flat_tensor header. |
no outgoing calls