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

OnnxTransform freezing - replace tensor.CopyTo(List<float>) with tensor.CopyTo(float[]). #1275

Merged
merged 1 commit into from
Oct 18, 2018

Conversation

jignparm
Copy link
Contributor

Fixes #1228.

Reduce the number of data copies of a tensor. Use the Tensor.Copy() method to move contents directly into destination, rather than into a list[T] first, and then destination.

@jignparm jignparm self-assigned this Oct 17, 2018
@jignparm jignparm changed the title [WIP] Optimize tensor copy - address OnnxTransform freezing OnnxTransform freezing - replace tensor.CopyTo(List<float>) with tensor.CopyTo(float[]). Oct 18, 2018
@vaeksare
Copy link
Member

    /// Sonoma API only provides CopyTo() functions with overloaded versions

Since this comment is no longer accurate, you should change/remove it.


Refers to: src/Microsoft.ML.OnnxTransform/OnnxUtils.cs:334 in 4cf52d8. [](commit_id = 4cf52d8, deletion_comment = False)

Copy link
Member

@vaeksare vaeksare left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:shipit:

Copy link
Contributor

@Ivanidzo4ka Ivanidzo4ka left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:shipit:

@jignparm jignparm merged commit c6d4e62 into dotnet:master Oct 18, 2018
var typedDst = (System.Single[])(object)dst;
tensor.CopyTo(listDst);
listDst.CopyTo(typedDst);
tensor.CopyTo(typedDst);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You could add a CopyTo(T[] dst) to Sonoma and avoid this method entirely.

@ghost ghost locked as resolved and limited conversation to collaborators Mar 27, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants