Hi,
The C api has TF_ForwardInputOrAllocateOutput for forwarding an input if possible, the output shape can be altered but not the datatype.
I see examples where it could be possible to forward an input with a different output datatype, like Equal
(a == b
).
I see in the checks performed by forward_input
(which ends up being called by above):
// Check that input type matches.
if (input_dtype(input_index) != output_dtype) {
CHECK(!forward_expected);
return nullptr;
}
// Check that the input and output sizes are compatible.
if (input.tensor->shape().num_elements() != output_shape.num_elements()) {
CHECK(!forward_expected);
return nullptr;
}
Instead of those two conditions, correct me if I am wrong, it seems better to check that the byte sizes match.
So why is that?