@@ -220,52 +220,16 @@ private GraphOperation graphOp(Operand<?> operand) {
220
220
}
221
221
222
222
/**
223
- * Finds the operations used to produce {@code outputs} from {@code inputs}, or throws if that is not possible.
224
- * Includes control dependencies.
225
- *
226
- * @param inputs the inputs of the subgraph. Must be from single output ops. May not be null.
227
- * @param outputs the outputs of the subgraph. May not be null.
228
- * @param allowNoInputBodyOps whether to allow 0-input ops in the body. For more specificy use {@link
229
- * #completeSubgraph(Set, Set, Set, Set)}.
230
- * @return the set of operations needed to calculate outputs from inputs, including outputs and inputs
231
- * @throws IllegalStateException if outputs depends on ops outside of the subgraph (i.e. is not calculable based
232
- * solely on inputs)
233
- * @see #completeSubgraph(Set, Set, Set, Set)
234
- */
235
- public Set <GraphOperation > completeSubgraph (Set <Operand <?>> inputs , Set <Operand <?>> outputs ,
236
- boolean allowNoInputBodyOps ) {
237
- return completeSubgraph (inputs , outputs , null , allowNoInputBodyOps ? Collections .emptySet () : null );
238
- }
239
-
240
- /**
241
- * Finds the operations used to produce {@code outputs} from {@code inputs}, or throws if that is not possible.
242
- * Includes control dependencies.
243
- *
244
- * If both {@code allowedNoInputBodyOps} and {@code forbiddenNoInputBodyOps} are {@code null}, forbids 0-input ops in
245
- * the body. To allow all ops in the body, use {@code null} for {@code allowedNoInputBodyOps} and the empty set for
246
- * {@code forbiddenNoInputBodyOps}.
223
+ * Finds the operations used to produce {@code outputs}, assuming {@code inputs} are provided. Includes control dependencies.
224
+ * <p>
225
+ * Note that this function can easily return ops upstream of inputs as part of the body. Depending on your use, the
226
+ * returned body should probably be filtered for {@code Placeholder}s, at least.
247
227
*
248
228
* @param inputs the inputs of the subgraph. Must be from single output ops. May not be null.
249
229
* @param outputs the outputs of the subgraph. May not be null.
250
- * @param allowedNoInputBodyOps types of ops to allow as 0-input ops in the body. Allows all (except {@code
251
- * forbiddenNoInputBodyOps}) if null.
252
- * @param forbiddenNoInputBodyOps types of ops to never allow as 0-input ops in the body. Forbids all (except {@code
253
- * allowedNoInputBodyOps}) if null.
254
230
* @return the set of operations needed to calculate outputs from inputs, including outputs and inputs
255
- * @throws IllegalStateException if outputs depends on ops outside of the subgraph (i.e. is not calculable based
256
- * solely on inputs)
257
- * @see #completeSubgraph(Set, Set, boolean)
258
231
*/
259
- public synchronized Set <GraphOperation > completeSubgraph (Set <Operand <?>> inputs , Set <Operand <?>> outputs ,
260
- Set <String > allowedNoInputBodyOps , Set <String > forbiddenNoInputBodyOps ) {
261
-
262
- if (forbiddenNoInputBodyOps != null && allowedNoInputBodyOps != null ) {
263
- for (String t : forbiddenNoInputBodyOps ) {
264
- if (allowedNoInputBodyOps .contains (t )) {
265
- throw new IllegalArgumentException ("Can't allow and forbid op type " + t + "." );
266
- }
267
- }
268
- }
232
+ public synchronized Set <GraphOperation > completeSubgraph (Set <Operand <?>> inputs , Set <Operand <?>> outputs ) {
269
233
270
234
if (inputs == null ) {
271
235
throw new IllegalArgumentException ("Inputs can't be null." );
@@ -301,18 +265,6 @@ public synchronized Set<GraphOperation> completeSubgraph(Set<Operand<?>> inputs,
301
265
continue ;
302
266
}
303
267
304
- if (op .numControlInputs () + op .numInputs () == 0 ) {
305
- // inverted: (nothing is forbidden || not forbidden) and (everything is allowed || allowed) and (not both null)
306
- if ((forbiddenNoInputBodyOps != null && forbiddenNoInputBodyOps .contains (op .type ()))
307
- || (allowedNoInputBodyOps != null && !allowedNoInputBodyOps .contains (op .type ()))
308
- || (forbiddenNoInputBodyOps == null && allowedNoInputBodyOps == null )) {
309
- throw new IllegalStateException ("Operation " + op
310
- + " of type " + op .type () +
311
- " has no inputs and is not an allowed 0-input op type, but is not set as an input. "
312
- + "It is impossible to calculate the specified outputs with the given inputs." );
313
- }
314
- }
315
-
316
268
for (GraphOperation control : op .controlInputs ()) {
317
269
if (!inputOps .contains (control )) {
318
270
currents .add (control );
0 commit comments