Skip to content

Complete VBuffer redesign - #1650

Merged
eerhardt merged 14 commits into
dotnet:masterfrom
eerhardt:VBufferInUltimo
Nov 19, 2018
Merged

eerhardt merged 14 commits into
dotnet:masterfrom
eerhardt:VBufferInUltimo

Conversation

@eerhardt

@eerhardt eerhardt commented Nov 16, 2018 •

Copy link
Copy Markdown
Member

This completes the redesign work for VBuffer by removing .Values and .Indices public arrays and converts all their usages to the new pattern. This is proposed change (4) in #608 (comment).

Change the public T[] Values and public int[] Indices to public ReadOnlySpan GetValues() and public ReadOnlySpan GetIndices().

Fixes #608

VBuffer<Float> tempGrad = default(VBuffer<Float>);
for (int i = from; i < to; ++i)
{
tempGrad = new VBuffer<Float>(0, 0, tempGrad.Values, tempGrad.Indices);

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I wasn't sure on this one. Normally when you call a function passing in a VBuffer, it is assumed that the function will return with the right result into that VBuffer. So "zeroing" it right before calling _func seemed unnecessary.

@TomFinley TomFinley Nov 16, 2018 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Well, that depends. I wonder if this _func here is some sort of "accumulating" gradient, so that if you call it multiple times without a refresh it will accumulate the partial gradients for all things. That could explain this pattern. To give another example, things in VectorUtils and the like often accept a vector as both a source and destination of data (e.g., the scaling, the multiply-add-intos, and stuff like this).


In reply to: 234085400 [](ancestors = 234085400)

@TomFinley TomFinley Nov 16, 2018 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actually I tried to go hunting for it to see if the usages of this actually bear out, there are no usages of DifferentiableFunctionAggregator at all. Not sure what's up with that. This code though is probably one of the oldest parts of the codebase, so maybe it was used years ago and no one noticed when we stopped using it. To be honest I'm not even sure what it is meant to do... maaaaaaaybe we can nuke it?


In reply to: 234102794 [](ancestors = 234102794,234085400)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I'll add this line back. I've opened #1653 to investigate removing this class since it isn't used.

}

var weightsEditor = VBufferEditor.CreateFromBuffer(ref weights[0]);
var l1IntermediateWeightsEditor = VBufferEditor.CreateFromBuffer(ref l1IntermediateWeights[0]);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

l1IntermediateWeights [](start = 89, length = 21)

Similar, I think this can be null.

Comment thread src/Microsoft.ML.PCA/PcaTrainer.cs Resolved
@TomFinley

TomFinley commented Nov 16, 2018 •

Copy link
Copy Markdown
Contributor

Looks very nice in general @eerhardt, thanks for working on this! I guess you're going to nail down the test failures, and I notice we haven't yet deleted the arrays from VBuffer, so I might expect lots of churn? Generally though looks great.

@TomFinley TomFinley left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Looks great, thanks @eerhardt -- but I see we still have the array accessors but maybe we can get rid of it soon?

@eerhardt

Copy link
Copy Markdown
Member Author

This change is ready to go in. Just needs one more reviewer to approve.

@eerhardt eerhardt mentioned this pull request Nov 19, 2018

@TomFinley TomFinley left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Hi @eerhardt still looks great, I see you've now gotten rid of the array accessors so that's fantastic news!

@TomFinley
TomFinley requested a review from sfilipi November 19, 2018 17:05

@yaeldekel yaeldekel left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

:shipit:

@eerhardt
eerhardt merged commit 0fe8baf into dotnet:master Nov 19, 2018
@eerhardt
eerhardt deleted the VBufferInUltimo branch November 19, 2018 18:11
@ghost ghost locked as resolved and limited conversation to collaborators Sep 8, 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.

3 participants