dotnet / TorchSharp

A .NET library that provides access to the library that powers PyTorch.
MIT License
1.37k stars 177 forks source link

Split Razor template in several smaller pieces #50

Closed NiklasGustafsson closed 4 years ago

NiklasGustafsson commented 5 years ago

The TypeGeneration.tt file is very big and will cause unnecessary merge conflicts unless it is split up into pieces.

I suggest the following organization into separate files:

  1. The Storage subclass (btw, it shouldn't need qualification, since it's a nested class).
  2. The basics -- constructors, ToString(), indexer, HType subclass, accessors, various static factories, etc.
  3. Copy and Fill operations.
  4. Tensor manipulation -- resize, transpose, etc.
  5. Element-wise operations, unary operators.
  6. Linear algebra operators
interesaaat commented 5 years ago

Sounds good to me. I suggest to put 2 and 3 together though.

migueldeicaza commented 5 years ago

This sounds like a band aid for the root of the problem.

We probably should sort out not generating the file, and using the NuGet from Mikayla to generate the file.

NiklasGustafsson commented 5 years ago

@migueldeicaza, I'm not sure I understand your proposal. Could you elaborate?

motus commented 5 years ago

@NiklasGustafsson I agree. In fact, I am trying to follow that logic in my recent PR #57 - I keep all DllImport mappings in the TorchSharp/Raw/ folder, and will define the high-level operations separately. We can do teh same to THTorch_* mappings etc.

P.S. @migueldeicaza I am not sure I can understand it either.. (Meanwhile, I have three PRs ready for issues #21 #22 #23 all using TT) :)

migueldeicaza commented 5 years ago

The desire to split this is rooted on the generated file and the conflicts with PR, so what I would rather do is fix the generation of the file than split the file. It is a tiny file.

dsyme commented 4 years ago

Closing, see https://github.com/xamarin/TorchSharp/pull/129