| 134 | } |
| 135 | |
| 136 | void NodeDefBuilder::ListInput(const OpDef::ArgDef* input_arg, |
| 137 | gtl::ArraySlice<NodeOut> src_list) { |
| 138 | for (const auto& node_out : src_list) { |
| 139 | AddInput(node_out.node, node_out.index); |
| 140 | } |
| 141 | |
| 142 | if (!input_arg->number_attr().empty()) { |
| 143 | Attr(input_arg->number_attr(), static_cast<int64>(src_list.size())); |
| 144 | if (input_arg->type() != DT_INVALID) { |
| 145 | const DataType expected = MaybeAddRef(input_arg, input_arg->type()); |
| 146 | for (const auto& node_out : src_list) { |
| 147 | VerifyInputType(input_arg, expected, node_out.data_type); |
| 148 | } |
| 149 | } else if (!src_list.empty()) { |
| 150 | const DataType base = BaseType(src_list[0].data_type); |
| 151 | Attr(input_arg->type_attr(), base); |
| 152 | const DataType expected = MaybeAddRef(input_arg, base); |
| 153 | for (const auto& node_out : src_list) { |
| 154 | VerifyInputType(input_arg, expected, node_out.data_type); |
| 155 | } |
| 156 | } |
| 157 | } else if (!input_arg->type_list_attr().empty()) { |
| 158 | DataTypeVector type_vec; |
| 159 | type_vec.reserve(src_list.size()); |
| 160 | for (const auto& node_out : src_list) { |
| 161 | const DataType dt = node_out.data_type; |
| 162 | VerifyInputRef(input_arg, dt); |
| 163 | type_vec.push_back(BaseType(dt)); |
| 164 | } |
| 165 | Attr(input_arg->type_list_attr(), type_vec); |
| 166 | } else { |
| 167 | errors_.push_back(strings::StrCat("List provided to input '", |
| 168 | input_arg->name(), |
| 169 | "' when single Tensor expected")); |
| 170 | } |
| 171 | } |
| 172 | |
| 173 | void NodeDefBuilder::AddInput(StringPiece src_node, int src_index) { |
| 174 | if (src_node.empty()) { |