xref: /aosp_15_r20/external/pytorch/aten/src/ATen/core/rref_interface.h (revision da0073e96a02ea20f0ac840b70461e3646d07c45)
1 #pragma once
2 
3 #include <c10/util/intrusive_ptr.h>
4 #include <ATen/core/jit_type_base.h>
5 
6 namespace c10 {
7 
8 struct Type;
9 using worker_id_t = int16_t;
10 
11 // This abstract class contains only user-facing APIs, and will be shared
12 // between jit and distributed to implement TorchScript support.
13 class C10_EXPORT RRefInterface : public c10::intrusive_ptr_target {
14  public:
15   RRefInterface() = default;
16   // RRef is made NOT copyable NOT movable to prevent messing up reference
17   // counting.
18   RRefInterface(const RRefInterface& other) = delete;
19   RRefInterface(RRefInterface&& other) = delete;
20   RRefInterface& operator=(RRefInterface&& other) = delete;
21 
22   ~RRefInterface() override = default;
23 
24   // returns the worker id of the owner
25   virtual worker_id_t owner() const = 0;
26 
27   // returns the worker name of the owner
28   virtual std::string ownerName() const = 0;
29 
30   // Returns true if this is the ``OwnerRRef``
31   virtual bool isOwner() const = 0;
32 
33   // Returns true if this is an ``OwnerRRef`` or if this ``UserRRef`` has been
34   // confirmed by its owner.
35   virtual bool confirmedByOwner() const = 0;
36 
37   virtual const TypePtr type() const = 0;
38 };
39 
40 }
41