Improve scheduling
This MR improves further the scheduling, with the following novelties:
- New static sequential scheduling policies:
ShortestBranchFirst
andLonguestBranchFirst
(@raphaelmillet we talked about it, it is now there!); - Added
Scheduler::tagForkBranches()
that tags nodes with their branch (the fork node and its output index) in theschedule.branch
attribute. The tag mechanism is recursive (branches in branches will produce a second tag inschedule.branch
); - Added node attributes display in Mermaid output (example below, the display is better on latest version of Mermaid...);
- Enums are now automatically convertible to string with
fmt
when anEnumString
is provided, thanks to a templatedformat_as()
; - Current version of
generateMemory()
only works for purely sequential scheduling, it has therefore be moved toSequentialScheduler
. This way, the scheduling policy remains consistent betweengetSequentialStaticScheduling()
andgenerateMemory()
. This solves #243 (closed); - Fixed issue aidge_backend_cpu#48 (closed).
%%{init: {'flowchart': { 'curve': 'monotoneY'}, 'fontFamily': 'Verdana' } }%%
flowchart TB
Producer_0("input<br/><sub><em>(Producer#0)</em></sub>"):::producerCls_rootCls
CryptoHash_0("hash <sup><span title="name = hash
schedule:
branch = {(n.op.Producer, 0)}
" style="cursor: pointer; font-weight: bold; color: blue">[2]</span></sup><br/><sub><em>(CryptoHash#0)</em></sub>")
Mod_0("mod<br/><sub><em>(Mod#0)</em></sub>")
ReLU_0("relu <sup><span title="name = relu
schedule:
branch = {(n.op.Producer, 1)}
cond = {(n.op.Select, 0)}
" style="cursor: pointer; font-weight: bold; color: blue">[2]</span></sup><br/><sub><em>(ReLU#0)</em></sub>")
Tanh_0("tanh <sup><span title="name = tanh
schedule:
branch = {(n.op.Producer, 2)}
cond = {(n.op.Select, 1)}
" style="cursor: pointer; font-weight: bold; color: blue">[2]</span></sup><br/><sub><em>(Tanh#0)</em></sub>")
Sqrt_0("sqrt <sup><span title="name = sqrt
schedule:
branch = {(n.op.Producer, 3)}
cond = {(n.op.Select, 2)}
" style="cursor: pointer; font-weight: bold; color: blue">[2]</span></sup><br/><sub><em>(Sqrt#0)</em></sub>")
Select_0("select<br/><sub><em>(Select#0)</em></sub>")
Producer_1("<em>Producer#1</em>"):::producerCls
Producer_0-->|"0 [2, 3] Float32<br/>↓<br/>0"|CryptoHash_0
Producer_0-->|"0 [2, 3] Float32<br/>↓<br/>0"|ReLU_0
Producer_0-->|"0 [2, 3] Float32<br/>↓<br/>0"|Tanh_0
Producer_0-->|"0 [2, 3] Float32<br/>↓<br/>0"|Sqrt_0
CryptoHash_0-->|"0 [4] UInt64<br/>↓<br/>0"|Mod_0
Mod_0-->|"0 [4] UInt64<br/>↓<br/>0"|Select_0
ReLU_0-->|"0 [2, 3] Float32<br/>↓<br/>1"|Select_0
Tanh_0-->|"0 [2, 3] Float32<br/>↓<br/>2"|Select_0
Sqrt_0-->|"0 [2, 3] Float32<br/>↓<br/>3"|Select_0
Producer_1-->|"0 [1] UInt64<br/>↓<br/>1"|Mod_0
Select_0--->|"0 [2, 3] Float32<br/>↓"|output0((out#0)):::outputCls
classDef inputCls fill:#afa
classDef outputCls fill:#ffa
classDef externalCls fill:#ccc
classDef producerCls fill:#ccf
classDef genericCls fill:#f9f9ff,stroke-width:1px,stroke-dasharray: 5 5
classDef metaCls stroke-width:5px
classDef rootCls stroke:#f00
classDef producerCls_rootCls stroke:#f00,fill:#ccf
classDef genericCls_rootCls stroke:#f00,fill:#f9f9ff,stroke-width:1px,stroke-dasharray: 5 5
classDef metaCls_rootCls stroke:#f00,stroke-width:5px
Edited by Olivier BICHLER