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

Method test_no_constants

exir/_serialize/test/test_program.py:680–705  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

678 self.assertEqual(deserialized.named_data, None)
679
680 def test_no_constants(self) -> None:
681 program = get_test_program()
682 # Insert placeholder for non-const tensors.
683 add_constant_data(program, [b""])
684
685 pte_data = bytes(
686 serialize_pte_binary(
687 PTEFile(program=program),
688 extract_delegate_segments=True,
689 segment_alignment=SEGMENT_ALIGNMENT,
690 constant_tensor_alignment=CONSTANT_TENSOR_ALIGNMENT,
691 )
692 )
693 # The input Program should not be modified.
694 self.assertEqual(program.segments, [])
695
696 # Peek inside the actual flatbuffer data to see the segments.
697 flatbuffer_program = _json_to_program(_program_flatbuffer_to_json(pte_data))
698
699 # Constant buffer should be empty.
700 self.assertEqual(len(flatbuffer_program.constant_buffer), 0)
701
702 # Constant segment should contain the placeholder.
703 self.assertEqual(flatbuffer_program.constant_segment.segment_index, 0)
704 self.assertEqual(len(flatbuffer_program.constant_segment.offsets), 1)
705 self.assertEqual(flatbuffer_program.constant_segment.offsets[0], 0)
706
707 def test_unused_inline_delegate_blobs_with_segments(self) -> None:
708 # Create a program with some delegate data blobs.

Callers

nothing calls this directly

Calls 6

get_test_programFunction · 0.90
serialize_pte_binaryFunction · 0.90
PTEFileClass · 0.90
_json_to_programFunction · 0.90
add_constant_dataFunction · 0.85

Tested by

no test coverage detected