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

Method gen_blob_data

exir/_serialize/test/test_program.py:546–554  ·  view source on GitHub ↗

Generates a buffer with special first and last bytes, repeating the middle byte of the pattern.

(size: int, pattern: bytes)

Source from the content-addressed store, hash-verified

544
545 @staticmethod
546 def gen_blob_data(size: int, pattern: bytes) -> bytes:
547 """Generates a buffer with special first and last bytes,
548 repeating the middle byte of the pattern."""
549 assert len(pattern) == 3
550 assert size >= 3
551 # Stretch out the middle byte to fill the space.
552 ret = pattern[0:1] + pattern[1:2] * (size - 2) + pattern[2:3]
553 assert len(ret) == size
554 return ret
555
556 def test_round_trip_with_segments(self) -> None:
557 # Create a program with some delegate data blobs.

Calls

no outgoing calls

Tested by

no test coverage detected