-
Notifications
You must be signed in to change notification settings - Fork 78
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
Conversation
Best reviewed: commit by commit
Optimal code review plan (1 warning)
|
Codecov Report
@@ 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
Continue to review full report at Codecov.
|
@@ -69,7 +70,17 @@ const ( | |||
threeDim | |||
) | |||
|
|||
var loadFunc = tf.LoadSavedModel | |||
var loadFunc = func(t *tensorflow) error { |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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%)
There was a problem hiding this comment.
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
/rebase |
[REBASE] Rebase triggered by vankichi for branch: feature/internal/tensorflow_warmup |
b400518
to
68beb90
Compare
|
||
for _, test := range tests { | ||
t.Run(test.name, func(tt *testing.T) { | ||
defer goleak.VerifyNone(t) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
defer goleak.VerifyNone(t) | |
defer goleak.VerifyNone(tt) |
|
||
for _, test := range tests { | ||
t.Run(test.name, func(tt *testing.T) { | ||
defer goleak.VerifyNone(t) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
defer goleak.VerifyNone(t) | |
defer goleak.VerifyNone(tt) |
68beb90
to
45123c4
Compare
/rebase |
[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>
7b0f0d1
to
ba92ef5
Compare
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) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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{} |
There was a problem hiding this comment.
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 { |
There was a problem hiding this comment.
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) { |
There was a problem hiding this comment.
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)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
/format |
[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...) |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Signed-off-by: datelier 57349093+datelier@users.noreply.github.com
Description:
tensorflow savedmodel warmup
Related Issue:
How Has This Been Tested?:
Environment:
Types of changes:
Changes to Core Features:
Checklist: