1 /* Copyright 2017 The TensorFlow Authors. All Rights Reserved. 2 3 Licensed under the Apache License, Version 2.0 (the "License"); 4 you may not use this file except in compliance with the License. 5 You may obtain a copy of the License at 6 7 http://www.apache.org/licenses/LICENSE-2.0 8 9 Unless required by applicable law or agreed to in writing, software 10 distributed under the License is distributed on an "AS IS" BASIS, 11 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 See the License for the specific language governing permissions and 13 limitations under the License. 14 ==============================================================================*/ 15 16 package org.tensorflow.op; 17 18 import java.util.ArrayList; 19 import java.util.List; 20 import org.tensorflow.Operand; 21 import org.tensorflow.OperationBuilder; 22 import org.tensorflow.Output; 23 24 /** Utilities for manipulating operand related types and lists. */ 25 public final class Operands { 26 27 /** 28 * Converts a list of {@link Operand} into an array of {@link Output}. 29 * 30 * <p>Operation wrappers need to convert back a list of inputs into an array of outputs in order 31 * to build an operation, see {@link OperationBuilder#addInputList(Output[])}. 32 * 33 * @param inputs an iteration of input operands 34 * @return an array of outputs 35 */ 36 public static Output<?>[] asOutputs(Iterable<? extends Operand<?>> inputs) { 37 List<Output<?>> outputList = new ArrayList<>(); 38 for (Operand<?> input : inputs) { 39 outputList.add(input.asOutput()); 40 } 41 return outputList.toArray(new Output<?>[outputList.size()]); 42 } 43 44 // Disabled constructor 45 private Operands() {} 46 } 47