Handbook
Glossary
2d-matmul-mixed ( vec1: float-array vec2: float-array res: float-array m: fixnum n: fixnum p: fixnum start: fixnum -- )
Vocabulary
tensors
.
private
Inputs
vec1
a
float-array
vec2
a
float-array
res
a
float-array
m
a
fixnum
n
a
fixnum
p
a
fixnum
start
a
fixnum
Outputs
None
Definition
USING:
accessors
kernel
math
math.vectors
sequences
sequences.private
typed
;
IN:
tensors.private
TYPED::
2d-matmul-mixed
( vec1: float-array vec2: float-array res: float-array m: fixnum n: fixnum p: fixnum start: fixnum -- )
{
n p
}
vec2
<tensor>
2d-transpose
vec>>
:>
vec2 start m n
*
*
:>
start1 start n p
*
*
:>
start2 m
[
:>
i i n
*
:>
in 4 4 in start1
+
4
mod
-
swap
mod
:>
in4m i p
*
:>
ip vec1 in n
make-subseq
:>
sub1 sub1 in4m
<simd-slice>
:>
slice1 p
[
:>
j j n
*
:>
jn 4 4 jn 4
mod
-
swap
mod
:>
jn4m vec2 jn n
make-subseq
in4m jn4m
=
[
jn4m
<simd-slice>
slice1
swap
2dup
[
first-slice>>
]
bi@
0.0
[
*
+
]
2reduce
[
2dup
[
simd-slice>>
]
bi@
]
dip
[
vdot
+
]
2reduce
[
[
end-slice>>
]
bi@
]
dip
[
*
+
]
2reduce
]
[
sub1
swap
0.0
[
*
+
]
2reduce
]
if
ip j
+
res
set-nth-unsafe
]
each-integer
]
each-integer
;