dfalbel / torch

torch from R!
http://dfalbel.github.io/torch
Other
51 stars 5 forks source link

divergence between doc and source for logsumexp function #29

Closed Athospd closed 5 years ago

Athospd commented 5 years ago

About tch_logsumexp()

Doc says it accepts dim (int or tuple of python:ints) – the dimension or dimensions to reduce Source say it accepts int64_t dim

When I tried to pass Rcpp::Nullable<Rcpp::IntegerVector> dim to logsumexp it thrown an error. And when I passed std::int64_t dim it finally worked out.

Am I missing something?

dfalbel commented 5 years ago

This seems like a bug in pytorch itself - or in the docs. See for example:

>>> import torch
>>> x = torch.randn(2,2,2)
>>> torch.logsumexp(x, 0)
tensor([[1.4389, 0.9872],
        [0.9308, 1.1934]])
>>> torch.logsumexp(x, (0,1))
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: logsumexp(): argument 'dim' (position 2) must be int, not tuple

I think we should mimic pytorch's behavior for now and file an issue in pytorch.