diff --git a/xla/pjrt/pjrt_c_api_client.cc b/xla/pjrt/pjrt_c_api_client.cc index a6ebe3a39dfe31..3832eea7e7414a 100644 --- a/xla/pjrt/pjrt_c_api_client.cc +++ b/xla/pjrt/pjrt_c_api_client.cc @@ -1030,6 +1030,7 @@ PjRtCApiDeviceDescription::memory_spaces() const { extension->PJRT_DeviceDescription_MemoryDescriptions(&mem_desc_args), c_api_); + memory_space_descriptions_.reserve(mem_desc_args.num_memory_descriptions); for (int i = 0; i < mem_desc_args.num_memory_descriptions; i++) { PJRT_MemoryDescription_Kind_Args kind_args; kind_args.struct_size = PJRT_MemoryDescription_Kind_Args_STRUCT_SIZE, diff --git a/xla/pjrt/pjrt_device_description.h b/xla/pjrt/pjrt_device_description.h index b5d072c387e93c..95e2367a757268 100644 --- a/xla/pjrt/pjrt_device_description.h +++ b/xla/pjrt/pjrt_device_description.h @@ -36,7 +36,7 @@ class PjRtMemorySpaceDescription { // A platform-dependent string that uniquely identifies the kind of the // memory space. - absl::string_view kind() const { return kind_; } + absl::string_view kind() const { return absl::string_view(kind_); } // An ID uniquely identifies the kind of the memory space among those attached // to the same `PjRtClient`. The IDs assigned to a kind is implementation @@ -44,7 +44,7 @@ class PjRtMemorySpaceDescription { int kind_id() const { return kind_id_; } private: - absl::string_view kind_; + std::string kind_; int kind_id_; };