Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] GenericTensor 2.0 API Design #31

Open
WhiteBlackGoose opened this issue May 30, 2022 · 2 comments
Open

[WIP] GenericTensor 2.0 API Design #31

WhiteBlackGoose opened this issue May 30, 2022 · 2 comments
Labels
Opinions wanted If you have advice, share it! proposal

Comments

@WhiteBlackGoose
Copy link
Member

WhiteBlackGoose commented May 30, 2022

Name of the type

For now we will assume it's Tensor. However it's opionated, because it might be useful to avoid calling it the same name as other libs.

Operations

Namespace: GenericTensor.Core.

Interfaces with method Invoke: () -> A

IAdditiveIdentity<A>
IMultiplicativeIdentity<A>

Interfaces with method Invoke: A -> B

INegate<A, B>

Interfaces with method Invoke: A x B -> C

IAdd<A, B, C>
ISubtract<A, B, C>
IMultiply<A, B, C>
IDivide<A, B, C>

Interfaces with method Invoke: A -> bool

IEqualsAdditiveIdentity<A>

Interfaces with method Invoke: A x B -> bool

IAreEqual<A, B>

Interfaces with method Invoke: A -> string

IToString<A>

Interfaces with method Invoke: A -> byte[]

ISerialize<A>

Interfaces with method Invoke: byte[] -> A

IDeserialize<A>

Tensor

The main type where all these methods will be is Tensor (but not Tensor<T>!).

Composition

static Tensor<T> Concat<T>(params Tensor<T>[] ts, int axis = -1);
byte[] Serialize<T, TSerializer>() where TSerializer : ISerialize<T>;
Tensor<T> Slice<T>(params Either<int, Index, Range>[] dims);
static Tensor<T> Stack<T>(params Tensor<T>[] ts);
Tensor<T> Transpose<T>(Tensor<T> a);
Tensor<T> Transpose<T>(Tensor<T> a, int axis1, int axis2);
void TransposeInplace(Tensor<T> a);
void TransposeInplace(Tensor<T> a, int axis1, int axis2);

Math operations

...

Elementwise:

void AddPointwise<A, B, C, TAdder>(Tensor<A> a, Tensor<B> b, Tensor<C> destination) where TAdder : struct, IAdder<A, B, C>;
Tensor<C> AddPointwise<A, B, C, TAdder>(Tensor<A> a, Tensor<B> b) where TAdder : struct, IAdder<A, B, C>;
@WhiteBlackGoose WhiteBlackGoose added Opinions wanted If you have advice, share it! proposal labels May 30, 2022
@Happypig375
Copy link
Member

Consider integration with .NET6/7 numeric interfaces?

@WhiteBlackGoose
Copy link
Member Author

I think we can do it for multitarget. So if the target is .NET 7+, then we also offer a wrapper which would provide default operations implementing their numeric interfaces

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Opinions wanted If you have advice, share it! proposal
Projects
None yet
Development

No branches or pull requests

2 participants