Keep symbolic arithmetic inference scoped to dynamic XLA - #46
Conversation
5df6c3d to
95e9f58
Compare
95e9f58 to
b05772f
Compare
a0294f3 to
5205084
Compare
59d953d to
bba27c3
Compare
5205084 to
ffee85a
Compare
73775f2 to
911d97f
Compare
| if (op == "Sub") | ||
| TF_RETURN_IF_ERROR(ic->Subtract(da, db, &r)); | ||
| else if (op == "Add") | ||
| TF_RETURN_IF_ERROR(ic->Add(da, db, &r)); | ||
| else if (op == "Mul") | ||
| TF_RETURN_IF_ERROR(ic->Multiply(da, db, &r)); | ||
| else | ||
| TF_RETURN_IF_ERROR( | ||
| ic->Divide(da, db, /*evenly_divisible=*/false, &r)); |
There was a problem hiding this comment.
This still does not fall back when symbolic arithmetic fails 😒. Shape-value tensors can validly produce -1, for example, [1] - [2], but InferenceContext::Subtract interprets these values as dimensions and returns InvalidArgument. Because TF_RETURN_IF_ERROR propagates that error, GraphProperties fails instead of reaching normal value inference, contrary to the new fallback behaviour. Please treat arithmetic failure as “symbolic propagation does not apply” (or use tensor-value semantics) and add a regression test covering negative results and unknown-shape sentinels.
There was a problem hiding this comment.
Thank you for your review. As you correctly said, -1 is invalid as a concrete dimension but remains a perfectly valid integer tensor value. The symbolic path now steps aside instead of failing GraphProperties, and regression tests ensure this distinction should not require another reminder.
911d97f to
6aa420b
Compare
Summary
TensorFlow-side dynamic value inference has a symbolic path for shape-like values produced by
Add,Sub,Mul, andDiv. That path previously ran even when dynamic value inference was disabled, and it returned early when symbolic propagation could not handle the available operands. This could prevent GraphProperties from continuing through its normal value-inference logic.This change:
Ordinary GraphProperties behavior is therefore preserved when dynamic value inference is disabled, while dynamic XLA inference can still propagate compatible symbolic shape values.
Tests
//tensorflow/core/grappler/costs:graph_properties_test