MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / TEST

Function TEST

tensorflow/core/ops/math_ops_test.cc:28–75  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

26namespace tensorflow {
27
28TEST(MathOpsTest, AddN_ShapeFn) {
29 ShapeInferenceTestOp op("AddN");
30 auto set_n = [&op](int n) {
31 std::vector<NodeDefBuilder::NodeOut> src_list;
32 src_list.reserve(n);
33 for (int i = 0; i < n; ++i) src_list.emplace_back("a", 0, DT_FLOAT);
34 TF_ASSERT_OK(NodeDefBuilder("test", "AddN")
35 .Input(src_list)
36 .Attr("N", n)
37 .Finalize(&op.node_def));
38 };
39
40 set_n(2);
41 // Adding two unknowns returns either input.
42 INFER_OK(op, "?;?", "in0|in1");
43
44 // known+unknown returns the known input.
45 INFER_OK(op, "[1];[?]", "in0");
46 INFER_OK(op, "[1];?", "in0");
47 INFER_OK(op, "[?];[1]", "in1");
48 INFER_OK(op, "?;[1]", "in1");
49
50 set_n(2);
51 INFER_OK(op, "[1,2];[?,2]", "in0");
52 INFER_OK(op, "[1,2];[1,2]", "in0|in1");
53 INFER_OK(op, "[?,2];[1,2]", "in1");
54
55 set_n(3);
56 INFER_OK(op, "[1,?];[?,2];[1,2]", "in2");
57 INFER_OK(op, "[1,2];[?,2];[1,?]", "in0");
58 INFER_OK(op, "?;?;[1,2]", "in2");
59
60 set_n(2);
61 INFER_OK(op, "?;[1,2]", "in1");
62 INFER_OK(op, "[1,?];[?,2]", "[d0_0,d1_1]");
63 INFER_OK(op, "[?,2,?];[?,?,3]", "[d0_0|d1_0,d0_1,d1_2]");
64 INFER_OK(op, "[?,2];[1,?]", "[d1_0,d0_1]");
65
66 set_n(3);
67 INFER_ERROR("Dimension 1 in both shapes must be equal, but are 2 and 4", op,
68 "[1,2];?;[1,4]");
69 INFER_ERROR("From merging shape 0 with other shapes.", op, "[1,2];?;[1,4]");
70 set_n(4);
71 INFER_ERROR("Shapes must be equal rank, but are 2 and 3", op,
72 "?;[1,2];?;[1,2,3]");
73 INFER_ERROR("From merging shape 1 with other shapes.", op,
74 "?;[1,2];?;[1,2,3]");
75}
76
77TEST(MathOpsTest, UnchangedShape_ShapeFn) {
78 ShapeInferenceTestOp op("Cast");

Callers

nothing calls this directly

Calls 15

NodeDefBuilderClass · 0.85
TensorShapeProtoClass · 0.85
construction_statusMethod · 0.80
pop_backMethod · 0.80
AddNodeAttrFunction · 0.50
StrContainsFunction · 0.50
AsScalarFunction · 0.50
reserveMethod · 0.45
emplace_backMethod · 0.45
FinalizeMethod · 0.45
AttrMethod · 0.45

Tested by

no test coverage detected