| 352 | } // namespace |
| 353 | |
| 354 | OpSpec OpSpec::Create(const OpDef& op_def, const ApiDef& api_def) { |
| 355 | OpSpec op(api_def.graph_op_name(), api_def.visibility() == ApiDef::HIDDEN, |
| 356 | op_def.deprecation().explanation()); |
| 357 | TypeResolver type_resolver(op_def); |
| 358 | for (const string& next_input_name : api_def.arg_order()) { |
| 359 | for (int i = 0; i < op_def.input_arg().size(); ++i) { |
| 360 | if (op_def.input_arg(i).name() == next_input_name) { |
| 361 | op.inputs_.push_back(CreateInput(op_def.input_arg(i), api_def.in_arg(i), |
| 362 | &type_resolver)); |
| 363 | break; |
| 364 | } |
| 365 | } |
| 366 | } |
| 367 | for (int i = 0; i < op_def.attr().size(); ++i) { |
| 368 | // do not parse attributes already visited, they have probably been inferred |
| 369 | // before as an input argument type |
| 370 | if (!type_resolver.IsAttributeVisited(op_def.attr(i).name())) { |
| 371 | AttributeSpec attr = |
| 372 | CreateAttribute(op_def.attr(i), api_def.attr(i), &type_resolver); |
| 373 | // attributes with a default value are optional |
| 374 | if (attr.has_default_value() && attr.type().kind() != Type::GENERIC) { |
| 375 | op.optional_attributes_.push_back(attr); |
| 376 | } else { |
| 377 | op.attributes_.push_back(attr); |
| 378 | } |
| 379 | } |
| 380 | } |
| 381 | for (int i = 0; i < op_def.output_arg().size(); ++i) { |
| 382 | op.outputs_.push_back( |
| 383 | CreateOutput(op_def.output_arg(i), api_def.out_arg(i), &type_resolver)); |
| 384 | } |
| 385 | for (const auto& endpoint_def : api_def.endpoint()) { |
| 386 | op.endpoints_.push_back(CreateEndpoint(op_def, api_def, endpoint_def)); |
| 387 | } |
| 388 | return op; |
| 389 | } |
| 390 | |
| 391 | } // namespace java |
| 392 | } // namespace tensorflow |
nothing calls this directly
no test coverage detected