yhtang / FunFact

Tensor decomposition with arbitrary expressions: inner, outer, elementwise operators; nonlinear transformations; and more.
Other
57 stars 4 forks source link

[REQ] Index arithmetics #231

Open yhtang opened 2 years ago

yhtang commented 2 years ago

Is your feature request related to a problem? Please describe. The FunFact tensor expression syntax lacks a way to express convolutions and tensor reshaping in a convenient manner.

Describe the solution you'd like We could use index addition to denote convolution, e.g.

A[i+p, j+q] B[p, q]  #convolving A with B using B as a filter.

Following a similar line of thought, index multiplication can denote both reshaping and Kronecker product (since Kronecker product can be thought of as outer product + reshaping):

A[i] B[j] >> [i*j]  # Kronecker product between A and B
A[i, j, k] >> [i*j, k]  #reshape two first dimensions of A to a vector

Describe alternatives you've considered Currently, we have the unary * operator to denote Kronecker product, e.g.:

A[[*i]] B[[*i]]  # Kronecker product between A

but we do not have the means to express reshaping or convolution yet.

Additional context

216.