MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / GetLoopInvariants

Function GetLoopInvariants

tensorflow/compiler/tf2xla/kernels/while_op.cc:128–140  ·  view source on GitHub ↗

Populates loop invariant indices to true in `loop_invariants`.

Source from the content-addressed store, hash-verified

126
127// Populates loop invariant indices to true in `loop_invariants`.
128void 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

Callers 1

Calls 5

FindFunctionBodyMethod · 0.80
input_nodeMethod · 0.80
compilerMethod · 0.45
sizeMethod · 0.45
idMethod · 0.45

Tested by

no test coverage detected