MCPcopy Create free account
hub / github.com/pytorch/executorch / _format_string_for_array

Method _format_string_for_array

backends/nxp/nxp_backend.py:283–290  ·  view source on GitHub ↗

Create a format string which will represent the provided array. It also handles the necessary alignment. E.g. for array [1,2,3] we get '3s13x', because '3s' means string of 3 bytes, and `13x` means adding 13 bytes of '0' padding at the end (for 16B alignment).

(self, array: np.ndarray)

Source from the content-addressed store, hash-verified

281 return f"{self.ALIGNMENT - overflow}x"
282
283 def _format_string_for_array(self, array: np.ndarray) -> str:
284 """Create a format string which will represent the provided array. It also handles the necessary alignment.
285 E.g. for array [1,2,3] we get '3s13x', because '3s' means string of 3 bytes, and `13x` means adding 13 bytes
286 of '0' padding at the end (for 16B alignment).
287 """
288 assert array.dtype == np.dtype("uint8")
289
290 return f"{array.size}s{self._padding_format_string_for_array(array)}"
291
292 def _create_payload_header(
293 self, io_formats: dict[str, list[DataFormat]], neutron_artifacts

Callers 1

_pack_with_alignmentMethod · 0.95

Calls 2

dtypeMethod · 0.45

Tested by

no test coverage detected