aboutsummaryrefslogtreecommitdiff
path: root/docs/multinpu.puml
blob: e5248b1b937781c3a35b70feae4625843d72c8ae (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
@startuml

skinparam backgroundColor #EEEBDC

box "Application" #00C1DE
participant "main()" as app
end box

box "Tensorflow" #FF6B00
participant "TFLu" as tflu
participant "Ethos-U custom op" as custom
end box

box "Ethos-U driver" #95D600
participant "Driver" as driver
end box

box "Hardware" #FFC700
participant "Cortex-M" as cortexm
participant "Ethos-U" as ethosu
end box

app -> tflu++: Invoke()
    tflu -> custom++: Eval()
        custom -> driver++: ethosu_reserve_driver()
            loop Find and reserve driver
                driver -> app++: ethosu_mutex_lock()
                return

                driver -> driver: ethosu_find_and_reserve_driver()

                driver -> app++: ethosu_mutex_unlock()
                return

                alt Found free driver
                    note over driver
                        Return free driver
                    end note
                else No driver available
                    driver -> app++: ethosu_semaphore_take()
                        note over app
                            Block on semaphore
                        end note
                    return
                end
            end loop
        return

        custom -> driver++: ethosu_invoke()
            driver -\\ ethosu: Configure NPU and trigger inference

            driver -> driver++: wait_for_irq()
                note over driver
                    Driver sleeping waiting for IRQ
                end note

                ethosu -\\ cortexm: IRQ
                cortexm -\\ driver: ethosu_irq_handler()

                note over driver
                    Driver woken up by IRQ handler
                end note
            return
        return

        custom -> driver++: ethosu_release_driver()
            driver -> app++: ethosu_mutex_lock()
            return

            driver -> app++: ethosu_semaphore_give()
                note over app
                    Wake up threads blocking on the semaphore
                end note
            return

            driver -> app++: ethosu_mutex_unlock()
            return
        return
    return
return

@enduml