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

Use bytes proto field type for string values of xla::PjRtValueType to bytes #64750

Merged
merged 1 commit into from
Mar 29, 2024

Conversation

copybara-service[bot]
Copy link

@copybara-service copybara-service bot commented Mar 29, 2024

Use bytes proto field type for string values of xla::PjRtValueType to bytes

xla::PjRtValueType is defined in C++, where its std::string value can
contain any string (not necessarily UTF-8). Protobuf verison 3 requires a
string field to contain UTF-8, so it is more suitable to use bytes to
express this value.

(Note that the string value of xla::PjRtValueType would be often consumed by
Python, where nanobind would convert std::string into Python str with UTF-8
decoding. However, this is what some users of xla::PjRtValueType choose to
do; this is not sufficient enough to constrain the string to be UTF-8 only in
C++ APIs.)

This is a preemptive change; there is no known problem of using a string
field previously.

…` to `bytes`

`xla::PjRtValueType` is defined in C++, where its `std::string` value can
contain any string (not necessarily UTF-8). Protobuf verison 3 requires a
`string` field to contain UTF-8, so it is more suitable to use `bytes` to
express this value.

(Note that the string value of `xla::PjRtValueType` would be often consumed by
Python, where nanobind would convert `std::string` into Python `str` with UTF-8
decoding. However, this is what some users of `xla::PjRtValueType` choose to
do; this is not sufficient enough to constrain the string to be UTF-8 only in
C++ APIs.)

This is a preemptive change; there is no known problem of using a `string`
field previously.

PiperOrigin-RevId: 620315110
@copybara-service copybara-service bot merged commit f606d83 into master Mar 29, 2024
1 check passed
@copybara-service copybara-service bot deleted the exported_pr_620060088 branch March 29, 2024 21:08
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

1 participant