Observation
Per the tf.Tensor.set_shape API docs, the method returns None. The TF source confirms this — set_shape is a side-effecting mutation that updates the receiver Tensor's static shape, not a return-value producer.
tensorflow.xml claims otherwise:
<class name="set_shape" allocatable="true">
<method name="do" descriptor="()LRoot;" numArgs="2" paramNames="self shape">
<return value="self" />
</method>
</class>
(tensorflow.xml:1660-1664)
This <return value="self"/> claims the call returns self. In the callable-as-attribute context, self is the callable instance — not the receiver Tensor and not None. Misleading regardless of how it's read.
Surfaced By
Reviewing the explorations in ponder-lab/ML#338 (closed): a follow-up to #550 used a similar <return value="self"/> pattern for fresh <method name="set_shape"> declarations on Tensor classes. Comparing both modelings against the real TF API surfaced the mismatch.
Possible Fix
Two reasonable options:
- Empty body (no
<return>): the WALA Python frontend can synthesize a None return for methods without an explicit <return> (verify this against existing void-returning models).
- Explicit
None allocation: <new def="r" class="Lnone"/><return value="r"/> or similar, following whatever convention tensorflow.xml uses elsewhere for None returns.
Whichever pattern lands should be applied to:
Out of Scope
This is independent of the dispatch-mechanism debate in #550. The return-value mismatch is a separate API-correctness bug that applies regardless of whether set_shape is recognized via Java IR-syntactic scan, XML class-method dispatch, or XML callable-as-attribute.
Related
Observation
Per the
tf.Tensor.set_shapeAPI docs, the method returnsNone. The TF source confirms this —set_shapeis a side-effecting mutation that updates the receiver Tensor's static shape, not a return-value producer.tensorflow.xmlclaims otherwise:(
tensorflow.xml:1660-1664)This
<return value="self"/>claims the call returnsself. In the callable-as-attribute context,selfis the callable instance — not the receiver Tensor and notNone. Misleading regardless of how it's read.Surfaced By
Reviewing the explorations in ponder-lab/ML#338 (closed): a follow-up to #550 used a similar
<return value="self"/>pattern for fresh<method name="set_shape">declarations on Tensor classes. Comparing both modelings against the real TF API surfaced the mismatch.Possible Fix
Two reasonable options:
<return>): the WALA Python frontend can synthesize aNonereturn for methods without an explicit<return>(verify this against existing void-returning models).Noneallocation:<new def="r" class="Lnone"/><return value="r"/>or similar, following whatever conventiontensorflow.xmluses elsewhere forNonereturns.Whichever pattern lands should be applied to:
<class name="set_shape">attensorflow.xml:1660-1664.set_shaperecognition from Java IR-scan to<method>on Tensor classes intensorflow.xml#550 implementation work.Out of Scope
This is independent of the dispatch-mechanism debate in #550. The return-value mismatch is a separate API-correctness bug that applies regardless of whether
set_shapeis recognized via Java IR-syntactic scan, XML class-method dispatch, or XML callable-as-attribute.Related
set_shaperecognition from Java IR-scan to<method>on Tensor classes intensorflow.xml#550 —set_shaperecognition architecture; would consume any cleanup here.getSetShapeCallsSyntacticto find the calls.