1d7639d5e25ba540f8f0f4bc8e555096ee700fb53A. Unique TensorFlower/* Copyright 2016 The TensorFlow Authors. All Rights Reserved.
2d7639d5e25ba540f8f0f4bc8e555096ee700fb53A. Unique TensorFlower
3d7639d5e25ba540f8f0f4bc8e555096ee700fb53A. Unique TensorFlowerLicensed under the Apache License, Version 2.0 (the "License");
4d7639d5e25ba540f8f0f4bc8e555096ee700fb53A. Unique TensorFlower
5d7639d5e25ba540f8f0f4bc8e555096ee700fb53A. Unique TensorFlowerYou may obtain a copy of the License at
6d7639d5e25ba540f8f0f4bc8e555096ee700fb53A. Unique TensorFlower
7d7639d5e25ba540f8f0f4bc8e555096ee700fb53A. Unique TensorFlower    http://www.apache.org/licenses/LICENSE-2.0
8d7639d5e25ba540f8f0f4bc8e555096ee700fb53A. Unique TensorFlower
9d7639d5e25ba540f8f0f4bc8e555096ee700fb53A. Unique TensorFlowerUnless required by applicable law or agreed to in writing, software
10d7639d5e25ba540f8f0f4bc8e555096ee700fb53A. Unique TensorFlowerdistributed under the License is distributed on an "AS IS" BASIS,
11d7639d5e25ba540f8f0f4bc8e555096ee700fb53A. Unique TensorFlowerWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12d7639d5e25ba540f8f0f4bc8e555096ee700fb53A. Unique TensorFlowerSee the License for the specific language governing permissions and
13d7639d5e25ba540f8f0f4bc8e555096ee700fb53A. Unique TensorFlowerlimitations under the License.
14d7639d5e25ba540f8f0f4bc8e555096ee700fb53A. Unique TensorFlower==============================================================================*/
15d7639d5e25ba540f8f0f4bc8e555096ee700fb53A. Unique TensorFlower
16d7639d5e25ba540f8f0f4bc8e555096ee700fb53A. Unique TensorFlower#include "tensorflow/core/framework/op.h"
17d7639d5e25ba540f8f0f4bc8e555096ee700fb53A. Unique TensorFlower#include "tensorflow/core/framework/shape_inference_testutil.h"
18d7639d5e25ba540f8f0f4bc8e555096ee700fb53A. Unique TensorFlower#include "tensorflow/core/platform/test.h"
19d7639d5e25ba540f8f0f4bc8e555096ee700fb53A. Unique TensorFlower
20d7639d5e25ba540f8f0f4bc8e555096ee700fb53A. Unique TensorFlowernamespace tensorflow {
21d7639d5e25ba540f8f0f4bc8e555096ee700fb53A. Unique TensorFlower
22075d1ab68fcaf5ddd90c3d30f6a046b78c3c04f3A. Unique TensorFlower// Used for testing the grad+indices handling for SparseApplyXYZ tests.
231d0b8c007b8bc7f77dd63c74f02d87185071f038Peter Hawkinsstatic void TestGradAndIndicesErrorHandling(const ShapeInferenceTestOp& op,
24075d1ab68fcaf5ddd90c3d30f6a046b78c3c04f3A. Unique TensorFlower                                            string shape_spec_middle,
251d0b8c007b8bc7f77dd63c74f02d87185071f038Peter Hawkins                                            const string& shape_spec_end = "") {
26075d1ab68fcaf5ddd90c3d30f6a046b78c3c04f3A. Unique TensorFlower  auto shape_spec = [&shape_spec_middle, shape_spec_end](
27982549ea3423df4270ff154e5c764beb43d472daRasmus Munk Larsen                        const char* var_spec, const char* grad_indices_spec) {
28075d1ab68fcaf5ddd90c3d30f6a046b78c3c04f3A. Unique TensorFlower    return strings::StrCat(var_spec, ";", shape_spec_middle, ";",
29075d1ab68fcaf5ddd90c3d30f6a046b78c3c04f3A. Unique TensorFlower                           grad_indices_spec, shape_spec_end);
30075d1ab68fcaf5ddd90c3d30f6a046b78c3c04f3A. Unique TensorFlower  };
31075d1ab68fcaf5ddd90c3d30f6a046b78c3c04f3A. Unique TensorFlower
327946b8481f73cf6d91375400237b7bcce545e7beA. Unique TensorFlower  // mismatch between grad[1] and var[1].
337946b8481f73cf6d91375400237b7bcce545e7beA. Unique TensorFlower  INFER_ERROR("Dimension 1 in both shapes must be equal", op,
34dcc3cdce8d44b9eb6b105ec7e770e297bacfc215A. Unique TensorFlower              shape_spec("[?,1]", "[?,2];[?]"));
35075d1ab68fcaf5ddd90c3d30f6a046b78c3c04f3A. Unique TensorFlower  // grad[0] and indices[0] must match.
36075d1ab68fcaf5ddd90c3d30f6a046b78c3c04f3A. Unique TensorFlower  INFER_ERROR("Dimensions must be equal, but are 1 and 2", op,
37dcc3cdce8d44b9eb6b105ec7e770e297bacfc215A. Unique TensorFlower              shape_spec("?", "[2,?];[1]"));
38075d1ab68fcaf5ddd90c3d30f6a046b78c3c04f3A. Unique TensorFlower  // grad is wrong rank.
39dcc3cdce8d44b9eb6b105ec7e770e297bacfc215A. Unique TensorFlower  INFER_ERROR("must be equal rank", op, shape_spec("[1]", "[?,2];[?]"));
40075d1ab68fcaf5ddd90c3d30f6a046b78c3c04f3A. Unique TensorFlower  // indices is wrong rank.
41075d1ab68fcaf5ddd90c3d30f6a046b78c3c04f3A. Unique TensorFlower  INFER_ERROR("Shape must be rank 1 but is rank 2", op,
42dcc3cdce8d44b9eb6b105ec7e770e297bacfc215A. Unique TensorFlower              shape_spec("[?]", "[?];[1,2]"));
43075d1ab68fcaf5ddd90c3d30f6a046b78c3c04f3A. Unique TensorFlower}
44075d1ab68fcaf5ddd90c3d30f6a046b78c3c04f3A. Unique TensorFlower
45d7639d5e25ba540f8f0f4bc8e555096ee700fb53A. Unique TensorFlowerTEST(TrainingOpsTest, ApplyGradientDescent_ShapeFn) {
46d7639d5e25ba540f8f0f4bc8e555096ee700fb53A. Unique TensorFlower  ShapeInferenceTestOp op("ApplyGradientDescent");
47d7639d5e25ba540f8f0f4bc8e555096ee700fb53A. Unique TensorFlower
48d7639d5e25ba540f8f0f4bc8e555096ee700fb53A. Unique TensorFlower  // Output is a merge of inputs 0 and 2 (var and delta).
49d7639d5e25ba540f8f0f4bc8e555096ee700fb53A. Unique TensorFlower  INFER_OK(op, "[1,?];[];[?,2]", "[d0_0,d2_1]");
50d7639d5e25ba540f8f0f4bc8e555096ee700fb53A. Unique TensorFlower  INFER_ERROR("Dimension 0 in both shapes must be equal, but are 1 and 2", op,
51d7639d5e25ba540f8f0f4bc8e555096ee700fb53A. Unique TensorFlower              "[1];[];[2]");
52d7639d5e25ba540f8f0f4bc8e555096ee700fb53A. Unique TensorFlower
53d7639d5e25ba540f8f0f4bc8e555096ee700fb53A. Unique TensorFlower  // alpha must be a scalar.
54d7639d5e25ba540f8f0f4bc8e555096ee700fb53A. Unique TensorFlower  INFER_ERROR("Shape must be rank 0 but is rank 1", op, "?;[?];?");
55d7639d5e25ba540f8f0f4bc8e555096ee700fb53A. Unique TensorFlower}
56d7639d5e25ba540f8f0f4bc8e555096ee700fb53A. Unique TensorFlower
57075d1ab68fcaf5ddd90c3d30f6a046b78c3c04f3A. Unique TensorFlowerTEST(TrainingOpsTest, ApplyProximalGradientDescent_ShapeFn) {
58d7639d5e25ba540f8f0f4bc8e555096ee700fb53A. Unique TensorFlower  ShapeInferenceTestOp op("ApplyProximalGradientDescent");
59d7639d5e25ba540f8f0f4bc8e555096ee700fb53A. Unique TensorFlower
60d7639d5e25ba540f8f0f4bc8e555096ee700fb53A. Unique TensorFlower  // Output is a merge of inputs 0 and 4 (var and delta).
61d7639d5e25ba540f8f0f4bc8e555096ee700fb53A. Unique TensorFlower  INFER_OK(op, "[1,?];[];[];[];[?,2]", "[d0_0,d4_1]");
62d7639d5e25ba540f8f0f4bc8e555096ee700fb53A. Unique TensorFlower  INFER_ERROR("Dimension 0 in both shapes must be equal, but are 1 and 2", op,
63d7639d5e25ba540f8f0f4bc8e555096ee700fb53A. Unique TensorFlower              "[1];[];[];[];[2]");
64d7639d5e25ba540f8f0f4bc8e555096ee700fb53A. Unique TensorFlower
65d7639d5e25ba540f8f0f4bc8e555096ee700fb53A. Unique TensorFlower  // alpha, l1, and l2 must be scalars.
66d7639d5e25ba540f8f0f4bc8e555096ee700fb53A. Unique TensorFlower  INFER_ERROR("Shape must be rank 0 but is rank 1", op, "?;[?];?;?;?");
67d7639d5e25ba540f8f0f4bc8e555096ee700fb53A. Unique TensorFlower  INFER_ERROR("Shape must be rank 0 but is rank 1", op, "?;?;[?];?;?");
68d7639d5e25ba540f8f0f4bc8e555096ee700fb53A. Unique TensorFlower  INFER_ERROR("Shape must be rank 0 but is rank 1", op, "?;?;?;[?];?");
69d7639d5e25ba540f8f0f4bc8e555096ee700fb53A. Unique TensorFlower}
70d7639d5e25ba540f8f0f4bc8e555096ee700fb53A. Unique TensorFlower
71075d1ab68fcaf5ddd90c3d30f6a046b78c3c04f3A. Unique TensorFlowerTEST(TrainingOpsTest, SparseApplyProximalGradientDescent_ShapeFn) {
72075d1ab68fcaf5ddd90c3d30f6a046b78c3c04f3A. Unique TensorFlower  ShapeInferenceTestOp op("SparseApplyProximalGradientDescent");
73075d1ab68fcaf5ddd90c3d30f6a046b78c3c04f3A. Unique TensorFlower
74075d1ab68fcaf5ddd90c3d30f6a046b78c3c04f3A. Unique TensorFlower  // Output is a merge of inputs 0 (var) and the non-indices part of 4 (delta).
757946b8481f73cf6d91375400237b7bcce545e7beA. Unique TensorFlower  INFER_OK(op, "[1,?];[];[];[];[?,2];[3]", "[d0_0,d4_1]");
76075d1ab68fcaf5ddd90c3d30f6a046b78c3c04f3A. Unique TensorFlower
77075d1ab68fcaf5ddd90c3d30f6a046b78c3c04f3A. Unique TensorFlower  TestGradAndIndicesErrorHandling(op, "[];[];[]");
78075d1ab68fcaf5ddd90c3d30f6a046b78c3c04f3A. Unique TensorFlower
79075d1ab68fcaf5ddd90c3d30f6a046b78c3c04f3A. Unique TensorFlower  // alpha, l1, and l2 must be scalars.
80075d1ab68fcaf5ddd90c3d30f6a046b78c3c04f3A. Unique TensorFlower  INFER_ERROR("Shape must be rank 0 but is rank 1", op, "?;[?];?;?;?;?");
81075d1ab68fcaf5ddd90c3d30f6a046b78c3c04f3A. Unique TensorFlower  INFER_ERROR("Shape must be rank 0 but is rank 1", op, "?;?;[?];?;?;?");
82075d1ab68fcaf5ddd90c3d30f6a046b78c3c04f3A. Unique TensorFlower  INFER_ERROR("Shape must be rank 0 but is rank 1", op, "?;?;?;[?];?;?");
83075d1ab68fcaf5ddd90c3d30f6a046b78c3c04f3A. Unique TensorFlower}
84075d1ab68fcaf5ddd90c3d30f6a046b78c3c04f3A. Unique TensorFlower
85d7639d5e25ba540f8f0f4bc8e555096ee700fb53A. Unique TensorFlowerTEST(TrainingOpsTest, ApplyAdadelta_ShapeFn) {
86d7639d5e25ba540f8f0f4bc8e555096ee700fb53A. Unique TensorFlower  ShapeInferenceTestOp op("ApplyAdadelta");
87d7639d5e25ba540f8f0f4bc8e555096ee700fb53A. Unique TensorFlower
88d7639d5e25ba540f8f0f4bc8e555096ee700fb53A. Unique TensorFlower  // Output is a merge of inputs 0, 1, 2, and 6 (var, accum, accum_update,
89d7639d5e25ba540f8f0f4bc8e555096ee700fb53A. Unique TensorFlower  // grad).
90d7639d5e25ba540f8f0f4bc8e555096ee700fb53A. Unique TensorFlower  INFER_OK(op, "[1,?,?,?];[?,2,?,?];[?,?,3,?];[];[];[];[?,?,?,4]",
91d7639d5e25ba540f8f0f4bc8e555096ee700fb53A. Unique TensorFlower           "[d0_0,d1_1,d2_2,d6_3]");
92d7639d5e25ba540f8f0f4bc8e555096ee700fb53A. Unique TensorFlower  INFER_ERROR("Dimension 0 in both shapes must be equal, but are 1 and 2", op,
93d7639d5e25ba540f8f0f4bc8e555096ee700fb53A. Unique TensorFlower              "[1];[2];[1];[];[];[];[1]");
94d7639d5e25ba540f8f0f4bc8e555096ee700fb53A. Unique TensorFlower  INFER_ERROR("Dimension 0 in both shapes must be equal, but are 1 and 2", op,
95d7639d5e25ba540f8f0f4bc8e555096ee700fb53A. Unique TensorFlower              "[1];[1];[2];[];[];[];[1]");
96d7639d5e25ba540f8f0f4bc8e555096ee700fb53A. Unique TensorFlower  INFER_ERROR("Dimension 0 in both shapes must be equal, but are 1 and 2", op,
97d7639d5e25ba540f8f0f4bc8e555096ee700fb53A. Unique TensorFlower              "[1];[1];[1];[];[];[];[2]");
98d7639d5e25ba540f8f0f4bc8e555096ee700fb53A. Unique TensorFlower
99d7639d5e25ba540f8f0f4bc8e555096ee700fb53A. Unique TensorFlower  // lr, rho, and episilon must be scalars.
100d7639d5e25ba540f8f0f4bc8e555096ee700fb53A. Unique TensorFlower  INFER_ERROR("Shape must be rank 0 but is rank 1", op, "?;?;?;[?];?;?;?");
101d7639d5e25ba540f8f0f4bc8e555096ee700fb53A. Unique TensorFlower  INFER_ERROR("Shape must be rank 0 but is rank 1", op, "?;?;?;?;[?];?;?");
102d7639d5e25ba540f8f0f4bc8e555096ee700fb53A. Unique TensorFlower  INFER_ERROR("Shape must be rank 0 but is rank 1", op, "?;?;?;?;?;[?];?");
103d7639d5e25ba540f8f0f4bc8e555096ee700fb53A. Unique TensorFlower}
104d7639d5e25ba540f8f0f4bc8e555096ee700fb53A. Unique TensorFlower
105075d1ab68fcaf5ddd90c3d30f6a046b78c3c04f3A. Unique TensorFlowerTEST(TrainingOpsTest, SparseApplyAdadelta_ShapeFn) {
106075d1ab68fcaf5ddd90c3d30f6a046b78c3c04f3A. Unique TensorFlower  ShapeInferenceTestOp op("SparseApplyAdadelta");
107075d1ab68fcaf5ddd90c3d30f6a046b78c3c04f3A. Unique TensorFlower
108075d1ab68fcaf5ddd90c3d30f6a046b78c3c04f3A. Unique TensorFlower  // Output is a merge of inputs 0, 1, 2, and non-indices part of 6 (var, accum,
109075d1ab68fcaf5ddd90c3d30f6a046b78c3c04f3A. Unique TensorFlower  // accum_update, grad).
1107946b8481f73cf6d91375400237b7bcce545e7beA. Unique TensorFlower  INFER_OK(op, "[1,?,?,?];[?,2,?,?];[?,?,3,?];[];[];[];[?,?,?,4];?",
1117946b8481f73cf6d91375400237b7bcce545e7beA. Unique TensorFlower           "[d0_0,d1_1,d2_2,d6_3]");
112075d1ab68fcaf5ddd90c3d30f6a046b78c3c04f3A. Unique TensorFlower  INFER_ERROR("Dimension 0 in both shapes must be equal, but are 1 and 2", op,
113075d1ab68fcaf5ddd90c3d30f6a046b78c3c04f3A. Unique TensorFlower              "[1];[2];[1];[];[];[];[1];?");
114075d1ab68fcaf5ddd90c3d30f6a046b78c3c04f3A. Unique TensorFlower  INFER_ERROR("Dimension 0 in both shapes must be equal, but are 1 and 2", op,
115075d1ab68fcaf5ddd90c3d30f6a046b78c3c04f3A. Unique TensorFlower              "[1];[1];[2];[];[];[];[1];?");
1167946b8481f73cf6d91375400237b7bcce545e7beA. Unique TensorFlower  INFER_ERROR("Dimension 1 in both shapes must be equal, but are 1 and 2", op,
1177946b8481f73cf6d91375400237b7bcce545e7beA. Unique TensorFlower              "[?,1];[?,1];[?,1];[];[];[];[?,2];?");
118075d1ab68fcaf5ddd90c3d30f6a046b78c3c04f3A. Unique TensorFlower
119075d1ab68fcaf5ddd90c3d30f6a046b78c3c04f3A. Unique TensorFlower  TestGradAndIndicesErrorHandling(op, "?;?;?;?;?");
120075d1ab68fcaf5ddd90c3d30f6a046b78c3c04f3A. Unique TensorFlower
121075d1ab68fcaf5ddd90c3d30f6a046b78c3c04f3A. Unique TensorFlower  // lr, rho, and episilon must be scalars.
122075d1ab68fcaf5ddd90c3d30f6a046b78c3c04f3A. Unique TensorFlower  INFER_ERROR("Shape must be rank 0 but is rank 1", op, "?;?;?;[?];?;?;?;?");
123075d1ab68fcaf5ddd90c3d30f6a046b78c3c04f3A. Unique TensorFlower  INFER_ERROR("Shape must be rank 0 but is rank 1", op, "?;?;?;?;[?];?;?;?");
124075d1ab68fcaf5ddd90c3d30f6a046b78c3c04f3A. Unique TensorFlower  INFER_ERROR("Shape must be rank 0 but is rank 1", op, "?;?;?;?;?;[?];?;?");
125075d1ab68fcaf5ddd90c3d30f6a046b78c3c04f3A. Unique TensorFlower}
126075d1ab68fcaf5ddd90c3d30f6a046b78c3c04f3A. Unique TensorFlower
127d7639d5e25ba540f8f0f4bc8e555096ee700fb53A. Unique TensorFlowerTEST(TrainingOpsTest, ApplyAdagrad_ShapeFn) {
128d7639d5e25ba540f8f0f4bc8e555096ee700fb53A. Unique TensorFlower  ShapeInferenceTestOp op("ApplyAdagrad");
129d7639d5e25ba540f8f0f4bc8e555096ee700fb53A. Unique TensorFlower
130d7639d5e25ba540f8f0f4bc8e555096ee700fb53A. Unique TensorFlower  // Output is a merge of inputs 0, 1, and 3 (var, accum, grad).
131d7639d5e25ba540f8f0f4bc8e555096ee700fb53A. Unique TensorFlower  INFER_OK(op, "[1,?,?];[?,2,?];[];[?,?,3]", "[d0_0,d1_1,d3_2]");
132d7639d5e25ba540f8f0f4bc8e555096ee700fb53A. Unique TensorFlower  INFER_ERROR("Dimension 0 in both shapes must be equal, but are 1 and 2", op,
133d7639d5e25ba540f8f0f4bc8e555096ee700fb53A. Unique TensorFlower              "[1];[2];[];[1]");
134d7639d5e25ba540f8f0f4bc8e555096ee700fb53A. Unique TensorFlower  INFER_ERROR("Dimension 0 in both shapes must be equal, but are 1 and 2", op,
135d7639d5e25ba540f8f0f4bc8e555096ee700fb53A. Unique TensorFlower              "[1];[1];[];[2]");
136d7639d5e25ba540f8f0f4bc8e555096ee700fb53A. Unique TensorFlower
137d7639d5e25ba540f8f0f4bc8e555096ee700fb53A. Unique TensorFlower  // lr must be a scalar.
138d7639d5e25ba540f8f0f4bc8e555096ee700fb53A. Unique TensorFlower  INFER_ERROR("Shape must be rank 0 but is rank 1", op, "?;?;[?];?");
139d7639d5e25ba540f8f0f4bc8e555096ee700fb53A. Unique TensorFlower}
140d7639d5e25ba540f8f0f4bc8e555096ee700fb53A. Unique TensorFlower
141075d1ab68fcaf5ddd90c3d30f6a046b78c3c04f3A. Unique TensorFlowerTEST(TrainingOpsTest, SparseApplyAdagrad_ShapeFn) {
142075d1ab68fcaf5ddd90c3d30f6a046b78c3c04f3A. Unique TensorFlower  ShapeInferenceTestOp op("SparseApplyAdagrad");
143075d1ab68fcaf5ddd90c3d30f6a046b78c3c04f3A. Unique TensorFlower
144075d1ab68fcaf5ddd90c3d30f6a046b78c3c04f3A. Unique TensorFlower  // Output is a merge of inputs 0, 1, and non-indices part of 3 (var, accum,
145075d1ab68fcaf5ddd90c3d30f6a046b78c3c04f3A. Unique TensorFlower  // grad).
1467946b8481f73cf6d91375400237b7bcce545e7beA. Unique TensorFlower  INFER_OK(op, "[1,?,?];[?,2,?];[];[?,?,3];?", "[d0_0,d1_1,d3_2]");
1477946b8481f73cf6d91375400237b7bcce545e7beA. Unique TensorFlower  INFER_ERROR("Dimension 1 in both shapes must be equal, but are 1 and 2", op,
1487946b8481f73cf6d91375400237b7bcce545e7beA. Unique TensorFlower              "[?,1];[?,2];[];[?,1];?");
1497946b8481f73cf6d91375400237b7bcce545e7beA. Unique TensorFlower  INFER_ERROR("Shapes must be equal rank, but are 2 and 3", op,
1507946b8481f73cf6d91375400237b7bcce545e7beA. Unique TensorFlower              "[?,1];[?,1];[];[?,?,2];?");
151075d1ab68fcaf5ddd90c3d30f6a046b78c3c04f3A. Unique TensorFlower
152075d1ab68fcaf5ddd90c3d30f6a046b78c3c04f3A. Unique TensorFlower  TestGradAndIndicesErrorHandling(op, "?;?");
153075d1ab68fcaf5ddd90c3d30f6a046b78c3c04f3A. Unique TensorFlower
154075d1ab68fcaf5ddd90c3d30f6a046b78c3c04f3A. Unique TensorFlower  // lr must be a scalar.
155075d1ab68fcaf5ddd90c3d30f6a046b78c3c04f3A. Unique TensorFlower  INFER_ERROR("Shape must be rank 0 but is rank 1", op, "?;?;[?];?;?");
156075d1ab68fcaf5ddd90c3d30f6a046b78c3c04f3A. Unique TensorFlower}
157075d1ab68fcaf5ddd90c3d30f6a046b78c3c04f3A. Unique TensorFlower
158d7639d5e25ba540f8f0f4bc8e555096ee700fb53A. Unique TensorFlowerTEST(TrainingOpsTest, ApplyProximalAdagrad_ShapeFn) {
159d7639d5e25ba540f8f0f4bc8e555096ee700fb53A. Unique TensorFlower  ShapeInferenceTestOp op("ApplyProximalAdagrad");
160d7639d5e25ba540f8f0f4bc8e555096ee700fb53A. Unique TensorFlower
161d7639d5e25ba540f8f0f4bc8e555096ee700fb53A. Unique TensorFlower  // Output is a merge of inputs 0, 1, and 5 (var, accum, grad).
162d7639d5e25ba540f8f0f4bc8e555096ee700fb53A. Unique TensorFlower  INFER_OK(op, "[1,?,?];[?,2,?];[];[];[];[?,?,3]", "[d0_0,d1_1,d5_2]");
163d7639d5e25ba540f8f0f4bc8e555096ee700fb53A. Unique TensorFlower  INFER_ERROR("Dimension 0 in both shapes must be equal, but are 1 and 2", op,
164d7639d5e25ba540f8f0f4bc8e555096ee700fb53A. Unique TensorFlower              "[1];[2];[];[];[];[1]");
165d7639d5e25ba540f8f0f4bc8e555096ee700fb53A. Unique TensorFlower  INFER_ERROR("Dimension 0 in both shapes must be equal, but are 1 and 2", op,
166d7639d5e25ba540f8f0f4bc8e555096ee700fb53A. Unique TensorFlower              "[1];[1];[];[];[];[2]");
167d7639d5e25ba540f8f0f4bc8e555096ee700fb53A. Unique TensorFlower
168d7639d5e25ba540f8f0f4bc8e555096ee700fb53A. Unique TensorFlower  // lr, l1, and l2 must be scalars.
169d7639d5e25ba540f8f0f4bc8e555096ee700fb53A. Unique TensorFlower  INFER_ERROR("Shape must be rank 0 but is rank 1", op, "?;?;[?];?;?;?");
170d7639d5e25ba540f8f0f4bc8e555096ee700fb53A. Unique TensorFlower  INFER_ERROR("Shape must be rank 0 but is rank 1", op, "?;?;?;[?];?;?");
171d7639d5e25ba540f8f0f4bc8e555096ee700fb53A. Unique TensorFlower  INFER_ERROR("Shape must be rank 0 but is rank 1", op, "?;?;?;?;[?];?");
172d7639d5e25ba540f8f0f4bc8e555096ee700fb53A. Unique TensorFlower}
173d7639d5e25ba540f8f0f4bc8e555096ee700fb53A. Unique TensorFlower
174075d1ab68fcaf5ddd90c3d30f6a046b78c3c04f3A. Unique TensorFlowerTEST(TrainingOpsTest, SparseApplyProximalAdagrad_ShapeFn) {
175075d1ab68fcaf5ddd90c3d30f6a046b78c3c04f3A. Unique TensorFlower  ShapeInferenceTestOp op("SparseApplyProximalAdagrad");
176075d1ab68fcaf5ddd90c3d30f6a046b78c3c04f3A. Unique TensorFlower
177075d1ab68fcaf5ddd90c3d30f6a046b78c3c04f3A. Unique TensorFlower  // Output is a merge of inputs 0, 1, and the non-indices part of 5 (var,
178075d1ab68fcaf5ddd90c3d30f6a046b78c3c04f3A. Unique TensorFlower  // accum, grad).
1797946b8481f73cf6d91375400237b7bcce545e7beA. Unique TensorFlower  INFER_OK(op, "[1,?,?];[?,2,?];[];[];[];[?,?,3];?", "[d0_0,d1_1,d5_2]");
180075d1ab68fcaf5ddd90c3d30f6a046b78c3c04f3A. Unique TensorFlower  INFER_ERROR("Dimension 0 in both shapes must be equal, but are 1 and 2", op,
181075d1ab68fcaf5ddd90c3d30f6a046b78c3c04f3A. Unique TensorFlower              "[1];[2];[];[];[];[?,1];?");
1827946b8481f73cf6d91375400237b7bcce545e7beA. Unique TensorFlower  INFER_ERROR("Dimension 1 in both shapes must be equal, but are 1 and 2", op,
1837946b8481f73cf6d91375400237b7bcce545e7beA. Unique TensorFlower              "[?,1];[?,1];[];[];[];[?,2];?");
184075d1ab68fcaf5ddd90c3d30f6a046b78c3c04f3A. Unique TensorFlower
185075d1ab68fcaf5ddd90c3d30f6a046b78c3c04f3A. Unique TensorFlower  TestGradAndIndicesErrorHandling(op, "?;?;?;?");
186075d1ab68fcaf5ddd90c3d30f6a046b78c3c04f3A. Unique TensorFlower
187075d1ab68fcaf5ddd90c3d30f6a046b78c3c04f3A. Unique TensorFlower  // lr, l1, and l2 must be scalars.
188075d1ab68fcaf5ddd90c3d30f6a046b78c3c04f3A. Unique TensorFlower  INFER_ERROR("Shape must be rank 0 but is rank 1", op, "?;?;[?];?;?;?;?");
189075d1ab68fcaf5ddd90c3d30f6a046b78c3c04f3A. Unique TensorFlower  INFER_ERROR("Shape must be rank 0 but is rank 1", op, "?;?;?;[?];?;?;?");
190075d1ab68fcaf5ddd90c3d30f6a046b78c3c04f3A. Unique TensorFlower  INFER_ERROR("Shape must be rank 0 but is rank 1", op, "?;?;?;?;[?];?;?");
191075d1ab68fcaf5ddd90c3d30f6a046b78c3c04f3A. Unique TensorFlower}
192075d1ab68fcaf5ddd90c3d30f6a046b78c3c04f3A. Unique TensorFlower
193d7639d5e25ba540f8f0f4bc8e555096ee700fb53A. Unique TensorFlowerTEST(TrainingOpsTest, ApplyFtrl_ShapeFn) {
194d7639d5e25ba540f8f0f4bc8e555096ee700fb53A. Unique TensorFlower  ShapeInferenceTestOp op("ApplyFtrl");
195d7639d5e25ba540f8f0f4bc8e555096ee700fb53A. Unique TensorFlower
196d7639d5e25ba540f8f0f4bc8e555096ee700fb53A. Unique TensorFlower  // Output is a merge of inputs 0, 1, 2, and 3 (var, accum, linear, grad).
197d7639d5e25ba540f8f0f4bc8e555096ee700fb53A. Unique TensorFlower  INFER_OK(op, "[1,?,?,?];[?,2,?,?];[?,?,3,?];[?,?,?,4];[];[];[];[]",
198d7639d5e25ba540f8f0f4bc8e555096ee700fb53A. Unique TensorFlower           "[d0_0,d1_1,d2_2,d3_3]");
199d7639d5e25ba540f8f0f4bc8e555096ee700fb53A. Unique TensorFlower  INFER_ERROR("Dimension 0 in both shapes must be equal, but are 1 and 2", op,
200d7639d5e25ba540f8f0f4bc8e555096ee700fb53A. Unique TensorFlower              "[1];[2];[1];[1];[];[];[];[]");
201d7639d5e25ba540f8f0f4bc8e555096ee700fb53A. Unique TensorFlower  INFER_ERROR("Dimension 0 in both shapes must be equal, but are 1 and 2", op,
202d7639d5e25ba540f8f0f4bc8e555096ee700fb53A. Unique TensorFlower              "[1];[1];[2];[1];[];[];[];[]");
203d7639d5e25ba540f8f0f4bc8e555096ee700fb53A. Unique TensorFlower  INFER_ERROR("Dimension 0 in both shapes must be equal, but are 1 and 2", op,
204d7639d5e25ba540f8f0f4bc8e555096ee700fb53A. Unique TensorFlower              "[1];[1];[1];[2];[];[];[];[]");
205d7639d5e25ba540f8f0f4bc8e555096ee700fb53A. Unique TensorFlower
206d7639d5e25ba540f8f0f4bc8e555096ee700fb53A. Unique TensorFlower  // lr, l1, l2, and lr_power must be scalars.
207d7639d5e25ba540f8f0f4bc8e555096ee700fb53A. Unique TensorFlower  INFER_ERROR("Shape must be rank 0 but is rank 1", op, "?;?;?;?;[?];?;?;?");
208d7639d5e25ba540f8f0f4bc8e555096ee700fb53A. Unique TensorFlower  INFER_ERROR("Shape must be rank 0 but is rank 1", op, "?;?;?;?;?;[?];?;?");
209d7639d5e25ba540f8f0f4bc8e555096ee700fb53A. Unique TensorFlower  INFER_ERROR("Shape must be rank 0 but is rank 1", op, "?;?;?;?;?;?;[?];?");
210d7639d5e25ba540f8f0f4bc8e555096ee700fb53A. Unique TensorFlower  INFER_ERROR("Shape must be rank 0 but is rank 1", op, "?;?;?;?;?;?;?;[?]");
211d7639d5e25ba540f8f0f4bc8e555096ee700fb53A. Unique TensorFlower}
212d7639d5e25ba540f8f0f4bc8e555096ee700fb53A. Unique TensorFlower
213075d1ab68fcaf5ddd90c3d30f6a046b78c3c04f3A. Unique TensorFlowerTEST(TrainingOpsTest, SparseApplyFtrl_ShapeFn) {
214075d1ab68fcaf5ddd90c3d30f6a046b78c3c04f3A. Unique TensorFlower  ShapeInferenceTestOp op("SparseApplyFtrl");
215075d1ab68fcaf5ddd90c3d30f6a046b78c3c04f3A. Unique TensorFlower
216075d1ab68fcaf5ddd90c3d30f6a046b78c3c04f3A. Unique TensorFlower  // Output is a merge of inputs 0, 1, 2, and non-indices part of 3 (var, accum,
217075d1ab68fcaf5ddd90c3d30f6a046b78c3c04f3A. Unique TensorFlower  // linear, grad).
2187946b8481f73cf6d91375400237b7bcce545e7beA. Unique TensorFlower  INFER_OK(op, "[1,?,?,?];[?,2,?,?];[?,?,3,?];[?,?,?,4];?;[];[];[];[]",
2197946b8481f73cf6d91375400237b7bcce545e7beA. Unique TensorFlower           "[d0_0,d1_1,d2_2,d3_3]");
220075d1ab68fcaf5ddd90c3d30f6a046b78c3c04f3A. Unique TensorFlower  INFER_ERROR("Dimension 0 in both shapes must be equal, but are 1 and 2", op,
221075d1ab68fcaf5ddd90c3d30f6a046b78c3c04f3A. Unique TensorFlower              "[1];[2];[1];[?,1];?;[];[];[];[]");
222075d1ab68fcaf5ddd90c3d30f6a046b78c3c04f3A. Unique TensorFlower  INFER_ERROR("Dimension 0 in both shapes must be equal, but are 1 and 2", op,
223075d1ab68fcaf5ddd90c3d30f6a046b78c3c04f3A. Unique TensorFlower              "[1];[1];[2];[?,1];?;[];[];[];[]");
2247946b8481f73cf6d91375400237b7bcce545e7beA. Unique TensorFlower  INFER_ERROR("Dimension 1 in both shapes must be equal, but are 1 and 2", op,
2257946b8481f73cf6d91375400237b7bcce545e7beA. Unique TensorFlower              "[?,1];[?,1];[?,1];[?,2];?;[];[];[];[]");
226075d1ab68fcaf5ddd90c3d30f6a046b78c3c04f3A. Unique TensorFlower
227075d1ab68fcaf5ddd90c3d30f6a046b78c3c04f3A. Unique TensorFlower  TestGradAndIndicesErrorHandling(op, "?;?", ";?;?;?;?");
228075d1ab68fcaf5ddd90c3d30f6a046b78c3c04f3A. Unique TensorFlower
229075d1ab68fcaf5ddd90c3d30f6a046b78c3c04f3A. Unique TensorFlower  // lr, l1, l2, and lr_power must be scalars.
230075d1ab68fcaf5ddd90c3d30f6a046b78c3c04f3A. Unique TensorFlower  INFER_ERROR("Shape must be rank 0 but is rank 1", op, "?;?;?;?;?;[?];?;?;?");
231075d1ab68fcaf5ddd90c3d30f6a046b78c3c04f3A. Unique TensorFlower  INFER_ERROR("Shape must be rank 0 but is rank 1", op, "?;?;?;?;?;?;[?];?;?");
232075d1ab68fcaf5ddd90c3d30f6a046b78c3c04f3A. Unique TensorFlower  INFER_ERROR("Shape must be rank 0 but is rank 1", op, "?;?;?;?;?;?;?;[?];?");
233075d1ab68fcaf5ddd90c3d30f6a046b78c3c04f3A. Unique TensorFlower  INFER_ERROR("Shape must be rank 0 but is rank 1", op, "?;?;?;?;?;?;?;?;[?]");
234075d1ab68fcaf5ddd90c3d30f6a046b78c3c04f3A. Unique TensorFlower}
235075d1ab68fcaf5ddd90c3d30f6a046b78c3c04f3A. Unique TensorFlower
236d7639d5e25ba540f8f0f4bc8e555096ee700fb53A. Unique TensorFlowerTEST(TrainingOpsTest, ApplyMomentum_ShapeFn) {
237d7639d5e25ba540f8f0f4bc8e555096ee700fb53A. Unique TensorFlower  ShapeInferenceTestOp op("ApplyMomentum");
238d7639d5e25ba540f8f0f4bc8e555096ee700fb53A. Unique TensorFlower
239d7639d5e25ba540f8f0f4bc8e555096ee700fb53A. Unique TensorFlower  // Output is a merge of inputs 0, 1, and 3 (var, accum, grad).
240d7639d5e25ba540f8f0f4bc8e555096ee700fb53A. Unique TensorFlower  INFER_OK(op, "[1,?,?];[?,2,?];[];[?,?,3];[]", "[d0_0,d1_1,d3_2]");
241d7639d5e25ba540f8f0f4bc8e555096ee700fb53A. Unique TensorFlower  INFER_ERROR("Dimension 0 in both shapes must be equal, but are 1 and 2", op,
242d7639d5e25ba540f8f0f4bc8e555096ee700fb53A. Unique TensorFlower              "[1];[2];[];[1];[]");
243d7639d5e25ba540f8f0f4bc8e555096ee700fb53A. Unique TensorFlower  INFER_ERROR("Dimension 0 in both shapes must be equal, but are 1 and 2", op,
244d7639d5e25ba540f8f0f4bc8e555096ee700fb53A. Unique TensorFlower              "[1];[1];[];[2];[]");
245d7639d5e25ba540f8f0f4bc8e555096ee700fb53A. Unique TensorFlower
246d7639d5e25ba540f8f0f4bc8e555096ee700fb53A. Unique TensorFlower  // lr and momentum must be scalars.
247d7639d5e25ba540f8f0f4bc8e555096ee700fb53A. Unique TensorFlower  INFER_ERROR("Shape must be rank 0 but is rank 1", op, "?;?;[?];?;?");
248d7639d5e25ba540f8f0f4bc8e555096ee700fb53A. Unique TensorFlower  INFER_ERROR("Shape must be rank 0 but is rank 1", op, "?;?;?;?;[?]");
249d7639d5e25ba540f8f0f4bc8e555096ee700fb53A. Unique TensorFlower}
250d7639d5e25ba540f8f0f4bc8e555096ee700fb53A. Unique TensorFlower
251075d1ab68fcaf5ddd90c3d30f6a046b78c3c04f3A. Unique TensorFlowerTEST(TrainingOpsTest, SparseApplyMomentum_ShapeFn) {
252075d1ab68fcaf5ddd90c3d30f6a046b78c3c04f3A. Unique TensorFlower  ShapeInferenceTestOp op("SparseApplyMomentum");
253075d1ab68fcaf5ddd90c3d30f6a046b78c3c04f3A. Unique TensorFlower
254075d1ab68fcaf5ddd90c3d30f6a046b78c3c04f3A. Unique TensorFlower  // Output is a merge of inputs 0, 1, and non-indices part of 3 (var, accum,
255075d1ab68fcaf5ddd90c3d30f6a046b78c3c04f3A. Unique TensorFlower  // grad).
2567946b8481f73cf6d91375400237b7bcce545e7beA. Unique TensorFlower  INFER_OK(op, "[1,?,?];[?,2,?];[];[?,?,3];?;[]", "[d0_0,d1_1,d3_2]");
2577946b8481f73cf6d91375400237b7bcce545e7beA. Unique TensorFlower  INFER_ERROR("Dimension 1 in both shapes must be equal, but are 1 and 2", op,
2587946b8481f73cf6d91375400237b7bcce545e7beA. Unique TensorFlower              "[?,1];[?,2];[];[?,1];?;[]");
2597946b8481f73cf6d91375400237b7bcce545e7beA. Unique TensorFlower  INFER_ERROR("Dimension 1 in both shapes must be equal, but are 1 and 2", op,
2607946b8481f73cf6d91375400237b7bcce545e7beA. Unique TensorFlower              "[?,1];[?,1];[];[?,2];?;[]");
261075d1ab68fcaf5ddd90c3d30f6a046b78c3c04f3A. Unique TensorFlower
262075d1ab68fcaf5ddd90c3d30f6a046b78c3c04f3A. Unique TensorFlower  TestGradAndIndicesErrorHandling(op, "?;?", ";?");
263075d1ab68fcaf5ddd90c3d30f6a046b78c3c04f3A. Unique TensorFlower
264075d1ab68fcaf5ddd90c3d30f6a046b78c3c04f3A. Unique TensorFlower  // lr and momentum must be scalars.
265075d1ab68fcaf5ddd90c3d30f6a046b78c3c04f3A. Unique TensorFlower  INFER_ERROR("Shape must be rank 0 but is rank 1", op, "?;?;[?];?;?;?");
266075d1ab68fcaf5ddd90c3d30f6a046b78c3c04f3A. Unique TensorFlower  INFER_ERROR("Shape must be rank 0 but is rank 1", op, "?;?;?;?;?;[?]");
267075d1ab68fcaf5ddd90c3d30f6a046b78c3c04f3A. Unique TensorFlower}
268075d1ab68fcaf5ddd90c3d30f6a046b78c3c04f3A. Unique TensorFlower
269d7639d5e25ba540f8f0f4bc8e555096ee700fb53A. Unique TensorFlowerTEST(TrainingOpsTest, ApplyAdam_ShapeFn) {
270d7639d5e25ba540f8f0f4bc8e555096ee700fb53A. Unique TensorFlower  ShapeInferenceTestOp op("ApplyAdam");
271d7639d5e25ba540f8f0f4bc8e555096ee700fb53A. Unique TensorFlower
272d7639d5e25ba540f8f0f4bc8e555096ee700fb53A. Unique TensorFlower  // Output is a merge of inputs 0, 1, 2, and 9 (var, m, v, and grad).
273d7639d5e25ba540f8f0f4bc8e555096ee700fb53A. Unique TensorFlower  INFER_OK(op, "[1,?,?,?];[?,2,?,?];[?,?,3,?];[];[];[];[];[];[];[?,?,?,4]",
274d7639d5e25ba540f8f0f4bc8e555096ee700fb53A. Unique TensorFlower           "[d0_0,d1_1,d2_2,d9_3]");
275d7639d5e25ba540f8f0f4bc8e555096ee700fb53A. Unique TensorFlower  INFER_ERROR("Dimension 0 in both shapes must be equal, but are 1 and 2", op,
276d7639d5e25ba540f8f0f4bc8e555096ee700fb53A. Unique TensorFlower              "[1];[2];[1];[];[];[];[];[];[];[1]");
277d7639d5e25ba540f8f0f4bc8e555096ee700fb53A. Unique TensorFlower  INFER_ERROR("Dimension 0 in both shapes must be equal, but are 1 and 2", op,
278d7639d5e25ba540f8f0f4bc8e555096ee700fb53A. Unique TensorFlower              "[1];[1];[2];[];[];[];[];[];[];[1]");
279d7639d5e25ba540f8f0f4bc8e555096ee700fb53A. Unique TensorFlower  INFER_ERROR("Dimension 0 in both shapes must be equal, but are 1 and 2", op,
280d7639d5e25ba540f8f0f4bc8e555096ee700fb53A. Unique TensorFlower              "[1];[1];[1];[];[];[];[];[];[];[2]");
281d7639d5e25ba540f8f0f4bc8e555096ee700fb53A. Unique TensorFlower
282d7639d5e25ba540f8f0f4bc8e555096ee700fb53A. Unique TensorFlower  // beta1_power, beta2_power, lr, beta1, beta2, and epsilon must be scalars.
283075d1ab68fcaf5ddd90c3d30f6a046b78c3c04f3A. Unique TensorFlower  const char err[] = "Shape must be rank 0 but is rank 1";
284075d1ab68fcaf5ddd90c3d30f6a046b78c3c04f3A. Unique TensorFlower  INFER_ERROR(err, op, "?;?;?;[?];?;?;?;?;?;?");
285075d1ab68fcaf5ddd90c3d30f6a046b78c3c04f3A. Unique TensorFlower  INFER_ERROR(err, op, "?;?;?;?;[?];?;?;?;?;?");
286075d1ab68fcaf5ddd90c3d30f6a046b78c3c04f3A. Unique TensorFlower  INFER_ERROR(err, op, "?;?;?;?;?;[?];?;?;?;?");
287075d1ab68fcaf5ddd90c3d30f6a046b78c3c04f3A. Unique TensorFlower  INFER_ERROR(err, op, "?;?;?;?;?;?;[?];?;?;?");
288075d1ab68fcaf5ddd90c3d30f6a046b78c3c04f3A. Unique TensorFlower  INFER_ERROR(err, op, "?;?;?;?;?;?;?;[?];?;?");
289075d1ab68fcaf5ddd90c3d30f6a046b78c3c04f3A. Unique TensorFlower  INFER_ERROR(err, op, "?;?;?;?;?;?;?;?;[?];?");
290d7639d5e25ba540f8f0f4bc8e555096ee700fb53A. Unique TensorFlower}
291d7639d5e25ba540f8f0f4bc8e555096ee700fb53A. Unique TensorFlower
292d7639d5e25ba540f8f0f4bc8e555096ee700fb53A. Unique TensorFlowerTEST(TrainingOpsTest, ApplyRMSProp_ShapeFn) {
293d7639d5e25ba540f8f0f4bc8e555096ee700fb53A. Unique TensorFlower  ShapeInferenceTestOp op("ApplyRMSProp");
294d7639d5e25ba540f8f0f4bc8e555096ee700fb53A. Unique TensorFlower
295d7639d5e25ba540f8f0f4bc8e555096ee700fb53A. Unique TensorFlower  // Output is a merge of inputs 0, 1, 2, and 7 (var, ms, mom, and grad).
296d7639d5e25ba540f8f0f4bc8e555096ee700fb53A. Unique TensorFlower  INFER_OK(op, "[1,?,?,?];[?,2,?,?];[?,?,3,?];[];[];[];[];[?,?,?,4]",
297d7639d5e25ba540f8f0f4bc8e555096ee700fb53A. Unique TensorFlower           "[d0_0,d1_1,d2_2,d7_3]");
298d7639d5e25ba540f8f0f4bc8e555096ee700fb53A. Unique TensorFlower  INFER_ERROR("Dimension 0 in both shapes must be equal, but are 1 and 2", op,
299d7639d5e25ba540f8f0f4bc8e555096ee700fb53A. Unique TensorFlower              "[1];[2];[1];[];[];[];[];[1]");
300d7639d5e25ba540f8f0f4bc8e555096ee700fb53A. Unique TensorFlower  INFER_ERROR("Dimension 0 in both shapes must be equal, but are 1 and 2", op,
301d7639d5e25ba540f8f0f4bc8e555096ee700fb53A. Unique TensorFlower              "[1];[1];[2];[];[];[];[];[1]");
302d7639d5e25ba540f8f0f4bc8e555096ee700fb53A. Unique TensorFlower  INFER_ERROR("Dimension 0 in both shapes must be equal, but are 1 and 2", op,
303d7639d5e25ba540f8f0f4bc8e555096ee700fb53A. Unique TensorFlower              "[1];[1];[1];[];[];[];[];[2]");
304d7639d5e25ba540f8f0f4bc8e555096ee700fb53A. Unique TensorFlower
305d7639d5e25ba540f8f0f4bc8e555096ee700fb53A. Unique TensorFlower  // lr, rho, momentum, and epsilon must be scalars.
306d7639d5e25ba540f8f0f4bc8e555096ee700fb53A. Unique TensorFlower  INFER_ERROR("Shape must be rank 0 but is rank 1", op, "?;?;?;[?];?;?;?;?");
307d7639d5e25ba540f8f0f4bc8e555096ee700fb53A. Unique TensorFlower  INFER_ERROR("Shape must be rank 0 but is rank 1", op, "?;?;?;?;[?];?;?;?");
308d7639d5e25ba540f8f0f4bc8e555096ee700fb53A. Unique TensorFlower  INFER_ERROR("Shape must be rank 0 but is rank 1", op, "?;?;?;?;?;[?];?;?");
309d7639d5e25ba540f8f0f4bc8e555096ee700fb53A. Unique TensorFlower  INFER_ERROR("Shape must be rank 0 but is rank 1", op, "?;?;?;?;?;?;[?];?");
310d7639d5e25ba540f8f0f4bc8e555096ee700fb53A. Unique TensorFlower}
311d7639d5e25ba540f8f0f4bc8e555096ee700fb53A. Unique TensorFlower
312075d1ab68fcaf5ddd90c3d30f6a046b78c3c04f3A. Unique TensorFlowerTEST(TrainingOpsTest, SparseApplyRMSProp_ShapeFn) {
313075d1ab68fcaf5ddd90c3d30f6a046b78c3c04f3A. Unique TensorFlower  ShapeInferenceTestOp op("SparseApplyRMSProp");
314075d1ab68fcaf5ddd90c3d30f6a046b78c3c04f3A. Unique TensorFlower
315075d1ab68fcaf5ddd90c3d30f6a046b78c3c04f3A. Unique TensorFlower  // Output is a merge of inputs 0, 1, 2, and the non-indices part of 7 (var,
316075d1ab68fcaf5ddd90c3d30f6a046b78c3c04f3A. Unique TensorFlower  // ms, mom, and grad).
3177946b8481f73cf6d91375400237b7bcce545e7beA. Unique TensorFlower  INFER_OK(op, "[1,?,?,?];[?,2,?,?];[?,?,3,?];[];[];[];[];[?,?,?,4];?",
3187946b8481f73cf6d91375400237b7bcce545e7beA. Unique TensorFlower           "[d0_0,d1_1,d2_2,d7_3]");
319075d1ab68fcaf5ddd90c3d30f6a046b78c3c04f3A. Unique TensorFlower  INFER_ERROR("Dimension 0 in both shapes must be equal, but are 1 and 2", op,
3207946b8481f73cf6d91375400237b7bcce545e7beA. Unique TensorFlower              "[1];[2];[1];[];[];[];[];[1];?");
321075d1ab68fcaf5ddd90c3d30f6a046b78c3c04f3A. Unique TensorFlower  INFER_ERROR("Dimension 0 in both shapes must be equal, but are 1 and 2", op,
3227946b8481f73cf6d91375400237b7bcce545e7beA. Unique TensorFlower              "[1];[1];[2];[];[];[];[];[1];?");
3237946b8481f73cf6d91375400237b7bcce545e7beA. Unique TensorFlower  INFER_ERROR("Dimension 1 in both shapes must be equal, but are 1 and 2", op,
3247946b8481f73cf6d91375400237b7bcce545e7beA. Unique TensorFlower              "[?,1];[?,1];[?,1];[];[];[];[];[?,2];?");
325075d1ab68fcaf5ddd90c3d30f6a046b78c3c04f3A. Unique TensorFlower
326075d1ab68fcaf5ddd90c3d30f6a046b78c3c04f3A. Unique TensorFlower  TestGradAndIndicesErrorHandling(op, "?;?;?;?;?;?");
327075d1ab68fcaf5ddd90c3d30f6a046b78c3c04f3A. Unique TensorFlower
328075d1ab68fcaf5ddd90c3d30f6a046b78c3c04f3A. Unique TensorFlower  // lr, rho, momentum, and epsilon must be scalars.
329075d1ab68fcaf5ddd90c3d30f6a046b78c3c04f3A. Unique TensorFlower  INFER_ERROR("Shape must be rank 0 but is rank 1", op, "?;?;?;[?];?;?;?;?;?");
330075d1ab68fcaf5ddd90c3d30f6a046b78c3c04f3A. Unique TensorFlower  INFER_ERROR("Shape must be rank 0 but is rank 1", op, "?;?;?;?;[?];?;?;?;?");
331075d1ab68fcaf5ddd90c3d30f6a046b78c3c04f3A. Unique TensorFlower  INFER_ERROR("Shape must be rank 0 but is rank 1", op, "?;?;?;?;?;[?];?;?;?");
332075d1ab68fcaf5ddd90c3d30f6a046b78c3c04f3A. Unique TensorFlower  INFER_ERROR("Shape must be rank 0 but is rank 1", op, "?;?;?;?;?;?;[?];?;?");
333075d1ab68fcaf5ddd90c3d30f6a046b78c3c04f3A. Unique TensorFlower}
334075d1ab68fcaf5ddd90c3d30f6a046b78c3c04f3A. Unique TensorFlower
3359dd9246d76aeada08f07d8c9550d7eedb0809713A. Unique TensorFlowerTEST(TrainingOpsTest, ApplyAddSign_ShapeFn) {
3369dd9246d76aeada08f07d8c9550d7eedb0809713A. Unique TensorFlower  ShapeInferenceTestOp op("ApplyAddSign");
3379dd9246d76aeada08f07d8c9550d7eedb0809713A. Unique TensorFlower
3389dd9246d76aeada08f07d8c9550d7eedb0809713A. Unique TensorFlower  // Output is a merge of inputs 0, 1, and 6 (var, ms, and grad).
3399dd9246d76aeada08f07d8c9550d7eedb0809713A. Unique TensorFlower  INFER_OK(op, "[1,?,?];[?,2,?];[];[];[];[];[?,?,2]", "[d0_0,d1_1,d6_2]");
3409dd9246d76aeada08f07d8c9550d7eedb0809713A. Unique TensorFlower  INFER_ERROR("Dimension 0 in both shapes must be equal, but are 1 and 2", op,
3419dd9246d76aeada08f07d8c9550d7eedb0809713A. Unique TensorFlower              "[1];[2];[];[];[];[];[1]");
3429dd9246d76aeada08f07d8c9550d7eedb0809713A. Unique TensorFlower  INFER_ERROR("Dimension 0 in both shapes must be equal, but are 1 and 2", op,
3439dd9246d76aeada08f07d8c9550d7eedb0809713A. Unique TensorFlower              "[1];[1];[];[];[];[];[2]");
3449dd9246d76aeada08f07d8c9550d7eedb0809713A. Unique TensorFlower
3459dd9246d76aeada08f07d8c9550d7eedb0809713A. Unique TensorFlower  // lr, alpha, sign_decay, and beta must be scalars.
3469dd9246d76aeada08f07d8c9550d7eedb0809713A. Unique TensorFlower  INFER_ERROR("Shape must be rank 0 but is rank 1", op, "?;?;[?];?;?;?;?");
3479dd9246d76aeada08f07d8c9550d7eedb0809713A. Unique TensorFlower  INFER_ERROR("Shape must be rank 0 but is rank 1", op, "?;?;?;[?];?;?;?");
3489dd9246d76aeada08f07d8c9550d7eedb0809713A. Unique TensorFlower  INFER_ERROR("Shape must be rank 0 but is rank 1", op, "?;?;?;?;[?];?;?");
3499dd9246d76aeada08f07d8c9550d7eedb0809713A. Unique TensorFlower  INFER_ERROR("Shape must be rank 0 but is rank 1", op, "?;?;?;?;?;[?];?");
3509dd9246d76aeada08f07d8c9550d7eedb0809713A. Unique TensorFlower}
3519dd9246d76aeada08f07d8c9550d7eedb0809713A. Unique TensorFlower
3529dd9246d76aeada08f07d8c9550d7eedb0809713A. Unique TensorFlowerTEST(TrainingOpsTest, ApplyPowerSign_ShapeFn) {
3539dd9246d76aeada08f07d8c9550d7eedb0809713A. Unique TensorFlower  ShapeInferenceTestOp op("ApplyPowerSign");
3549dd9246d76aeada08f07d8c9550d7eedb0809713A. Unique TensorFlower
3559dd9246d76aeada08f07d8c9550d7eedb0809713A. Unique TensorFlower  // Output is a merge of inputs 0, 1, and 6 (var, ms, and grad).
3569dd9246d76aeada08f07d8c9550d7eedb0809713A. Unique TensorFlower  INFER_OK(op, "[1,?,?];[?,2,?];[];[];[];[];[?,?,2]", "[d0_0,d1_1,d6_2]");
3579dd9246d76aeada08f07d8c9550d7eedb0809713A. Unique TensorFlower  INFER_ERROR("Dimension 0 in both shapes must be equal, but are 1 and 2", op,
3589dd9246d76aeada08f07d8c9550d7eedb0809713A. Unique TensorFlower              "[1];[2];[];[];[];[];[1]");
3599dd9246d76aeada08f07d8c9550d7eedb0809713A. Unique TensorFlower  INFER_ERROR("Dimension 0 in both shapes must be equal, but are 1 and 2", op,
3609dd9246d76aeada08f07d8c9550d7eedb0809713A. Unique TensorFlower              "[1];[1];[];[];[];[];[2]");
3619dd9246d76aeada08f07d8c9550d7eedb0809713A. Unique TensorFlower
3629dd9246d76aeada08f07d8c9550d7eedb0809713A. Unique TensorFlower  // lr, logbase, sign_decay, and beta must be scalars.
3639dd9246d76aeada08f07d8c9550d7eedb0809713A. Unique TensorFlower  INFER_ERROR("Shape must be rank 0 but is rank 1", op, "?;?;[?];?;?;?;?");
3649dd9246d76aeada08f07d8c9550d7eedb0809713A. Unique TensorFlower  INFER_ERROR("Shape must be rank 0 but is rank 1", op, "?;?;?;[?];?;?;?");
3659dd9246d76aeada08f07d8c9550d7eedb0809713A. Unique TensorFlower  INFER_ERROR("Shape must be rank 0 but is rank 1", op, "?;?;?;?;[?];?;?");
3669dd9246d76aeada08f07d8c9550d7eedb0809713A. Unique TensorFlower  INFER_ERROR("Shape must be rank 0 but is rank 1", op, "?;?;?;?;?;[?];?");
3679dd9246d76aeada08f07d8c9550d7eedb0809713A. Unique TensorFlower}
3689dd9246d76aeada08f07d8c9550d7eedb0809713A. Unique TensorFlower
369d7639d5e25ba540f8f0f4bc8e555096ee700fb53A. Unique TensorFlower}  // end namespace tensorflow
370