Skip to content

Commit 57a3d8e

Browse files
committed
Use OP_NAME constant instead of hard coding name
Signed-off-by: Ryan Nett <[email protected]>
1 parent daeb257 commit 57a3d8e

File tree

1 file changed

+6
-3
lines changed
  • tensorflow-core/tensorflow-core-generator/src/main/java/org/tensorflow/op/generator

1 file changed

+6
-3
lines changed

tensorflow-core/tensorflow-core-generator/src/main/java/org/tensorflow/op/generator/ClassGenerator.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,8 @@ static boolean canGenerateOp(OpDef op, ApiDef apiDef) {
6666
&& !op.getName().startsWith("_"); //TODO do I want this? Some interesting ops like _XlaCompile
6767
}
6868

69+
private static final String OP_NAME_FIELD_NAME = "OP_NAME";
70+
6971
enum RenderMode {
7072
DEFAULT, LIST_OPERAND, OPERAND;
7173
}
@@ -305,7 +307,7 @@ void buildClass() {
305307

306308
// add op name field
307309
builder
308-
.addField(FieldSpec.builder(TypeResolver.STRING, "OP_NAME", Modifier.PUBLIC, Modifier.STATIC, Modifier.FINAL)
310+
.addField(FieldSpec.builder(TypeResolver.STRING, OP_NAME_FIELD_NAME, Modifier.PUBLIC, Modifier.STATIC, Modifier.FINAL)
309311
.addJavadoc("$L", "The name of this op, as known by TensorFlow core engine")
310312
.initializer("$S", op.getName())
311313
.build());
@@ -463,8 +465,9 @@ private void buildFactoryMethods() {
463465

464466
Set<TypeVariableName> typeVars = new LinkedHashSet<>(typeParams);
465467

466-
body.addStatement("$T opBuilder = scope.env().opBuilder($S, scope.makeOpName($S))",
467-
Names.OperationBuilder, op.getName(),
468+
body.addStatement("$T opBuilder = scope.env().opBuilder($L, scope.makeOpName($S))",
469+
Names.OperationBuilder,
470+
OP_NAME_FIELD_NAME,
468471
className);
469472

470473
// add the inputs as parameters, and add them to the op builder

0 commit comments

Comments
 (0)