Hoist function input placeholders out of any control flow context.
Prior to this change, functions that closed over external tensors in a while loop would cause a segfault at runtime. This is because the external tensors are temporarily represented as placeholders in the function body before being replaced by input parameters, and the placeholders would be created directly in the while loop body. This would eventually lead to using the input tensor in the while loop body without an enter node. This wasn't caught by the runtime check because it isn't applied to function bodies. This change adds tests for capturing tensors in a while loop body and in a cond context. Note that the cond test passed without this fix. PiperOrigin-RevId: 177464541
Loading
Please sign in to comment