Populates loop invariant indices to true in `loop_invariants`.
| 126 | |
| 127 | // Populates loop invariant indices to true in `loop_invariants`. |
| 128 | void GetLoopInvariants(XlaOpKernelContext* ctx, |
| 129 | const NameAttrList& body_name_attr, |
| 130 | std::vector<bool>* const loop_invariants) { |
| 131 | const FunctionBody* body; |
| 132 | OP_REQUIRES_OK(ctx, ctx->compiler()->FindFunctionBody(body_name_attr, &body)); |
| 133 | for (int i = 0; i < body->ret_nodes.size(); i++) { |
| 134 | const Node* arg = body->arg_nodes[i]; |
| 135 | const Node* ret = body->ret_nodes[i]; |
| 136 | const Node* ret_input_0; |
| 137 | OP_REQUIRES_OK(ctx, ret->input_node(0, &ret_input_0)); |
| 138 | (*loop_invariants)[i] = ret_input_0->id() == arg->id(); |
| 139 | } |
| 140 | } |
| 141 | |
| 142 | // Converts entries in `args` which are loop invariants and have compile |
| 143 | // time constant inputs to constants so that they can be propagated in the loop |
no test coverage detected