Commit cdd0335
committed
[pytorch/executorch][diff_train] Serialize NamedData in PTE file (#8847)
1. Serialize NamedData in PTE file
2. Add NamedDataStore to EdgeProgramManager
---
Serializing NamedData is slightly different to constant/delegate data as each segment comes with its own alignment.
**An example:**
Given NamedData = {"key": data}. Data is 250 bytes.
- BackendA requires data with alignment=3
- BackendB requires data with alignment=4
Then, data0 should be serialized with alignment of lcm(3, 4) = 12
At serialization, ExecuTorch has a 'segment_alignment' that defaults to 128. Data is now serialized to lcm(12, 128) = 384.
Inside the DataSegment, we want to store the original size of the data (250). The offset of the subsequent DataSegment would be 384 bytes after the start of this one.
**Design**
Introduce a new dataclass 'AlignedData' that stores the buffer and any alignment that's required. This is used when assembling Program.segments to ensure we get lcm(buffer_alignment, segment_alignment).
Note: The default segment_alignment can be overridden inside 'ExecutorchBackendConfig'.
Pull Request resolved: #8835
Internal:
<< DO NOT EDIT BELOW THIS LINE >>
**GitHub Author**: pytorchbot <[email protected]>
**GitHub Repo**: [pytorch/executorch](https://github.com/pytorch/executorch)
**GitHub Pull Request**: [#8835](#8835)
Initially generated by: https://www.internalfb.com/intern/sandcastle/job/18014400207802303/
This was imported as part of a Diff Train.
Please review this as soon as possible. Since it is a direct copy of a commit on
GitHub, there shouldn't be much to do.
diff-train-source-id: 314ab18
Co-authored-by: lucylq <[email protected]>
Differential Revision: [D69764150](https://our.internmc.facebook.com/intern/diff/D69764150/)
ghstack-source-id: 2690827991 parent 4df0ade commit cdd0335
File tree
5 files changed
+290
-23
lines changed- exir
- _serialize
- test
- program
- tests
5 files changed
+290
-23
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
| 11 | + | |
11 | 12 | | |
12 | 13 | | |
13 | 14 | | |
14 | | - | |
| 15 | + | |
15 | 16 | | |
16 | 17 | | |
17 | 18 | | |
| |||
20 | 21 | | |
21 | 22 | | |
22 | 23 | | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
23 | 28 | | |
24 | 29 | | |
25 | 30 | | |
| |||
29 | 34 | | |
30 | 35 | | |
31 | 36 | | |
| 37 | + | |
32 | 38 | | |
33 | 39 | | |
34 | 40 | | |
| |||
41 | 47 | | |
42 | 48 | | |
43 | 49 | | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
44 | 68 | | |
45 | 69 | | |
46 | 70 | | |
| |||
213 | 237 | | |
214 | 238 | | |
215 | 239 | | |
216 | | - | |
| 240 | + | |
217 | 241 | | |
218 | 242 | | |
219 | 243 | | |
| |||
253 | 277 | | |
254 | 278 | | |
255 | 279 | | |
256 | | - | |
| 280 | + | |
257 | 281 | | |
258 | 282 | | |
259 | 283 | | |
| |||
316 | 340 | | |
317 | 341 | | |
318 | 342 | | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
| 378 | + | |
| 379 | + | |
| 380 | + | |
319 | 381 | | |
320 | 382 | | |
321 | 383 | | |
| |||
324 | 386 | | |
325 | 387 | | |
326 | 388 | | |
| 389 | + | |
327 | 390 | | |
328 | 391 | | |
329 | 392 | | |
| |||
343 | 406 | | |
344 | 407 | | |
345 | 408 | | |
| 409 | + | |
| 410 | + | |
346 | 411 | | |
347 | 412 | | |
348 | 413 | | |
| |||
355 | 420 | | |
356 | 421 | | |
357 | 422 | | |
358 | | - | |
359 | | - | |
| 423 | + | |
| 424 | + | |
| 425 | + | |
360 | 426 | | |
361 | 427 | | |
362 | 428 | | |
| |||
374 | 440 | | |
375 | 441 | | |
376 | 442 | | |
377 | | - | |
| 443 | + | |
378 | 444 | | |
379 | 445 | | |
380 | 446 | | |
| |||
389 | 455 | | |
390 | 456 | | |
391 | 457 | | |
392 | | - | |
| 458 | + | |
393 | 459 | | |
394 | 460 | | |
395 | 461 | | |
| 462 | + | |
| 463 | + | |
396 | 464 | | |
397 | 465 | | |
398 | 466 | | |
399 | 467 | | |
400 | 468 | | |
401 | | - | |
| 469 | + | |
402 | 470 | | |
403 | 471 | | |
404 | 472 | | |
405 | 473 | | |
406 | 474 | | |
| 475 | + | |
407 | 476 | | |
408 | 477 | | |
409 | | - | |
| 478 | + | |
410 | 479 | | |
411 | 480 | | |
412 | 481 | | |
413 | | - | |
| 482 | + | |
414 | 483 | | |
415 | 484 | | |
416 | | - | |
| 485 | + | |
417 | 486 | | |
418 | 487 | | |
419 | 488 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
9 | | - | |
10 | | - | |
| 9 | + | |
11 | 10 | | |
12 | 11 | | |
13 | 12 | | |
14 | 13 | | |
| 14 | + | |
15 | 15 | | |
16 | 16 | | |
17 | 17 | | |
| |||
28 | 28 | | |
29 | 29 | | |
30 | 30 | | |
| 31 | + | |
31 | 32 | | |
32 | 33 | | |
33 | 34 | | |
34 | 35 | | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
35 | 49 | | |
36 | 50 | | |
37 | 51 | | |
38 | 52 | | |
39 | 53 | | |
40 | 54 | | |
41 | 55 | | |
| 56 | + | |
42 | 57 | | |
43 | 58 | | |
44 | 59 | | |
| |||
88 | 103 | | |
89 | 104 | | |
90 | 105 | | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
91 | 112 | | |
0 commit comments