Skip to content

Commit

Permalink
Automated Code Change
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 621403466
  • Loading branch information
tensorflower-gardener committed Apr 3, 2024
1 parent 7909dde commit 29e3c03
Show file tree
Hide file tree
Showing 8 changed files with 24 additions and 25 deletions.
2 changes: 1 addition & 1 deletion tensorflow/core/common_runtime/function_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -635,7 +635,7 @@ TEST_F(FunctionLibraryRuntimeTest, StateHandle) {
// Attrs
{},
// Nodes
{FDH::Const<int32>("shape", gtl::ArraySlice<int32>({1})),
{FDH::Const<int32>("shape", absl::Span<const int32>({1})),
FDH::Const<int32>("minval", 0),
FDH::Const<int32>("maxval", 10),
// A stateful node.
Expand Down
2 changes: 1 addition & 1 deletion tensorflow/core/common_runtime/function_testlib.cc
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ FunctionDef BlockingOpFn() {

// TODO(phawkins): replace with C++ API for calling functions, when that exists.
Output Call(Scope* scope, const string& op_name, const string& fn_name,
gtl::ArraySlice<Input> inputs) {
absl::Span<const Input> inputs) {
NodeDef def;
NodeDefBuilder builder(op_name, fn_name, scope->graph()->op_registry());
for (const Input& input : inputs) {
Expand Down
2 changes: 1 addition & 1 deletion tensorflow/core/common_runtime/function_testlib.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ FunctionDef BlockingOpFn();
// Adds a function call to the given scope and returns the output for the node.
// TODO(phawkins): replace with C++ API for calling functions, when that exists.
Output Call(Scope* scope, const string& op_name, const string& fn_name,
gtl::ArraySlice<Input> inputs);
absl::Span<const Input> inputs);

} // namespace function
} // namespace test
Expand Down
26 changes: 13 additions & 13 deletions tensorflow/core/common_runtime/gradients.cc
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ static Node* AddZerosLike(Graph* g, NodeOut input) {
}
}

static Node* AddSymGrad(Graph* g, Node* n, gtl::ArraySlice<NodeOut> grads) {
static Node* AddSymGrad(Graph* g, Node* n, absl::Span<const NodeOut> grads) {
const int num_x = n->num_inputs();
const int num_y = n->num_outputs();
CHECK_EQ(num_y, grads.size());
Expand Down Expand Up @@ -151,18 +151,18 @@ static Node* AddSymGrad(Graph* g, Node* n, gtl::ArraySlice<NodeOut> grads) {

class SymbolicGradientBuilder {
public:
SymbolicGradientBuilder(gtl::ArraySlice<NodeOut> y_node_outputs,
gtl::ArraySlice<NodeOut> x_node_outputs,
gtl::ArraySlice<NodeOut> y_grad_node_outputs,
SymbolicGradientBuilder(absl::Span<const NodeOut> y_node_outputs,
absl::Span<const NodeOut> x_node_outputs,
absl::Span<const NodeOut> y_grad_node_outputs,
std::vector<NodeOut>* x_grad_node_outputs,
Graph* graph);

Status Compute();

private:
gtl::ArraySlice<NodeOut> y_node_outputs_;
gtl::ArraySlice<NodeOut> x_node_outputs_;
gtl::ArraySlice<NodeOut> y_grad_node_outputs_;
absl::Span<const NodeOut> y_node_outputs_;
absl::Span<const NodeOut> x_node_outputs_;
absl::Span<const NodeOut> y_grad_node_outputs_;
std::vector<NodeOut>* x_grad_node_outputs_;
Graph* graph_; // Not owned.

Expand Down Expand Up @@ -209,9 +209,9 @@ class SymbolicGradientBuilder {
};

SymbolicGradientBuilder::SymbolicGradientBuilder(
gtl::ArraySlice<NodeOut> y_node_outputs,
gtl::ArraySlice<NodeOut> x_node_outputs,
gtl::ArraySlice<NodeOut> y_grad_node_outputs,
absl::Span<const NodeOut> y_node_outputs,
absl::Span<const NodeOut> x_node_outputs,
absl::Span<const NodeOut> y_grad_node_outputs,
std::vector<NodeOut>* x_grad_node_outputs, Graph* graph)
: y_node_outputs_(y_node_outputs),
x_node_outputs_(x_node_outputs),
Expand Down Expand Up @@ -405,9 +405,9 @@ Status SymbolicGradientBuilder::Compute() {
return absl::OkStatus();
}

Status AddSymbolicGradients(gtl::ArraySlice<NodeOut> y_node_outputs,
gtl::ArraySlice<NodeOut> x_node_outputs,
gtl::ArraySlice<NodeOut> y_grad_node_outputs,
Status AddSymbolicGradients(absl::Span<const NodeOut> y_node_outputs,
absl::Span<const NodeOut> x_node_outputs,
absl::Span<const NodeOut> y_grad_node_outputs,
std::vector<NodeOut>* x_grad_node_outputs,
Graph* graph) {
SymbolicGradientBuilder builder(y_node_outputs, x_node_outputs,
Expand Down
6 changes: 3 additions & 3 deletions tensorflow/core/common_runtime/gradients.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,9 @@ struct NodeOut {
// implementation only supports gradients for functions). In particular,
// the nodes in 'x_nodes' are currently restricted to have one output.

Status AddSymbolicGradients(gtl::ArraySlice<NodeOut> y_node_outputs,
gtl::ArraySlice<NodeOut> x_node_outputs,
gtl::ArraySlice<NodeOut> y_grad_node_outputs,
Status AddSymbolicGradients(absl::Span<const NodeOut> y_node_outputs,
absl::Span<const NodeOut> x_node_outputs,
absl::Span<const NodeOut> y_grad_node_outputs,
std::vector<NodeOut>* x_grad_node_outputs,
Graph* graph);

Expand Down
4 changes: 2 additions & 2 deletions tensorflow/core/common_runtime/graph_constructor.cc
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ class GraphConstructor {
string default_device;
};

typedef gtl::ArraySlice<const NodeDef*> NodeDefSlice;
typedef absl::Span<const NodeDef* const> NodeDefSlice;

// versions, library, and debug_info may be nullptr
static Status Construct(
Expand Down Expand Up @@ -1534,7 +1534,7 @@ Status ConvertGraphDefToGraph(const GraphConstructorOptions& opts,
}

Status ConvertNodeDefsToGraph(const GraphConstructorOptions& opts,
gtl::ArraySlice<NodeDef> nodes, Graph* g,
absl::Span<const NodeDef> nodes, Graph* g,
const GraphDebugInfo* debug_info) {
ShapeRefiner refiner(TF_GRAPH_DEF_VERSION, g->op_registry());
// TODO(irving): Copy will go away once NodeInfo exists
Expand Down
2 changes: 1 addition & 1 deletion tensorflow/core/common_runtime/graph_constructor.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ extern Status ConvertGraphDefToGraph(const GraphConstructorOptions& opts,
// instantiation.
// TODO(irving): This will turn into std::vector<NodeInfoPtr> soon.
extern Status ConvertNodeDefsToGraph(
const GraphConstructorOptions& opts, gtl::ArraySlice<NodeDef> nodes,
const GraphConstructorOptions& opts, absl::Span<const NodeDef> nodes,
Graph* g, const GraphDebugInfo* debug_info = nullptr);

// Options for calling ImportGraphDef().
Expand Down
5 changes: 2 additions & 3 deletions tensorflow/core/common_runtime/graph_view.h
Original file line number Diff line number Diff line change
Expand Up @@ -111,9 +111,8 @@ struct NodeItem {
// is true if and only if the ith output is consumed by another node.
std::unique_ptr<bool[]> outputs_required;

gtl::MutableArraySlice<EdgeInfo> mutable_output_edges() {
return gtl::MutableArraySlice<EdgeInfo>(output_edge_base(),
num_output_edges);
absl::Span<EdgeInfo> mutable_output_edges() {
return absl::Span<EdgeInfo>(output_edge_base(), num_output_edges);
}

gtl::ArraySlice<EdgeInfo> output_edges() const {
Expand Down

0 comments on commit 29e3c03

Please sign in to comment.