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

[QST]Can I create a null tensor? #1812

Open
ziyuhuang123 opened this issue Sep 12, 2024 · 2 comments
Open

[QST]Can I create a null tensor? #1812

ziyuhuang123 opened this issue Sep 12, 2024 · 2 comments

Comments

@ziyuhuang123
Copy link

Hi! I am wondering can I create a null tensor?

I am creating a tensor within a {} but need to use it in another {}. The lifetime of a variable is within a {}. So I need to create the tensor before the first {}, like:

Tensor s;
{
auto s = ......
}

{
func(s, ......)
}

But it seems I can not create like Tensor s ???

@thakkarV
Copy link
Collaborator

tensors are non-owning views (unless the layout is fully static). I do not really know what it is that you are trying to achieve here. if you want to pass around the data buffer, just pass around the underlying buffer itself rather than the whole tensor?

@osayamenja
Copy link

@ziyuhuang123 If you could somewhat specify your use case, templates may help achieve what you desire. See here

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

3 participants