A `Scope` object represents a set of related TensorFlow ops that have the same properties such as a common name prefix. A Scope object is a container for TensorFlow Op properties. Op constructors get a Scope object as a mandatory first argument and the constructed op acquires the properties in the object. A simple example: using namespace ops; Scope root = Scope::NewRootScope(); auto c1 = Const
| 96 | /// A `Scope` object is NOT thread-safe. Threads cannot concurrently call |
| 97 | /// op-constructor functions on the same `Scope` object. |
| 98 | class Scope { |
| 99 | public: |
| 100 | Scope(const Scope& other); |
| 101 | ~Scope(); |
| 102 | Scope& operator=(const Scope& other); |
| 103 | |
| 104 | // The following functions are for users making graphs. They return brand new |
| 105 | // scopes, or scopes derived from an existing scope object. |
| 106 | |
| 107 | /// Return a new scope. |
| 108 | /// This creates a new graph and all operations constructed in this graph |
| 109 | /// should use the returned object as the "root" scope. |
| 110 | static Scope NewRootScope(); |
| 111 | |
| 112 | /// Return a new scope. Ops created with this scope will have |
| 113 | /// `name/child_scope_name` as the prefix. The actual name will be unique |
| 114 | /// in the current scope. All other properties are inherited from the current |
| 115 | /// scope. If `child_scope_name` is empty, the `/` is elided. |
| 116 | Scope NewSubScope(const string& child_scope_name) const; |
| 117 | |
| 118 | /// Return a new scope. All ops created within the returned scope will have |
| 119 | /// names of the form `name/StrCat(fragments...)[_suffix]` |
| 120 | template <typename... Ty> |
| 121 | Scope WithOpName(Ty... fragments) const { |
| 122 | return WithOpNameImpl(absl::StrCat(fragments...)); |
| 123 | } |
| 124 | |
| 125 | /// Return a new scope. All ops created within the returned scope will have as |
| 126 | /// control dependencies the union of operations in the control_deps vector |
| 127 | /// and the control dependencies of the current scope. |
| 128 | Scope WithControlDependencies( |
| 129 | const gtl::ArraySlice<Operation>& control_deps) const; |
| 130 | /// Same as above, but convenient to add control dependency on the operation |
| 131 | /// producing the control_dep output. |
| 132 | Scope WithControlDependencies(const Output& control_dep) const; |
| 133 | |
| 134 | /// Return a new scope. All ops created within the returned scope will have no |
| 135 | /// control dependencies on other operations. |
| 136 | Scope WithNoControlDependencies() const; |
| 137 | |
| 138 | /// Return a new scope. All ops created within the returned scope will have |
| 139 | /// the device field set to 'device'. |
| 140 | Scope WithDevice(const string& device) const; |
| 141 | |
| 142 | /// Returns a new scope. All ops created within the returned scope will have |
| 143 | /// their assigned device set to `assigned_device`. |
| 144 | Scope WithAssignedDevice(const string& assigned_device) const; |
| 145 | |
| 146 | /// Returns a new scope. All ops created within the returned scope will have |
| 147 | /// their _XlaCluster attribute set to `xla_cluster`. |
| 148 | Scope WithXlaCluster(const string& xla_cluster) const; |
| 149 | |
| 150 | /// Return a new scope. All ops created within the returned scope will be |
| 151 | /// co-located on the device where op is placed. |
| 152 | /// NOTE: This function is intended to be use internal libraries only for |
| 153 | /// controlling placement of ops on to devices. Public use is not encouraged |
| 154 | /// because the implementation of device placement is subject to change. |
| 155 | Scope ColocateWith(const Operation& op) const; |
no outgoing calls
no test coverage detected