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

optimization for the array structure #42

Merged
merged 9 commits into from
May 30, 2019
Merged

optimization for the array structure #42

merged 9 commits into from
May 30, 2019

Conversation

owulveryck
Copy link
Member

The value field is not initialized when the structure is created.
The population of the value is made when on call to Data() if the value is nil

@owulveryck owulveryck requested a review from chewxy May 29, 2019 20:03
@coveralls
Copy link

Coverage Status

Coverage decreased (-0.1%) to 72.711% when pulling 0a9a1ec on optim into 8eeece3 on master.

1 similar comment
@coveralls
Copy link

Coverage Status

Coverage decreased (-0.1%) to 72.711% when pulling 0a9a1ec on optim into 8eeece3 on master.

@owulveryck
Copy link
Member Author

For info, there is a bench done in onnx-go

@chewxy
Copy link
Member

chewxy commented May 30, 2019

Gentleman and scholar

Copy link
Member

@chewxy chewxy left a comment

Choose a reason for hiding this comment

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

(t *array) might cause govet to scream at you, other wise all good!

Thank you


// Pointer returns the pointer of the first value of the slab, as an unsafe.Pointer
func (t *array) Pointer() unsafe.Pointer { return t.Ptr }
func (a *array) Pointer() unsafe.Pointer { return a.Ptr }
Copy link
Member

Choose a reason for hiding this comment

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

These should be left as t otherwise govet shouts at you

Copy link
Member Author

Choose a reason for hiding this comment

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

Strange, I changed it on purpose because go vet was shouting at me, telling me that the name of the receiver was not consistent with the other methods.
I will change it back.

Copy link
Member

Choose a reason for hiding this comment

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

nah I may have an older version of govet. Keep it


// Data returns the representation of a slice.
func (a array) Data() interface{} { return a.v }
func (a array) Data() interface{} {
Copy link
Member

Choose a reason for hiding this comment

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

👍 love it

@@ -360,8 +365,11 @@ func copyDenseIter(dst, src DenseTensor, diter, siter Iterator) (int, error) {
return copyDense(dst, src), nil
}

if !dst.IsNativelyAccessible() || !src.IsNativelyAccessible() {
return 0, errors.Errorf(inaccessibleData, "copy")
if !dst.IsNativelyAccessible() {
Copy link
Member

Choose a reason for hiding this comment

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

Thanks for the boyscouting!

@@ -45,10 +46,12 @@ func TestSaveLoadNumpy(t *testing.T) {
t.Error(err)
}

expected := "[[ 1. 5.]\n [ 10. -1.]]\n"
expected := `\[\[\s*1\.\s*5\.\]\n \[\s*10\.\s*-1\.\]\]\n`
Copy link
Member

Choose a reason for hiding this comment

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

Novel test! I like this!

@owulveryck
Copy link
Member Author

Ok to merge?

@chewxy chewxy merged commit 1b74035 into master May 30, 2019
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 this pull request may close these issues.

None yet

3 participants