MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / RenderOptionsClass

Function RenderOptionsClass

tensorflow/java/src/gen/cc/op_generator.cc:387–411  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

385}
386
387void RenderOptionsClass(const OpSpec& op, const Type& op_class,
388 SourceWriter* writer) {
389 Type options_class = Type::Class("Options");
390 Javadoc options_doc = Javadoc::Create("Optional attributes for {@link " +
391 op_class.canonical_name() + "}");
392 writer->BeginInnerType(options_class, PUBLIC | STATIC, &options_doc);
393 for (const AttributeSpec& attr : op.optional_attributes()) {
394 Method setter = Method::Create(attr.var().name(), options_class);
395 Javadoc setter_doc = Javadoc::Create();
396 AddArgument(attr.var(), attr.description(), &setter, &setter_doc);
397 writer->BeginMethod(setter, PUBLIC, &setter_doc)
398 .Append("this." + attr.var().name() + " = " + attr.var().name() + ";")
399 .EndLine()
400 .Append("return this;")
401 .EndLine()
402 .EndMethod();
403 }
404 writer->EndLine();
405 for (const AttributeSpec& optional_attribute : op.optional_attributes()) {
406 writer->WriteField(optional_attribute.var(), PRIVATE);
407 }
408 Method constructor = Method::ConstructorFor(options_class);
409 writer->BeginMethod(constructor, PRIVATE).EndMethod();
410 writer->EndType();
411}
412
413inline Type ClassOf(const EndpointSpec& endpoint, const string& base_package) {
414 return Type::Class(

Callers 1

GenerateOpFunction · 0.85

Calls 7

AddArgumentFunction · 0.85
canonical_nameMethod · 0.80
descriptionMethod · 0.80
nameMethod · 0.65
CreateFunction · 0.50
varMethod · 0.45
AppendMethod · 0.45

Tested by

no test coverage detected