Qualify uses of std::string

PiperOrigin-RevId: 324413189
Change-Id: Ibb31fed1b4162936f180be5d7e8a6f4f39291396
This commit is contained in:
A. Unique TensorFlower 2020-08-01 12:17:58 -07:00 committed by TensorFlower Gardener
parent af197c251c
commit d0b99d9dde
4 changed files with 24 additions and 21 deletions

View File

@ -60,7 +60,7 @@ class Device : public DeviceBase {
~Device() override;
// Full name of this device (see top comment).
const string& name() const override { return device_attributes_.name(); }
const std::string& name() const override { return device_attributes_.name(); }
// Parsed name of this device
const DeviceNameUtils::ParsedName& parsed_name() const {
@ -71,7 +71,9 @@ class Device : public DeviceBase {
// human-readable and not computer-parsed, except that two devices
// with the same device_type() are expected to perform similarly
// (both from a computation and communication perspective).
const string& device_type() const { return device_attributes_.device_type(); }
const std::string& device_type() const {
return device_attributes_.device_type();
}
// Returns an aggregation of device attributes.
const DeviceAttributes& attributes() const override {
@ -157,15 +159,15 @@ class Device : public DeviceBase {
virtual ResourceMgr* resource_manager() { return rmgr_; }
// Summarizes the status of this Device, for debugging.
string DebugString() const { return device_attributes_.DebugString(); }
std::string DebugString() const { return device_attributes_.DebugString(); }
// Assembles the parameter components into a complete DeviceAttributes value.
static DeviceAttributes BuildDeviceAttributes(
const string& name, DeviceType device, Bytes memory_limit,
const DeviceLocality& locality, const string& physical_device_desc);
const std::string& name, DeviceType device, Bytes memory_limit,
const DeviceLocality& locality, const std::string& physical_device_desc);
static DeviceAttributes BuildDeviceAttributes(
const string& name, DeviceType device, Bytes memory_limit,
const std::string& name, DeviceType device, Bytes memory_limit,
const DeviceLocality& locality) {
// Pass in an empty string as physical device name.
return BuildDeviceAttributes(name, device, memory_limit, locality, "");

View File

@ -30,16 +30,16 @@ struct SessionOptions;
class DeviceFactory {
public:
virtual ~DeviceFactory() {}
static void Register(const string& device_type, DeviceFactory* factory,
static void Register(const std::string& device_type, DeviceFactory* factory,
int priority);
static DeviceFactory* GetFactory(const string& device_type);
static DeviceFactory* GetFactory(const std::string& device_type);
// Append to "*devices" all suitable devices, respecting
// any device type specific properties/counts listed in "options".
//
// CPU devices are added first.
static Status AddDevices(const SessionOptions& options,
const string& name_prefix,
const std::string& name_prefix,
std::vector<std::unique_ptr<Device>>* devices);
// Helper for tests. Create a single device of type "type". The
@ -73,7 +73,7 @@ class DeviceFactory {
// Most clients should call AddDevices() instead.
virtual Status CreateDevices(
const SessionOptions& options, const string& name_prefix,
const SessionOptions& options, const std::string& name_prefix,
std::vector<std::unique_ptr<Device>>* devices) = 0;
// Return the device priority number for a "device_type" string.
@ -88,7 +88,7 @@ class DeviceFactory {
// higher than the packaged devices. See calls to
// REGISTER_LOCAL_DEVICE_FACTORY to see the existing priorities used
// for built-in devices.
static int32 DevicePriority(const string& device_type);
static int32 DevicePriority(const std::string& device_type);
};
namespace dfactory {
@ -127,7 +127,7 @@ class Registrar {
// GPUCompatibleCPU: 70
// ThreadPoolDevice: 60
// Default: 50
explicit Registrar(const string& device_type, int priority = 50) {
explicit Registrar(const std::string& device_type, int priority = 50) {
DeviceFactory::Register(device_type, new Factory(), priority);
}
};

View File

@ -45,7 +45,7 @@ class ScopedAllocator {
// instance. It must be large enough to back all of the specified
// (offset, byte) ranges of the fields.
ScopedAllocator(const Tensor& backing_tensor, int32 scope_id,
const string& name, const gtl::ArraySlice<Field> fields,
const std::string& name, const gtl::ArraySlice<Field> fields,
int32 expected_call_count,
ScopedAllocatorContainer* container);
@ -60,7 +60,7 @@ class ScopedAllocator {
const Tensor& tensor() const { return backing_tensor_; }
const string& name() const { return name_; }
const std::string& name() const { return name_; }
private:
friend class ScopedAllocatorInstance;
@ -71,7 +71,7 @@ class ScopedAllocator {
Tensor backing_tensor_;
TensorBuffer* tbuf_;
int32 id_;
string name_;
std::string name_;
ScopedAllocatorContainer* container_;
std::vector<Field> fields_;
mutex mu_;
@ -111,7 +111,7 @@ class ScopedAllocatorInstance : public Allocator {
size_t AllocatedSize(const void* ptr) const override { return 0; }
int64 AllocationId(const void* ptr) const override { return 0; }
size_t AllocatedSizeSlow(const void* ptr) const override { return 0; }
string Name() override;
std::string Name() override;
private:
mutex mu_;

View File

@ -32,7 +32,8 @@ class ScopedAllocatorContainer : public core::RefCounted {
public:
// Establishes a reachable ScopedAllocator.
Status AddScopedAllocator(
const Tensor& backing_tensor, int32 scope_id, const string& scope_name,
const Tensor& backing_tensor, int32 scope_id,
const std::string& scope_name,
const gtl::ArraySlice<ScopedAllocator::Field>& fields,
int32 expected_call_count);
@ -72,7 +73,7 @@ class ScopedAllocatorContainer : public core::RefCounted {
// At most one of these exists per device.
class ScopedAllocatorMgr {
public:
explicit ScopedAllocatorMgr(const string& device_name)
explicit ScopedAllocatorMgr(const std::string& device_name)
: device_name_(device_name) {}
~ScopedAllocatorMgr();
@ -81,7 +82,7 @@ class ScopedAllocatorMgr {
// Establishes a reachable ScopedAllocator.
Status AddScopedAllocator(
const Tensor& backing_tensor, int64 step_id, int32 scope_id,
const string& scope_name,
const std::string& scope_name,
const gtl::ArraySlice<ScopedAllocator::Field>& fields,
int32 expected_call_count);
@ -97,10 +98,10 @@ class ScopedAllocatorMgr {
const DataType dtype,
std::vector<ScopedAllocator::Field>* fields);
const string& device_name() const { return device_name_; }
const std::string& device_name() const { return device_name_; }
private:
string device_name_;
std::string device_name_;
mutex mu_;
std::unordered_map<int64, ScopedAllocatorContainer*> per_step_map_
TF_GUARDED_BY(mu_);