Create the body subgraph defined by `body`. `outputs` must be non-null and empty.
| 119 | // Create the body subgraph defined by `body`. `outputs` must be non-null and |
| 120 | // empty. |
| 121 | Status CreateBody(const Scope& scope, const BodyGraphBuilderFn& body, |
| 122 | const std::vector<Output>& inputs, |
| 123 | std::vector<Output>* outputs) { |
| 124 | DCHECK(outputs != nullptr); |
| 125 | DCHECK(outputs->empty()); |
| 126 | |
| 127 | // The control dependency is analogous to that in CreateCond(). |
| 128 | Scope body_scope = |
| 129 | scope.NewSubScope("body").WithControlDependencies(inputs[0]); |
| 130 | TF_RETURN_IF_ERROR(body(body_scope, inputs, outputs)); |
| 131 | |
| 132 | const size_t num_loop_vars = inputs.size(); |
| 133 | if (outputs->size() != num_loop_vars) { |
| 134 | return errors::InvalidArgument( |
| 135 | "BuildWhileLoop: 'body' argument expected to return ", num_loop_vars, |
| 136 | " output(s), got ", outputs->size()); |
| 137 | } |
| 138 | for (const Output& output : *outputs) { |
| 139 | TF_RETURN_IF_ERROR( |
| 140 | scope.graph()->IsValidOutputTensor(output.node(), output.index())); |
| 141 | // TODO(skyewm): check output types/shapes |
| 142 | } |
| 143 | return Status::OK(); |
| 144 | } |
| 145 | |
| 146 | } // namespace |
| 147 |
no test coverage detected