aboutsummaryrefslogtreecommitdiffhomepage
path: root/tensorflow/cc/framework
diff options
context:
space:
mode:
authorGravatar Skye Wanderman-Milne <skyewm@google.com>2017-08-03 16:50:53 -0700
committerGravatar TensorFlower Gardener <gardener@tensorflow.org>2017-08-03 16:58:54 -0700
commit924c4af84e232e91eb0a7ffcf82548b76ed7d5e4 (patch)
tree7740e220243dfb3d9e6f8428037c78811c7cb9f6 /tensorflow/cc/framework
parent3599fd44d6bfcb16f45e763608a0e5da4e9072f5 (diff)
C++ API: move Scope::Impl to internal header file
This is in preparation to expose internal state to internal code that needs it, e.g. the scope's name and shape refiner. There are no code changes besides the move. PiperOrigin-RevId: 164202927
Diffstat (limited to 'tensorflow/cc/framework')
-rw-r--r--tensorflow/cc/framework/scope.cc77
-rw-r--r--tensorflow/cc/framework/scope_internal.h77
2 files changed, 77 insertions, 77 deletions
diff --git a/tensorflow/cc/framework/scope.cc b/tensorflow/cc/framework/scope.cc
index 1948dd4e46..4705b6b7e8 100644
--- a/tensorflow/cc/framework/scope.cc
+++ b/tensorflow/cc/framework/scope.cc
@@ -24,83 +24,6 @@ limitations under the License.
namespace tensorflow {
-class Scope::Impl {
- public:
- // A NameMap is used to keep track of suffixes for names used in a scope. A
- // name that has not been used so far in a scope will get no suffix. Later
- // uses of the same name will get suffixes _1, _2, _3, etc. Multiple scopes
- // can share the same NameMap. For instance, a new scope created using
- // WithControlDependencies() should would share the same NameMap with the
- // parent.
- typedef std::unordered_map<string, int> NameMap;
-
- Impl(const std::shared_ptr<Graph>& graph,
- const std::shared_ptr<Status>& status,
- const std::shared_ptr<NameMap>& name_map,
- const std::shared_ptr<ShapeRefiner>& refiner);
-
- private:
- friend class Scope;
-
- // Tag types to choose the constructor to dispatch.
- struct Tags {
- enum class ScopeName;
- enum class OpName;
- enum class ControlDeps;
- enum class Device;
- enum class SingleUseScope;
- enum class ExitOnError;
- enum class KernelLabel;
- enum class Colocate;
- };
-
- Impl(Graph* graph, Status* status, NameMap* name_map, ShapeRefiner* refiner);
- Impl(const Scope& other, Tags::ScopeName, const string& name,
- bool copy_names);
- Impl(const Scope& other, Tags::OpName, const string& name,
- const string& op_name);
- Impl(const Scope& other, Tags::ControlDeps,
- std::vector<Operation> control_deps, bool clear_control_deps);
- Impl(const Scope& other, Tags::Device, const string& device);
- Impl(const Scope& other, Tags::SingleUseScope, const string& op_name);
- Impl(const Scope& other, Tags::ExitOnError);
- Impl(const Scope& other, Tags::KernelLabel, const string& kernel_label);
- Impl(const Scope& other, Tags::Colocate, const Operation& colocate_with_op,
- bool clear_colocations);
-
- std::unordered_set<string> GetColocationConstraints(
- const Operation& colocate_with_op) const;
-
- // Helper functions to get a unique names.
- string GetUniqueName(const string& prefix, bool check_single_use) const;
- string GetNameForOp(const string& default_name) const;
-
- bool single_use_scope() const { return scope_used_ != nullptr; }
-
- // The graph, status, and name maps are shared by all child scopes
- // created from a single 'root' scope. A root scope is created by calling the
- // Scope::NewRootScope function, which creates a new graph, a new status and
- // the name maps.
- std::shared_ptr<Graph> graph_ = nullptr;
- std::shared_ptr<Status> status_ = nullptr;
- std::shared_ptr<NameMap> name_map_ = nullptr;
- std::shared_ptr<ShapeRefiner> refiner_ = nullptr;
-
- // If scope_used_ is not nullptr, op_name_ should be empty and
- // GetUniqueNameForOp can only be called once on this scope. More calls to
- // GetUniqueNameForOp will cause an error status to be set on this scope.
- std::shared_ptr<bool> scope_used_ = nullptr;
-
- const std::vector<Operation> control_deps_;
-
- const string name_ = "";
- const string op_name_ = "";
- const bool exit_on_error_ = false;
- const string kernel_label_ = "";
- const string device_ = "";
- const std::unordered_set<string> colocation_constraints_;
-};
-
Scope::Scope(Impl* impl) : impl_(impl) {}
Scope::Scope(const Scope& other) : impl_(new Impl(*other.impl())) {}
diff --git a/tensorflow/cc/framework/scope_internal.h b/tensorflow/cc/framework/scope_internal.h
index f2a911877f..3656c0aecf 100644
--- a/tensorflow/cc/framework/scope_internal.h
+++ b/tensorflow/cc/framework/scope_internal.h
@@ -28,6 +28,83 @@ class ShapeRefiner;
// bindings) to create a Scope and access C++ functionality (i.e. gradients).
Scope NewInternalScope(Graph* graph, Status* status, ShapeRefiner* refiner);
+class Scope::Impl {
+ public:
+ // A NameMap is used to keep track of suffixes for names used in a scope. A
+ // name that has not been used so far in a scope will get no suffix. Later
+ // uses of the same name will get suffixes _1, _2, _3, etc. Multiple scopes
+ // can share the same NameMap. For instance, a new scope created using
+ // WithControlDependencies() should would share the same NameMap with the
+ // parent.
+ typedef std::unordered_map<string, int> NameMap;
+
+ Impl(const std::shared_ptr<Graph>& graph,
+ const std::shared_ptr<Status>& status,
+ const std::shared_ptr<NameMap>& name_map,
+ const std::shared_ptr<ShapeRefiner>& refiner);
+
+ private:
+ friend class Scope;
+
+ // Tag types to choose the constructor to dispatch.
+ struct Tags {
+ enum class ScopeName;
+ enum class OpName;
+ enum class ControlDeps;
+ enum class Device;
+ enum class SingleUseScope;
+ enum class ExitOnError;
+ enum class KernelLabel;
+ enum class Colocate;
+ };
+
+ Impl(Graph* graph, Status* status, NameMap* name_map, ShapeRefiner* refiner);
+ Impl(const Scope& other, Tags::ScopeName, const string& name,
+ bool copy_names);
+ Impl(const Scope& other, Tags::OpName, const string& name,
+ const string& op_name);
+ Impl(const Scope& other, Tags::ControlDeps,
+ std::vector<Operation> control_deps, bool clear_control_deps);
+ Impl(const Scope& other, Tags::Device, const string& device);
+ Impl(const Scope& other, Tags::SingleUseScope, const string& op_name);
+ Impl(const Scope& other, Tags::ExitOnError);
+ Impl(const Scope& other, Tags::KernelLabel, const string& kernel_label);
+ Impl(const Scope& other, Tags::Colocate, const Operation& colocate_with_op,
+ bool clear_colocations);
+
+ std::unordered_set<string> GetColocationConstraints(
+ const Operation& colocate_with_op) const;
+
+ // Helper functions to get a unique names.
+ string GetUniqueName(const string& prefix, bool check_single_use) const;
+ string GetNameForOp(const string& default_name) const;
+
+ bool single_use_scope() const { return scope_used_ != nullptr; }
+
+ // The graph, status, and name maps are shared by all child scopes
+ // created from a single 'root' scope. A root scope is created by calling the
+ // Scope::NewRootScope function, which creates a new graph, a new status and
+ // the name maps.
+ std::shared_ptr<Graph> graph_ = nullptr;
+ std::shared_ptr<Status> status_ = nullptr;
+ std::shared_ptr<NameMap> name_map_ = nullptr;
+ std::shared_ptr<ShapeRefiner> refiner_ = nullptr;
+
+ // If scope_used_ is not nullptr, op_name_ should be empty and
+ // GetUniqueNameForOp can only be called once on this scope. More calls to
+ // GetUniqueNameForOp will cause an error status to be set on this scope.
+ std::shared_ptr<bool> scope_used_ = nullptr;
+
+ const std::vector<Operation> control_deps_;
+
+ const string name_ = "";
+ const string op_name_ = "";
+ const bool exit_on_error_ = false;
+ const string kernel_label_ = "";
+ const string device_ = "";
+ const std::unordered_set<string> colocation_constraints_;
+};
+
} // namespace tensorflow
#endif // THIRD_PARTY_TENSORFLOW_CC_FRAMEWORK_SCOPE_INTERNAL_H_