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

Better support for Tensorbackeds #29

Open
kaifox opened this issue Sep 25, 2017 · 5 comments
Open

Better support for Tensorbackeds #29

kaifox opened this issue Sep 25, 2017 · 5 comments

Comments

@kaifox
Copy link
Member

kaifox commented Sep 25, 2017

compose(ATensorbacked.class).from(aTensor);
vs.:
aTensor.as(ATensoribacked.class);
(usually, the latter one should be possible ... as long it does not require anything additional (e.g. a field)).

Further:

calculate(ATensorbacked.class).by(a).times(b);
(or from(a)?)

@jcgarnier
Copy link
Member

I tend to prefer
aTensor.as(ATensorbacked.class);

I find it more natural for me as a programmer to look for what I can do from a class using the autocompletion.

For the second one, what about:
a.times(b).as(ATensorBacked.class)
Just following my preference ;)

@agorzawski
Copy link
Member

agorzawski commented Sep 27, 2017

@jcgarnier I agree for the first one, but the second would need to implement the operations in the a.class... It needs to be something like @kaifox proposed or
calculate(ATensorbacked.class).for(a).times(b)

@michi42
Copy link
Member

michi42 commented Sep 27, 2017

For the first one, I prefer the aTensor.as(SomeTensorbacked.class) as it feels more concise - even though it is 'polluting' the Tensor interface up to some extent. The compose(...).from(...) is a bit too much boilerplate for my taste. In principle we're looking for a nicer (more fluent) way to write new SomeTensorbacked(aTensor) ...

For the second point, with the .as() method, we would get calculate(a).times(b).as(SomeTensorbacked.class) for free ...

@kaifox
Copy link
Member Author

kaifox commented Oct 1, 2017

As I mentioned to Michi:
For sure, the as(...) is more fluent. There I completely agree. The main reasons why I am hesitating, are:

  • we kept the interfaces very clean up to now and it proved to pay off. There were not much big changes in them. Most of the changes were mainly in the supporting methods.
  • The as(..) only works if we do not need any additional information for the conversion (e.g. the field, any strategy). This is ok for tensorbackeds (at the moment) .... However, as it would be nice to use a similar (same) approach for quantities, we might be in trouble
  • The calculate methods of tensorbackeds would always have to return a tensor (and not a tensorbacked) to make this approach possible.
  • The as(..) approach completely couples (circularily) The tensor and the Tensorbacked interfaces ...
    ... so I do not like it too much ...
    So I am clearly in favour of something like
    calculate(ATensorbacked.class).from(a).times(b);

... But probably opinions change until somebody gets to the point of implementing something

@kaifox
Copy link
Member Author

kaifox commented Sep 20, 2020

Additional things, which should go in here:

  • expose a method for creation in (Tensorbackeds)
create(Tensorbacked.class, tensor)

Currently it is only in tensorbacked internals... somethime it still is useful outside.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants