Handbook
Glossary
tensor
Vocabulary
tensors
Class description
A sequence of floating-point numbers consisting of an
underlying
C-style array and a
shape
.
Definition
USING:
arrays
specialized-arrays.instances.alien.c-types.float
;
IN:
tensors
TUPLE:
tensor
{
shape
array
initial:
{
}
}
{
vec
float-array
initial:
float-array{
}
}
;
Methods
USING:
prettyprint.custom
tensors
;
M:
tensor
>pprint-sequence
tensor>array
;
USING:
accessors
kernel
tensors
tensors.private
;
M:
tensor
clone
[
shape>>
clone
]
[
vec>>
clone
]
bi
<tensor>
;
USING:
accessors
kernel
sequences
tensors
;
M:
tensor
clone-like
over
tensor?
[
drop
clone
]
[
[
>tensor
]
dip
2dup
2length
=
[
shape>>
reshape
]
[
drop
]
if
]
if
;
USING:
accessors
sequences
tensors
;
M:
tensor
length
vec>>
length
;
USING:
accessors
arrays
kernel
sequences
specialized-arrays.instances.alien.c-types.float
tensors
tensors.private
;
M:
tensor
like
over
tensor?
[
drop
]
[
over
float-array?
[
[
dup
[
length
1array
]
dip
<tensor>
]
dip
]
[
[
>tensor
]
dip
]
if
2dup
2length
=
[
shape>>
reshape
]
[
drop
]
if
]
if
;
USING:
accessors
arrays
kernel
sequences
tensors
;
M:
tensor
new-sequence
shape>>
2dup
product
=
[
nip
(tensor)
]
[
drop
1array
(tensor)
]
if
;
USING:
accessors
sequences
tensors
tensors.private
;
M:
tensor
nth
num-index
vec>>
nth
;
USING:
accessors
sequences.private
tensors
tensors.private
;
M:
tensor
nth-unsafe
num-index
vec>>
nth-unsafe
;
USING:
prettyprint.custom
tensors
;
M:
tensor
pprint*
pprint-object
;
USING:
kernel
prettyprint.custom
tensors
;
M:
tensor
pprint-delims
drop
\
t{
\
}
;
USING:
accessors
sequences
tensors
tensors.private
;
M:
tensor
set-nth
num-index
vec>>
set-nth
;
USING:
accessors
sequences.private
tensors
tensors.private
;
M:
tensor
set-nth-unsafe
num-index
vec>>
set-nth-unsafe
;
USING:
accessors
kernel
math
sequences
tensors
tensors.private
;
M:
tensor
sum
vec>>
0
<simd-slice>
[
simd-slice>>
[
sum
]
map-sum
]
[
end-slice>>
sum
]
bi
+
;