|
312 | 312 | # For the CMake pipeline, we create a ``BundledProgram`` that packages the model |
313 | 313 | # with sample inputs and expected outputs for testing. We reuse the |
314 | 314 | # ``et_program_manager`` from Step 1. |
315 | | - |
316 | | -from executorch.devtools import BundledProgram |
317 | | - |
318 | | -from executorch.devtools.bundled_program.config import MethodTestCase, MethodTestSuite |
319 | | -from executorch.devtools.bundled_program.serialize import ( |
320 | | - serialize_from_bundled_program_to_flatbuffer, |
321 | | -) |
322 | | - |
323 | | -# Construct Method Test Suites using the same model and inputs from Pipeline 1 |
324 | | -m_name = "forward" |
325 | | -inputs = [model_inputs for _ in range(2)] |
326 | | - |
327 | | -method_test_suites = [ |
328 | | - MethodTestSuite( |
329 | | - method_name=m_name, |
330 | | - test_cases=[ |
331 | | - MethodTestCase(inputs=inp, expected_outputs=model(*inp)) for inp in inputs |
332 | | - ], |
333 | | - ) |
334 | | -] |
335 | | - |
336 | | -# Generate BundledProgram using the existing et_program_manager |
337 | | -bundled_program = BundledProgram(et_program_manager, method_test_suites) |
338 | | - |
339 | | -# Serialize BundledProgram to flatbuffer |
340 | | -serialized_bundled_program = serialize_from_bundled_program_to_flatbuffer( |
341 | | - bundled_program |
342 | | -) |
343 | | -bundled_program_path = os.path.join(temp_dir, "bundled_program.bp") |
344 | | -with open(bundled_program_path, "wb") as f: |
345 | | - f.write(serialized_bundled_program) |
| 315 | +# |
| 316 | +# .. code-block:: python |
| 317 | +# |
| 318 | +# from executorch.devtools import BundledProgram |
| 319 | +# from executorch.devtools.bundled_program.config import MethodTestCase, MethodTestSuite |
| 320 | +# from executorch.devtools.bundled_program.serialize import ( |
| 321 | +# serialize_from_bundled_program_to_flatbuffer, |
| 322 | +# ) |
| 323 | +# |
| 324 | +# # Construct Method Test Suites using the same model and inputs from Pipeline 1 |
| 325 | +# m_name = "forward" |
| 326 | +# inputs = [model_inputs for _ in range(2)] |
| 327 | +# |
| 328 | +# method_test_suites = [ |
| 329 | +# MethodTestSuite( |
| 330 | +# method_name=m_name, |
| 331 | +# test_cases=[ |
| 332 | +# MethodTestCase(inputs=inp, expected_outputs=model(*inp)) for inp in inputs |
| 333 | +# ], |
| 334 | +# ) |
| 335 | +# ] |
| 336 | +# |
| 337 | +# # Generate BundledProgram using the existing et_program_manager |
| 338 | +# bundled_program = BundledProgram(et_program_manager, method_test_suites) |
| 339 | +# |
| 340 | +# # Serialize BundledProgram to flatbuffer |
| 341 | +# serialized_bundled_program = serialize_from_bundled_program_to_flatbuffer( |
| 342 | +# bundled_program |
| 343 | +# ) |
| 344 | +# bundled_program_path = os.path.join(temp_dir, "bundled_program.bp") |
| 345 | +# with open(bundled_program_path, "wb") as f: |
| 346 | +# f.write(serialized_bundled_program) |
| 347 | +# |
346 | 348 |
|
347 | 349 | ###################################################################### |
348 | 350 | # Step 3: Run with CMake Example Runner |
|
0 commit comments