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

Function WriteSetAttrDirective

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

Source from the content-addressed store, hash-verified

112}
113
114void WriteSetAttrDirective(const AttributeSpec& attr, bool optional,
115 SourceWriter* writer) {
116 string var_name = optional ? "opts." + attr.var().name() : attr.var().name();
117 if (attr.iterable()) {
118 string array_name = attr.var().name() + "Array";
119 writer->AppendType(attr.jni_type())
120 .Append("[] " + array_name + " = new ")
121 .AppendType(attr.jni_type())
122 .Append("[" + var_name + ".size()];")
123 .EndLine()
124 .BeginBlock("for (int i = 0; i < " + array_name + ".length; ++i)")
125 .Append(array_name + "[i] = ");
126 if (attr.type().kind() == Type::GENERIC) {
127 writer->Append("DataType.fromClass(" + var_name + ".get(i));");
128 } else {
129 writer->Append(var_name + ".get(i);");
130 }
131 writer->EndLine()
132 .EndBlock()
133 .Append("opBuilder.setAttr(\"" + attr.op_def_name() + "\", ")
134 .Append(array_name + ");")
135 .EndLine();
136 } else {
137 writer->Append("opBuilder.setAttr(\"" + attr.op_def_name() + "\", ");
138 if (attr.var().type().name() == "Class") {
139 writer->Append("DataType.fromClass(" + var_name + "));");
140 } else {
141 writer->Append(var_name + ");");
142 }
143 writer->EndLine();
144 }
145}
146
147void RenderSecondaryFactoryMethod(const OpSpec& op, const Type& op_class,
148 std::map<string, Type> default_types,

Callers 1

RenderFactoryMethodsFunction · 0.85

Calls 6

nameMethod · 0.65
typeMethod · 0.65
varMethod · 0.45
iterableMethod · 0.45
AppendMethod · 0.45
kindMethod · 0.45

Tested by

no test coverage detected