def test_constant_folding(self):
"""frame should be constant foldable for constant inputs."""
- # Padding is incorrectly defined in shape_ops.py (the rank of the padding
- # tensor should be equal to the rank of the input tensor + 1): only test
- # with padding set to False to avoid this.
- for pad_end in [False]:
+ for pad_end in [True, False]:
g = ops.Graph()
with g.as_default():
frame_length, frame_step = 32, 16
[[0, pad_samples]],
array_ops.zeros([num_inner_dimensions, 2], dtype=pad_samples.dtype)],
0)
- # TODO(rjryan): the paddings tensor must of rank tf.rank(signal) + 1. This
- # isn't the case here and should be fixed.
signal = array_ops.pad(signal, paddings, constant_values=pad_value)
signal_shape = array_ops.shape(signal)
const Tensor* size_splits = c->input_tensor(1);
if (rank == InferenceContext::kUnknownRank) {
// If the rank of input tensor is unknown, then return unknown shapes.
- output_shape = c->UnknownShape();
+ // Note that the shape of each output can be different.
for (int i = 0; i < num_outputs; ++i) {
- c->set_output(i, output_shape);
+ c->set_output(i, c->UnknownShape());
}
} else if (rank == 0) {
// Throw error if input is a scalar.
// If split dimension is known, but the sizes are unknown, then
// only the split dimension is unknown
output_shape = input;
- TF_RETURN_IF_ERROR(c->ReplaceDim(output_shape,
- c->Value(split_dimension),
- c->UnknownDim(), &output_shape));
for (int i = 0; i < num_outputs; ++i) {
+ TF_RETURN_IF_ERROR(c->ReplaceDim(output_shape,
+ c->Value(split_dimension),
+ c->UnknownDim(), &output_shape));
c->set_output(i, output_shape);
}
} else if (size_splits == nullptr && !c->ValueKnown(split_dimension)) {
// If split dimension or tensor containing the split sizes is unknown,
- // then return unknown shapes of same rank as input.
- output_shape = c->UnknownShapeOfRank(rank);
+ // then return unknown shapes of same rank as input. Note that each
+ // output shape can be different since splitv doesn't always split
+ // tensors evenly.
for (int i = 0; i < num_outputs; ++i) {
- c->set_output(i, output_shape);
+ c->set_output(i, c->UnknownShapeOfRank(rank));
}
} else {
// Determine the output shape if split dimension and split sizes are