MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / Device

Class Device

tensorflow/core/common_runtime/device.h:55–221  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

53namespace tensorflow {
54
55class Device : public DeviceBase {
56 public:
57 // Callback type that takes a Status and returns void.
58 typedef std::function<void(const Status&)> DoneCallback;
59
60 Device(Env* env, const DeviceAttributes& device_attributes);
61 Device(Env* env, const DeviceAttributes& device_attributes,
62 const DeviceResourceMgrMap* dev_rmgr_map);
63 ~Device() override;
64
65 // Full name of this device (see top comment).
66 const string& name() const override { return device_attributes_.name(); }
67
68 const string& physical_name() const override {
69 if (device_attributes_.physical_name().empty()) {
70 return device_attributes_.name();
71 }
72 return device_attributes_.physical_name();
73 }
74
75 // Parsed name of this device
76 const DeviceNameUtils::ParsedName& parsed_name() const {
77 return parsed_name_;
78 }
79
80 // Describes what kind of device this is. This is intended to be
81 // human-readable and not computer-parsed, except that two devices
82 // with the same device_type() are expected to perform similarly
83 // (both from a computation and communication perspective).
84 const string& device_type() const { return device_attributes_.device_type(); }
85
86 // Returns an aggregation of device attributes.
87 const DeviceAttributes& attributes() const override {
88 return device_attributes_;
89 }
90
91 // Performs the actual compute function.
92 //
93 // Subclasses may override this function if they wish to perform
94 // some initialization before each compute.
95 virtual void Compute(OpKernel* op_kernel, OpKernelContext* context) {
96 op_kernel->Compute(context);
97 }
98
99 virtual bool IsSingleStreamMode() { return false; }
100
101 // Asynchronous kernel's compute.
102 virtual void ComputeAsync(AsyncOpKernel* op_kernel, OpKernelContext* context,
103 AsyncOpKernel::DoneCallback done) {
104 op_kernel->ComputeAsync(context, std::move(done));
105 }
106
107 // Blocks until all operations queued on the device at the time of
108 // the call have completed. Returns any error pending on the device
109 // at completion.
110 virtual Status Sync() = 0;
111
112 // Calls the given callback when all operations queued on the device at the

Callers 1

DebugStringMethod · 0.50

Calls 3

nameMethod · 0.65
emptyMethod · 0.45
device_typeMethod · 0.45

Tested by

no test coverage detected