| 22 | namespace tensorflow { |
| 23 | |
| 24 | TEST(CtcOpsTest, CTCLoss_ShapeFn) { |
| 25 | ShapeInferenceTestOp op("CTCLoss"); |
| 26 | |
| 27 | // Inputs are inputs, labels_indices, labels_values, and sequence_length. |
| 28 | |
| 29 | // Rank checks |
| 30 | INFER_ERROR("must be rank 3", op, "[];?;?;?"); // inputs |
| 31 | INFER_ERROR("must be rank 2", op, "?;[];?;?"); // labels_indices |
| 32 | INFER_ERROR("must be rank 1", op, "?;?;[];?"); // labels_values |
| 33 | INFER_ERROR("must be rank 1", op, "?;?;?;[]"); // sequence_length |
| 34 | |
| 35 | // labels_indices.dim(0) and labels_values.dim(0) must match. |
| 36 | INFER_ERROR("must be equal", op, "?;[1,?];[2];?"); |
| 37 | |
| 38 | // batch_size comes from inputs.dim(1) merged with sequence_length.dim(0). |
| 39 | // This becomes the dimension of the first out, and replaced inputs.dim(1) to |
| 40 | // become the second out. |
| 41 | INFER_OK(op, "[?,?,?];?;?;[?]", "[d0_1|d3_0];[d0_0,d0_1|d3_0,d0_2]"); |
| 42 | INFER_OK(op, "[?,1,?];?;?;[1]", "[d0_1|d3_0];[d0_0,d0_1|d3_0,d0_2]"); |
| 43 | INFER_OK(op, "[?,?,?];?;?;[1]", "[d3_0];[d0_0,d3_0,d0_2]"); |
| 44 | INFER_OK(op, "[?,1,?];?;?;[?]", "[d0_1];[d0_0,d0_1,d0_2]"); |
| 45 | INFER_ERROR("must be equal", op, "[?,1,?];?;?;[2]"); |
| 46 | } |
| 47 | |
| 48 | TEST(CtcOpsTest, CTCGreedyDecoder_ShapeFn) { |
| 49 | ShapeInferenceTestOp op("CTCGreedyDecoder"); |
nothing calls this directly
no test coverage detected