-
Notifications
You must be signed in to change notification settings - Fork 14
Expand file tree
/
Copy pathdense.asm
More file actions
41 lines (30 loc) · 767 Bytes
/
Copy pathdense.asm
File metadata and controls
41 lines (30 loc) · 767 Bytes
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
global dense
extern dot_product
extern relu, sigmoid
section .text
; rdi = pointer to input vector
; rsi = pointer to weights matrix (flattened row-major)
; rdx = pointer to bias vector
; r8 = pointer to output buffer
; r9 = num_neurons
; rcx = input_size
; r12 = 0 = ReLU, 1 = Sigmoid
dense:
mov r10, r9 ; neuron index
imul r11, rcx, 4 ; bytes of a row
.layer_loop:
call dot_product
cmp r12, 1
je .no_relu
call relu
jmp .save_value
.no_relu:
call sigmoid
.save_value:
movss [r8], xmm0 ; save
add r8, 4 ; go to next output
add rsi, r11 ; set W to next row of it
add rdx, 4 ; next bias
dec r10
jnz .layer_loop
ret