Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 858cf6a

Browse files
committed
Fix merge conflicts mostly due to lint enforcement and LMBD convulsions
2 parents fac9b88 + 3ddeac3 commit 858cf6a

450 files changed

Lines changed: 25818 additions & 14786 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

tensorflow/BUILD

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -428,6 +428,7 @@ filegroup(
428428
"//tensorflow/tools/test:all_files",
429429
"//tensorflow/tools/tfprof:all_files",
430430
"//tensorflow/tools/tfprof/internal:all_files",
431+
"//tensorflow/tools/tfprof/internal/advisor:all_files",
431432
"//tensorflow/user_ops:all_files",
432433
"//third_party/hadoop:all_files",
433434
"//third_party/sycl:all_files",

tensorflow/cc/BUILD

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ cc_library(
3434

3535
tf_cc_test(
3636
name = "framework_gradients_test",
37+
size = "small",
3738
srcs = ["framework/gradients_test.cc"],
3839
deps = [
3940
":cc_ops",
@@ -69,6 +70,7 @@ cc_library(
6970

7071
tf_cc_test(
7172
name = "framework_gradient_checker_test",
73+
size = "small",
7274
srcs = ["framework/gradient_checker_test.cc"],
7375
deps = [
7476
":cc_ops",
@@ -150,6 +152,7 @@ cc_library_with_android_deps(
150152

151153
tf_cc_test(
152154
name = "framework_scope_test",
155+
size = "small",
153156
srcs = ["framework/scope_test.cc"],
154157
deps = [
155158
":ops",
@@ -179,6 +182,7 @@ cc_library_with_android_deps(
179182

180183
tf_cc_test(
181184
name = "client_client_session_test",
185+
size = "small",
182186
srcs = ["client/client_session_test.cc"],
183187
deps = [
184188
":cc_ops",
@@ -213,6 +217,7 @@ cc_library_with_android_deps(
213217

214218
tf_cc_test(
215219
name = "ops_const_op_test",
220+
size = "small",
216221
srcs = ["ops/const_op_test.cc"],
217222
deps = [
218223
":const_op",
@@ -247,6 +252,7 @@ cc_library(
247252

248253
tf_cc_test(
249254
name = "gradients_array_grad_test",
255+
size = "small",
250256
srcs = ["gradients/array_grad_test.cc"],
251257
deps = [
252258
":array_grad",
@@ -277,6 +283,7 @@ cc_library(
277283

278284
tf_cc_test(
279285
name = "gradients_math_grad_test",
286+
size = "small",
280287
srcs = ["gradients/math_grad_test.cc"],
281288
deps = [
282289
":cc_ops",
@@ -307,6 +314,7 @@ cc_library(
307314

308315
tf_cc_test(
309316
name = "gradients_nn_grad_test",
317+
size = "small",
310318
srcs = ["gradients/nn_grad_test.cc"],
311319
deps = [
312320
":cc_ops",
@@ -355,6 +363,7 @@ tf_gen_op_wrappers_cc(
355363

356364
tf_cc_test(
357365
name = "framework_cc_ops_test",
366+
size = "small",
358367
srcs = ["framework/cc_ops_test.cc"],
359368
deps = [
360369
":cc_ops",
@@ -478,7 +487,6 @@ cc_binary(
478487
],
479488
deps = [
480489
":cc_ops",
481-
"//tensorflow/core:all_kernels", # buildcleaner: keep
482490
"//tensorflow/core:core_cpu",
483491
"//tensorflow/core:framework",
484492
"//tensorflow/core:lib",
@@ -550,6 +558,7 @@ cc_library(
550558

551559
tf_cc_test(
552560
name = "coordinator_test",
561+
size = "small",
553562
srcs = ["training/coordinator_test.cc"],
554563
deps = [
555564
":cc_ops",

tensorflow/cc/framework/gradient_checker.cc

Lines changed: 27 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,6 @@ limitations under the License.
2222
#include "tensorflow/core/lib/core/errors.h"
2323

2424
namespace tensorflow {
25-
using namespace ops; // NOLINT(build/namespaces)
26-
2725
namespace {
2826

2927
// TODO(andydavis) Support returning relative error (as opposed to max error)
@@ -39,15 +37,16 @@ Status ComputeTheoreticalJacobianTranspose(
3937
const std::vector<TensorShape>& x_shapes,
4038
const std::vector<Tensor>& x_datas, const OutputList& ys,
4139
const std::vector<TensorShape>& y_shapes,
42-
std::vector<Tensor>& jacobian_ts) {
40+
std::vector<Tensor>* jacobian_ts) {
4341
size_t y_num = y_shapes.size();
4442
size_t x_num = x_shapes.size();
4543
// Call AddSymbolicGradients to get 'dxs' (we will feed 'dys').
4644
OutputList dys;
4745
dys.reserve(y_shapes.size());
4846
for (const auto& y_shape : y_shapes) {
4947
// TODO(suharshs): This currently assumes that all x's are the same type.
50-
dys.push_back(Cast(scope, Const(scope, 1.0, y_shape), xs[0].type()));
48+
dys.push_back(
49+
ops::Cast(scope, ops::Const(scope, 1.0, y_shape), xs[0].type()));
5150
}
5251
OutputList dxs;
5352
TF_RETURN_IF_ERROR(AddSymbolicGradients(scope, ys, xs, dys, &dxs));
@@ -85,7 +84,7 @@ Status ComputeTheoreticalJacobianTranspose(
8584

8685
for (int x_idx = 0; x_idx < x_num; x_idx++) {
8786
const int64 x_size = x_shapes[x_idx].num_elements();
88-
auto jacobian = jacobian_ts[x_idx * y_num + y_idx].matrix<T>();
87+
auto jacobian = (*jacobian_ts)[x_idx * y_num + y_idx].matrix<T>();
8988
auto dx_flat = dxout[x_idx].flat<T>();
9089
for (int r = 0; r < x_size; ++r) {
9190
jacobian(r, c) = dx_flat(r);
@@ -98,20 +97,20 @@ Status ComputeTheoreticalJacobianTranspose(
9897
return Status::OK();
9998
}
10099

101-
Status EvaluateGraph(ClientSession& session, const OutputList& xs,
102-
const OutputList& ys, std::vector<Tensor>& x_datas,
100+
Status EvaluateGraph(ClientSession* session, const OutputList& xs,
101+
const OutputList& ys, std::vector<Tensor>* x_datas,
103102
std::vector<Tensor>* y_datas) {
104103
// Create the feed list.
105104
ClientSession::FeedType feed_list;
106-
for (int i = 0; i < x_datas.size(); i++) {
107-
feed_list.insert({xs[i], x_datas[i]});
105+
for (int i = 0; i < x_datas->size(); i++) {
106+
feed_list.insert({xs[i], (*x_datas)[i]});
108107
}
109108

110-
TF_RETURN_IF_ERROR(session.Run(feed_list, ys, y_datas));
109+
TF_RETURN_IF_ERROR(session->Run(feed_list, ys, y_datas));
111110
for (int y_idx = 0; y_idx < y_datas->size(); y_idx++) {
112-
for (int x_idx = 0; x_idx < x_datas.size(); x_idx++) {
111+
for (int x_idx = 0; x_idx < x_datas->size(); x_idx++) {
113112
Tensor y_data = (*y_datas)[y_idx];
114-
if (y_data.SharesBufferWith(x_datas[x_idx])) {
113+
if (y_data.SharesBufferWith((*x_datas)[x_idx])) {
115114
// Create copies of outputs that share a buffer with any inputs since
116115
// the underlying buffer of the input Tensors are not copied for some
117116
// operations (i.e. Identity), which can lead to incorrect results for
@@ -129,14 +128,14 @@ Status ComputeNumericJacobianTranspose(const Scope& scope, const OutputList& xs,
129128
const OutputList& ys,
130129
const std::vector<TensorShape>& y_shapes,
131130
const T delta,
132-
std::vector<Tensor>& x_datas,
133-
std::vector<Tensor>& jacobian_ts) {
131+
std::vector<Tensor>* x_datas,
132+
std::vector<Tensor>* jacobian_ts) {
134133
size_t y_num = y_shapes.size();
135134
size_t x_num = x_shapes.size();
136135

137136
ClientSession session(scope);
138137
for (int x_idx = 0; x_idx < x_num; x_idx++) {
139-
auto x_data_flat = x_datas[x_idx].flat<T>();
138+
auto x_data_flat = (*x_datas)[x_idx].flat<T>();
140139
const int64 x_size = x_shapes[x_idx].num_elements();
141140

142141
// Compute the numeric Jacobian one column at a time by perturbing each
@@ -148,19 +147,19 @@ Status ComputeNumericJacobianTranspose(const Scope& scope, const OutputList& xs,
148147
// Evaluate at positive delta.
149148
x_data_flat(r) = v + delta;
150149
std::vector<Tensor> y_pos;
151-
TF_RETURN_IF_ERROR(EvaluateGraph(session, xs, ys, x_datas, &y_pos));
150+
TF_RETURN_IF_ERROR(EvaluateGraph(&session, xs, ys, x_datas, &y_pos));
152151
// Evaluate at negative delta.
153152
x_data_flat(r) = v - delta;
154153
std::vector<Tensor> y_neg;
155-
TF_RETURN_IF_ERROR(EvaluateGraph(session, xs, ys, x_datas, &y_neg));
154+
TF_RETURN_IF_ERROR(EvaluateGraph(&session, xs, ys, x_datas, &y_neg));
156155

157156
for (int y_idx = 0; y_idx < y_num; y_idx++) {
158157
// Compute element-wise centered difference and store in each Jacobian.
159158
auto y_pos_flat = y_pos[y_idx].flat<T>();
160159
auto y_neg_flat = y_neg[y_idx].flat<T>();
161160
const int64 y_size = y_shapes[y_idx].num_elements();
162161
const T scale = 2 * delta;
163-
auto jacobian = jacobian_ts[x_idx * y_num + y_idx].matrix<T>();
162+
auto jacobian = (*jacobian_ts)[x_idx * y_num + y_idx].matrix<T>();
164163
for (int c = 0; c < y_size; ++c) {
165164
jacobian(r, c) = (y_pos_flat(c) - y_neg_flat(c)) / scale;
166165
}
@@ -176,19 +175,19 @@ template <typename T>
176175
void InitJacobians(const OutputList& xs,
177176
const std::vector<TensorShape>& x_shapes,
178177
const std::vector<TensorShape>& y_shapes,
179-
std::vector<Tensor>& jacobians) {
178+
std::vector<Tensor>* jacobians) {
180179
size_t y_num = y_shapes.size();
181180
size_t x_num = x_shapes.size();
182181

183-
jacobians.resize(y_num * x_num);
182+
jacobians->resize(y_num * x_num);
184183
for (int x_idx = 0; x_idx < x_num; x_idx++) {
185184
const int64 x_size = x_shapes[x_idx].num_elements();
186185
for (int y_idx = 0; y_idx < y_num; y_idx++) {
187186
const int64 y_size = y_shapes[y_idx].num_elements();
188187
Tensor jacobian_t(xs[x_idx].type(), {x_size, y_size});
189188
auto jacobian_t_flat = jacobian_t.flat<T>();
190189
jacobian_t_flat.setZero();
191-
jacobians[x_idx * y_num + y_idx] = std::move(jacobian_t);
190+
(*jacobians)[x_idx * y_num + y_idx] = std::move(jacobian_t);
192191
}
193192
}
194193
}
@@ -198,23 +197,23 @@ Status ComputeGradientErrorInternal(const Scope& scope, const OutputList& xs,
198197
const std::vector<TensorShape>& x_shapes,
199198
const OutputList& ys,
200199
const std::vector<TensorShape>& y_shapes,
201-
std::vector<Tensor>& x_datas,
200+
std::vector<Tensor>* x_datas,
202201
T* max_error) {
203202
// Initialize theoretical Jacobians to zeros.
204203
std::vector<Tensor> jacobian_ts;
205-
InitJacobians<T>(xs, x_shapes, y_shapes, jacobian_ts);
204+
InitJacobians<T>(xs, x_shapes, y_shapes, &jacobian_ts);
206205

207206
// Compute theoretical Jacobian.
208207
TF_RETURN_IF_ERROR(ComputeTheoreticalJacobianTranspose<T>(
209-
scope, xs, x_shapes, x_datas, ys, y_shapes, jacobian_ts));
208+
scope, xs, x_shapes, *x_datas, ys, y_shapes, &jacobian_ts));
210209

211210
// Initialize numeric Jacobian to zeros.
212211
std::vector<Tensor> jacobian_ns;
213-
InitJacobians<T>(xs, x_shapes, y_shapes, jacobian_ns);
212+
InitJacobians<T>(xs, x_shapes, y_shapes, &jacobian_ns);
214213

215214
// Compute numeric Jacobian.
216215
TF_RETURN_IF_ERROR(ComputeNumericJacobianTranspose<T>(
217-
scope, xs, x_shapes, ys, y_shapes, 1e-3, x_datas, jacobian_ns));
216+
scope, xs, x_shapes, ys, y_shapes, 1e-3, x_datas, &jacobian_ns));
218217

219218
for (int i = 0; i < jacobian_ts.size(); i++) {
220219
// Compute the maximum error between theoretical and numeric Jacobians.
@@ -257,7 +256,7 @@ Status ComputeGradientError(const Scope& scope, const OutputList& xs,
257256
}
258257
// Compute gradient error.
259258
return ComputeGradientErrorInternal(scope, xs, x_shapes, ys, y_shapes,
260-
x_datas, max_error);
259+
&x_datas, max_error);
261260
}
262261

263262
template <typename T>
@@ -268,7 +267,7 @@ Status ComputeGradientError(const Scope& scope, const Output& x,
268267
std::vector<Tensor> x_datas(1, Tensor(x_init_value));
269268
// Compute gradient error.
270269
return ComputeGradientErrorInternal(scope, {x}, {x_datas[0].shape()}, {y},
271-
{y_shape}, x_datas, max_error);
270+
{y_shape}, &x_datas, max_error);
272271
}
273272

274273
#define INSTANTIATE_GRAD_ERR_TYPE(T) \

tensorflow/compiler/aot/BUILD

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ cc_library(
2020

2121
cc_test(
2222
name = "runtime_test",
23+
size = "small",
2324
srcs = ["runtime_test.cc"],
2425
deps = [
2526
":runtime",
@@ -88,6 +89,7 @@ cc_library(
8889

8990
cc_test(
9091
name = "codegen_test",
92+
size = "small",
9193
srcs = ["codegen_test.cc"],
9294
data = ["codegen_test_h.golden"],
9395
deps = [
@@ -101,6 +103,7 @@ cc_test(
101103

102104
cc_test(
103105
name = "tfcompile_util_test",
106+
size = "small",
104107
srcs = ["tfcompile_util_test.cc"],
105108
deps = [
106109
":tfcompile_lib",

tensorflow/compiler/aot/tests/BUILD

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,15 +43,16 @@ genrule(
4343
testonly = 1,
4444
outs = [
4545
"test_graph_tfadd.pb",
46-
"test_graph_tfadd_with_ckpt.pb",
4746
"test_graph_tfadd_with_ckpt.ckpt",
48-
"test_graph_tfadd_with_ckpt_saver.pb",
47+
"test_graph_tfadd_with_ckpt.pb",
4948
"test_graph_tfadd_with_ckpt_saver.ckpt",
49+
"test_graph_tfadd_with_ckpt_saver.pb",
5050
"test_graph_tfadd_with_ckpt_saver.saver",
51+
"test_graph_tffunction.pb",
5152
"test_graph_tfgather.pb",
5253
"test_graph_tfmatmul.pb",
5354
"test_graph_tfmatmulandadd.pb",
54-
"test_graph_tffunction.pb",
55+
"test_graph_tfsplits.pb",
5556
],
5657
cmd = "$(location :make_test_graphs) --out_dir $(@D)",
5758
tags = ["manual"],
@@ -124,6 +125,15 @@ tf_library(
124125
tags = ["manual"],
125126
)
126127

128+
tf_library(
129+
name = "test_graph_tfsplits",
130+
testonly = 1,
131+
config = "test_graph_tfsplits.config.pbtxt",
132+
cpp_class = "SplitsComp",
133+
graph = "test_graph_tfsplits.pb",
134+
tags = ["manual"],
135+
)
136+
127137
cc_test(
128138
name = "tfcompile_test",
129139
srcs = ["tfcompile_test.cc"],
@@ -136,6 +146,7 @@ cc_test(
136146
":test_graph_tfgather",
137147
":test_graph_tfmatmul",
138148
":test_graph_tfmatmulandadd",
149+
":test_graph_tfsplits",
139150
"//tensorflow/core:test",
140151
"//tensorflow/core:test_main",
141152
"//third_party/eigen3",

tensorflow/compiler/aot/tests/make_test_graphs.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,23 @@ def test_func(a, b):
107107
test_func(x, y, name='func_call') # pylint: disable=unexpected-keyword-arg
108108

109109

110+
def tfsplits(_):
111+
"""A more complex graph, including splits."""
112+
x = array_ops.placeholder(dtypes.float32, shape=[2, 2], name='x')
113+
y = array_ops.placeholder(dtypes.float32, shape=[2, 2], name='y')
114+
for _ in range(3):
115+
x0, x1 = array_ops.split(x, 2, 0)
116+
y0, y1 = array_ops.split(y, 2, 0)
117+
x0 += 1
118+
y0 += 1
119+
z = math_ops.matmul(x, y, name='x_y_prod')
120+
a = array_ops.concat([x0, y1], axis=0, name='concat_x0_y1')
121+
b = array_ops.concat([y0, x1], axis=0, name='concat_y0_x1')
122+
x = math_ops.matmul(a, b, name='a_b')
123+
y = math_ops.add(x, z)
124+
array_ops.identity(y, name='result')
125+
126+
110127
def write_graph(build_graph, out_dir):
111128
"""Build a graph using build_graph and write it out."""
112129
g = ops.Graph()
@@ -125,6 +142,7 @@ def main(_):
125142
write_graph(tfmatmul, FLAGS.out_dir)
126143
write_graph(tfmatmulandadd, FLAGS.out_dir)
127144
write_graph(tffunction, FLAGS.out_dir)
145+
write_graph(tfsplits, FLAGS.out_dir)
128146

129147

130148
if __name__ == '__main__':
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Text form of tensorflow.tfcompile.Config proto.
2+
feed {
3+
id { node_name: "x" }
4+
shape {
5+
dim { size: 2 }
6+
dim { size: 2 }
7+
}
8+
}
9+
feed {
10+
id { node_name: "y" }
11+
shape {
12+
dim { size: 2 }
13+
dim { size: 2 }
14+
}
15+
}
16+
fetch {
17+
id { node_name: "result" }
18+
}

0 commit comments

Comments
 (0)