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

Support string flag #7509

Merged
merged 4 commits into from
Mar 30, 2023
Merged

Support string flag #7509

merged 4 commits into from
Mar 30, 2023

Conversation

axinging
Copy link
Contributor

@axinging axinging commented Mar 23, 2023

To see the logs from the Cloud Build CI, please join either our discussion or announcement mailing list.


This change is Reviewable

@axinging axinging changed the title [webgpu] Support WEBGPU_PRINT_SHADER flag Support string flag Mar 23, 2023
@axinging axinging force-pushed the string_flags branch 3 times, most recently from 8ab4a56 to edbf645 Compare March 24, 2023 08:28
@axinging axinging marked this pull request as ready for review March 24, 2023 08:33
@axinging
Copy link
Contributor Author

@qjia7 @xhcao @gyagp PTAL

@@ -192,9 +196,9 @@ function parseValue(flagName: string, value: string): FlagValue {
return value === 'true';
} else if (`${+ value}` === value) {
return +value;
} else {
return value;
Copy link
Contributor

@gyagp gyagp Mar 25, 2023

Choose a reason for hiding this comment

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

For string, I'd prefer case sensitive.

Copy link
Member

Choose a reason for hiding this comment

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

I agree with Yang. Case sensitive would be better for strings.

Copy link
Member

Choose a reason for hiding this comment

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

On line 77, we set flags based on the url flags

    if (this.urlFlags[flagName] != null) {
      const flagValue = this.urlFlags[flagName];

These url flags are parsed by this.urlFlags[key] = parseValue(key, value);, However, parseValue makes the value lowercase with value = value.toLowerCase();. That makes all flags specified in the URL lowercase, and it's impossible to specify an uppercase url flag.

Should we use a different variable, valueLowercase, to store the lowercase value and then return the unmodified value here instead?

Copy link
Collaborator

@pyu10055 pyu10055 left a comment

Choose a reason for hiding this comment

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

Reviewable status: :shipit: complete! 1 of 1 approvals obtained (waiting on @gyagp and @mattsoulanille)


tfjs-core/src/environment.ts line 200 at r1 (raw file):

Previously, gyagp (Yang Gu) wrote…

For string, I'd prefer case sensitive.

+1

@@ -192,9 +196,9 @@ function parseValue(flagName: string, value: string): FlagValue {
return value === 'true';
} else if (`${+ value}` === value) {
return +value;
} else {
return value;
Copy link
Member

Choose a reason for hiding this comment

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

I agree with Yang. Case sensitive would be better for strings.

@axinging axinging force-pushed the string_flags branch 2 times, most recently from 1f8e9cd to 8b1bf57 Compare March 28, 2023 01:22
@axinging
Copy link
Contributor Author

@gyagp @mattsoulanille
This is case sensitive. I think the test case is misleading. So I refined the test case, PTAL

@@ -192,9 +196,9 @@ function parseValue(flagName: string, value: string): FlagValue {
return value === 'true';
} else if (`${+ value}` === value) {
return +value;
} else {
return value;
Copy link
Member

Choose a reason for hiding this comment

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

On line 77, we set flags based on the url flags

    if (this.urlFlags[flagName] != null) {
      const flagValue = this.urlFlags[flagName];

These url flags are parsed by this.urlFlags[key] = parseValue(key, value);, However, parseValue makes the value lowercase with value = value.toLowerCase();. That makes all flags specified in the URL lowercase, and it's impossible to specify an uppercase url flag.

Should we use a different variable, valueLowercase, to store the lowercase value and then return the unmodified value here instead?

@axinging
Copy link
Contributor Author

@gyagp @mattsoulanille , now URL string is also case seneitive, PTAL

Copy link
Contributor

@gyagp gyagp 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
Member

@mattsoulanille mattsoulanille left a comment

Choose a reason for hiding this comment

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

LGTM. Thanks!

@mattsoulanille mattsoulanille merged commit 8d161d2 into tensorflow:master Mar 30, 2023
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.

4 participants