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

tensorflow savedmodel warmup #539

Merged
merged 5 commits into from
Jul 23, 2020
Merged

Conversation

datelier
Copy link
Contributor

@datelier datelier commented Jul 2, 2020

Signed-off-by: datelier 57349093+datelier@users.noreply.github.com

Description:

tensorflow savedmodel warmup

Related Issue:

How Has This Been Tested?:

Environment:

  • Go Version: 1.14.3
  • Docker Version: 19.03.8
  • Kubernetes Version: 1.18.2
  • NGT Version: 1.11.5

Types of changes:

  • Bug fix [type/bug]
  • New feature [type/feature]
  • Add tests [type/test]
  • Security related changes [type/security]
  • Add documents [type/documentation]
  • Refactoring [type/refactoring]
  • Update dependencies [type/dependency]
  • Update benchmarks and performances [type/bench]
  • Update CI [type/ci]

Changes to Core Features:

  • Have you added an explanation of what your changes do and why you'd like us to include them?
  • Have you written new tests for your core changes, as applicable?
  • Have you successfully ran tests with your changes locally?

Checklist:

  • I have read the CONTRIBUTING document.
  • I have checked open Pull Requests for the similar feature or fixes?
  • I have added tests and benchmarks to cover my changes.
  • I have ensured all new and existing tests passed.
  • I have commented my code, particularly in hard-to-understand areas
  • I have updated the documentation accordingly.

@pull-assistant
Copy link

pull-assistant bot commented Jul 2, 2020

Score: 0.88

Best reviewed: commit by commit


Optimal code review plan (1 warning)

tensorflow savedmodel warmup

...erter/tensorflow/tensorflow.go 45% changes removed in fix warmup

     fix warmup

     fix DeepSource issue: Empty string test can be improved

     fix test checkFunc

     Merge branch 'master' into feature/internal/tensorflow_warmup

Powered by Pull Assistant. Last update fcb3cb7 ... ee4bb8b. Read the comment docs.

@codecov
Copy link

codecov bot commented Jul 2, 2020

Codecov Report

Merging #539 into master will increase coverage by 3.95%.
The diff coverage is 17.10%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #539      +/-   ##
==========================================
+ Coverage    7.84%   11.80%   +3.95%     
==========================================
  Files         388      407      +19     
  Lines       19945    21227    +1282     
==========================================
+ Hits         1565     2505     +940     
- Misses      18156    18445     +289     
- Partials      224      277      +53     
Impacted Files Coverage Δ
internal/cache/cacher/cacher.go 100.00% <ø> (+100.00%) ⬆️
internal/client/discoverer/discover.go 0.00% <0.00%> (ø)
internal/compress/gob.go 26.19% <0.00%> (-1.31%) ⬇️
internal/compress/gzip.go 26.98% <0.00%> (-7.02%) ⬇️
internal/compress/lz4.go 36.36% <0.00%> (-5.31%) ⬇️
internal/compress/zstd.go 29.50% <0.00%> (-5.79%) ⬇️
internal/config/blob.go 0.00% <0.00%> (ø)
internal/config/config.go 15.78% <ø> (+15.78%) ⬆️
internal/config/grpc.go 0.00% <0.00%> (ø)
internal/config/log.go 100.00% <ø> (+100.00%) ⬆️
... and 162 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update dc6a44e...ee4bb8b. Read the comment docs.

@@ -69,7 +70,17 @@ const (
threeDim
)

var loadFunc = tf.LoadSavedModel
var loadFunc = func(t *tensorflow) error {
Copy link
Collaborator

Choose a reason for hiding this comment

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

local func variable is not clean, please use receiver func instead of local func val

Copy link
Contributor

Choose a reason for hiding this comment

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

I think he want to override it during testing, so he defines this function as variable instead of the receiver function.

One more thing, this function is not tested ... (the coverage of this file is 86%)

Copy link
Collaborator

Choose a reason for hiding this comment

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

exactly, that's why I recommend method & it can be replaced by Interface, please mock it using interface

@vankichi
Copy link
Contributor

vankichi commented Jul 6, 2020

/rebase

@vdaas-ci
Copy link
Collaborator

vdaas-ci commented Jul 6, 2020

[REBASE] Rebase triggered by vankichi for branch: feature/internal/tensorflow_warmup

@vdaas-ci vdaas-ci force-pushed the feature/internal/tensorflow_warmup branch from b400518 to 68beb90 Compare July 6, 2020 01:31

for _, test := range tests {
t.Run(test.name, func(tt *testing.T) {
defer goleak.VerifyNone(t)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
defer goleak.VerifyNone(t)
defer goleak.VerifyNone(tt)


for _, test := range tests {
t.Run(test.name, func(tt *testing.T) {
defer goleak.VerifyNone(t)
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
defer goleak.VerifyNone(t)
defer goleak.VerifyNone(tt)

@datelier datelier force-pushed the feature/internal/tensorflow_warmup branch from 68beb90 to 45123c4 Compare July 9, 2020 05:13
@datelier
Copy link
Contributor Author

datelier commented Jul 9, 2020

/rebase

@vdaas-ci
Copy link
Collaborator

vdaas-ci commented Jul 9, 2020

[REBASE] Rebase triggered by datelier for branch: feature/internal/tensorflow_warmup

Signed-off-by: datelier <57349093+datelier@users.noreply.github.com>
Signed-off-by: datelier <57349093+datelier@users.noreply.github.com>
Signed-off-by: datelier <57349093+datelier@users.noreply.github.com>
@vdaas-ci vdaas-ci force-pushed the feature/internal/tensorflow_warmup branch from 7b0f0d1 to ba92ef5 Compare July 9, 2020 05:38
Comment on lines 506 to 521
opts := []cmp.Option{
cmp.AllowUnexported(tensorflow{}),
cmp.AllowUnexported(OutputSpec{}),
cmpopts.IgnoreFields(tensorflow{}, "loadFunc"),
}
if diff := cmp.Diff(w.obj, obj, opts...); diff != "" {
return errors.Errorf("err: %s", diff)
}
opt := cmp.Comparer(func(want, obj T) bool {
p1 := reflect.ValueOf(want).FieldByName("loadFunc").Pointer()
p2 := reflect.ValueOf(obj).FieldByName("loadFunc").Pointer()
return p1 == p2
})
if !cmp.Equal(w.obj, obj, opt) {
return errors.Errorf("got = %v, want = %v", obj, w.obj)
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
opts := []cmp.Option{
cmp.AllowUnexported(tensorflow{}),
cmp.AllowUnexported(OutputSpec{}),
cmpopts.IgnoreFields(tensorflow{}, "loadFunc"),
}
if diff := cmp.Diff(w.obj, obj, opts...); diff != "" {
return errors.Errorf("err: %s", diff)
}
opt := cmp.Comparer(func(want, obj T) bool {
p1 := reflect.ValueOf(want).FieldByName("loadFunc").Pointer()
p2 := reflect.ValueOf(obj).FieldByName("loadFunc").Pointer()
return p1 == p2
})
if !cmp.Equal(w.obj, obj, opt) {
return errors.Errorf("got = %v, want = %v", obj, w.obj)
}
opts := []cmp.Option{
cmp.AllowUnexported(tensorflow{}),
cmp.AllowUnexported(OutputSpec{}),
cmpopts.IgnoreFields(tensorflow{}, "loadFunc"),
cmp.Comparer(func(want, got TF) bool {
p1 := reflect.ValueOf(want).Elem().FieldByName("loadFunc").Pointer()
p2 := reflect.ValueOf(got).Elem().FieldByName("loadFunc").Pointer()
return p1 == p2
}),
}
if diff := cmp.Diff(w.want, got, opts...); diff != "" {
return errors.Errorf("err: %s", diff)
}

Signed-off-by: datelier <57349093+datelier@users.noreply.github.com>
@@ -42,74 +44,127 @@ func TestNew(t *testing.T) {
beforeFunc func(args)
afterFunc func(args)
}
savedModel := &tf.SavedModel{}
Copy link
Contributor

Choose a reason for hiding this comment

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

[golangci] reported by reviewdog 🐶
assignments should only be cuddled with other assignments (wsl)

beforeFunc func()
afterFunc func()
}
defaultCheckFunc := func(w want, err error) error {
Copy link
Contributor

Choose a reason for hiding this comment

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

[golangci] reported by reviewdog 🐶
assignments should only be cuddled with other assignments (wsl)

},
graph: tf.NewGraph(),
session: &mockSession{
RunFunc: func(feeds map[tf.Output]*tf.Tensor, fetches []tf.Output, operations []*tf.Operation) ([]*tf.Tensor, error) {
Copy link
Contributor

Choose a reason for hiding this comment

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

[golangci] reported by reviewdog 🐶
line is 123 characters (lll)

Copy link
Collaborator

@hlts2 hlts2 left a comment

Choose a reason for hiding this comment

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

LGTM

@kevindiu
Copy link
Contributor

kevindiu commented Jul 9, 2020

/format

@vdaas-ci
Copy link
Collaborator

vdaas-ci commented Jul 9, 2020

[FORMAT] Updating license headers and formatting go codes triggered by kevindiu.

return func(t *tensorflow) {
if warmupInputs != nil {
if t.warmupInputs != nil {
t.warmupInputs = append(t.warmupInputs, warmupInputs...)
Copy link
Contributor

Choose a reason for hiding this comment

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

thinking functional options should not append inputs instead of replacing the value only.
@hlts2 what do you think?

Copy link
Collaborator

Choose a reason for hiding this comment

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

I understand your opinion.
but From a flexibility point of view, I would like to keep the current implementation.

Copy link
Contributor

@kevindiu kevindiu left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Collaborator

@kpango kpango left a comment

Choose a reason for hiding this comment

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

LGTM

@kpango kpango merged commit 6d215f6 into master Jul 23, 2020
@kpango kpango deleted the feature/internal/tensorflow_warmup branch July 23, 2020 05:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants