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

Why libtorch tensor value assignment takes so much time? #1534

Open
tangyipeng100 opened this issue May 24, 2021 · 1 comment
Open

Why libtorch tensor value assignment takes so much time? #1534

tangyipeng100 opened this issue May 24, 2021 · 1 comment
Labels
question Tensors Issues relating to tensors (generic issues/questions or specific tensor tutorials)

Comments

@tangyipeng100
Copy link

tangyipeng100 commented May 24, 2021

I just assign 10000 values to a tensor:

clock_t start = clock();
torch::Tensor transform_tensor = torch::zeros({ 10000 });
for (size_t m = 0; m < 10000 m++)
	transform_tensor[m] = int(m);
clock_t finish = clock();

And it takes 0.317s. If I assign 10,000 to an array or a vector, the time cost will be less.
Why tensor takes so much time? Can the time cost be decreased?

@holly1238 holly1238 added the Tensors Issues relating to tensors (generic issues/questions or specific tensor tutorials) label Jul 27, 2021
@svekars
Copy link
Contributor

svekars commented Mar 8, 2023

Closing as this has been asked long time ago and likely no longer relevant. If you have more questions, please post in https://dev-discuss.pytorch.org?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Tensors Issues relating to tensors (generic issues/questions or specific tensor tutorials)
Projects
None yet
Development

No branches or pull requests

3 participants