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

[Bug] oneflow.cat one input need return another tensor #7074

Closed
strint opened this issue Dec 21, 2021 · 1 comment · Fixed by #7075
Closed

[Bug] oneflow.cat one input need return another tensor #7074

strint opened this issue Dec 21, 2021 · 1 comment · Fixed by #7075

Comments

@strint
Copy link
Contributor

strint commented Dec 21, 2021

Summary

torch的cat,单输入,会创建另外一个单输出

>>> import torch
>>> torch.__version__
'1.10.0'
>>> x = torch.randn(2, 5, 5)
>>> y = torch.cat([x], 0)
>>> id(x)
140275845558832
>>> id(y)
140273210832272  # not x

oneflow的cat,单输入,输出直接返回了原输入

>>> import oneflow as torch
>>> x = torch.randn(2, 5, 5)
>>> y = torch.cat([x], 0)
>>> id(x)
140275721802288  
>>> id(y)
140275721802288 # is x

问题代码

class ConcatFunctor {
 public:
  ConcatFunctor() {
    ops_.resize(kMaxInputCount);
    for (int n = 1; n < ops_.size(); ++n) {
      ops_[n] = CHECK_JUST(one::OpBuilder("concat").Input("in", n + 1).Output("out").Build());
    }
  }
  Maybe<Tensor> operator()(const TensorTuple& inputs, const int64_t& dim) const {
    if (inputs.size() == 1) { return inputs.at(0); }  # 问题所在
@Aakifgithub
Copy link

Check the torch in few second on click event can be use

@Flowingsun007 Flowingsun007 linked a pull request Dec 22, 2021 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants