From 0c4e17a62809e1f3490f0417b53a5d1dbe17ba1a Mon Sep 17 00:00:00 2001 From: Ryan Nett Date: Thu, 14 Oct 2021 19:16:22 -0700 Subject: [PATCH 01/11] Forcibly sort group fields Signed-off-by: Ryan Nett --- .../processor/operator/OperatorProcessor.java | 28 ++++++++++--------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/tensorflow-core/tensorflow-core-generator/src/main/java/org/tensorflow/processor/operator/OperatorProcessor.java b/tensorflow-core/tensorflow-core-generator/src/main/java/org/tensorflow/processor/operator/OperatorProcessor.java index 70c7bb0a7de..051d0104499 100644 --- a/tensorflow-core/tensorflow-core-generator/src/main/java/org/tensorflow/processor/operator/OperatorProcessor.java +++ b/tensorflow-core/tensorflow-core-generator/src/main/java/org/tensorflow/processor/operator/OperatorProcessor.java @@ -698,19 +698,21 @@ private static void addGroupFields( MethodSpec.Builder ctorBuilder, List groups, boolean isTopClass) { - groups.forEach( - group -> { - classBuilder.addField( - FieldSpec.builder(group.className, group.fieldName) - .addModifiers(Modifier.PUBLIC, Modifier.FINAL) - .build()); - ctorBuilder - .addStatement( - "$L = new $T(" + (isTopClass ? "this" : "ops") + ")", - group.fieldName, - group.className) - .build(); - }); + groups.stream() + .sorted(Comparator.comparing(g -> g.fieldName)) + .forEach( + group -> { + classBuilder.addField( + FieldSpec.builder(group.className, group.fieldName) + .addModifiers(Modifier.PUBLIC, Modifier.FINAL) + .build()); + ctorBuilder + .addStatement( + "$L = new $T(" + (isTopClass ? "this" : "ops") + ")", + group.fieldName, + group.className) + .build(); + }); } private static AnnotationMirror getAnnotationMirror(Element element, Name annotationName) { From d6a21c777dfbacd7935e66cb6d6713acf2d816e0 Mon Sep 17 00:00:00 2001 From: Ryan Nett Date: Thu, 14 Oct 2021 19:55:25 -0700 Subject: [PATCH 02/11] Add checks for un-committed generation Signed-off-by: Ryan Nett --- .github/actions/check-generation/action.yml | 10 ++++++++++ .github/workflows/ci.yml | 8 ++++++++ 2 files changed, 18 insertions(+) create mode 100644 .github/actions/check-generation/action.yml diff --git a/.github/actions/check-generation/action.yml b/.github/actions/check-generation/action.yml new file mode 100644 index 00000000000..998166bd916 --- /dev/null +++ b/.github/actions/check-generation/action.yml @@ -0,0 +1,10 @@ +name: "Check generation is committed" +description: "Ensure that all code generation is present in the commits" +runs: + using: composite + steps: + - shell: bash + run: | + git add . + git update-index --refresh + git diff-index --name-status --exit-code HEAD tensorflow-core/tensorflow-core-api/src/gen/** > changes.txt || echo "::error file=changes.txt,line=0,title=\"Un-commited generation\"::Generated classes after build do not match what was committed" \ No newline at end of file diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 9e001606a23..829edf75461 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -41,6 +41,8 @@ jobs: - name: Run lint checks run: | mvn compiler:compile -Pdev,jdk11 -B -U -e + - name: Check for un-committed generation + uses: ./.github/actions/check-generation check-format: if: github.event_name == 'pull_request' runs-on: ubuntu-latest @@ -148,6 +150,8 @@ jobs: echo Executing Maven $MAVEN_PHASE mvn clean $MAVEN_PHASE -B -U -e -Djavacpp.platform=linux-x86_64 -Djavacpp.platform.extension=${{ matrix.ext }} -pl $NATIVE_BUILD_PROJECTS -am -DstagingRepositoryId=${{ needs.prepare.outputs.stagingRepositoryId }} "-Dnative.build.flags=$BAZEL_CACHE" df -h + - name: Check for un-committed generation + uses: ./.github/actions/check-generation macosx-x86_64: if: github.event_name == 'push' || contains(github.event.pull_request.labels.*.name, 'CI build') runs-on: macos-latest @@ -184,6 +188,8 @@ jobs: echo Executing Maven $MAVEN_PHASE mvn clean $MAVEN_PHASE -B -U -e -Djavacpp.platform=macosx-x86_64 -Djavacpp.platform.extension=${{ matrix.ext }} -pl $NATIVE_BUILD_PROJECTS -am -DstagingRepositoryId=${{ needs.prepare.outputs.stagingRepositoryId }} "-Dnative.build.flags=$BAZEL_CACHE" df -h + - name: Check for un-committed generation + uses: ./.github/actions/check-generation windows-x86_64: if: github.event_name == 'push' || contains(github.event.pull_request.labels.*.name, 'CI build') runs-on: windows-latest @@ -261,6 +267,8 @@ jobs: if ERRORLEVEL 1 exit /b df -h wmic pagefile list /format:list + - name: Check for un-committed generation + uses: ./.github/actions/check-generation deploy: if: github.event_name == 'push' && contains(github.ref, 'master') needs: [linux-x86_64, macosx-x86_64, windows-x86_64] From 7edca55aa9d51d3a21216f3f8f498ef5ab33d6d4 Mon Sep 17 00:00:00 2001 From: Ryan Nett Date: Thu, 14 Oct 2021 20:05:23 -0700 Subject: [PATCH 03/11] Fix action Signed-off-by: Ryan Nett --- .github/actions/check-generation/action.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/actions/check-generation/action.yml b/.github/actions/check-generation/action.yml index 998166bd916..478e91bea04 100644 --- a/.github/actions/check-generation/action.yml +++ b/.github/actions/check-generation/action.yml @@ -5,6 +5,6 @@ runs: steps: - shell: bash run: | - git add . - git update-index --refresh - git diff-index --name-status --exit-code HEAD tensorflow-core/tensorflow-core-api/src/gen/** > changes.txt || echo "::error file=changes.txt,line=0,title=\"Un-commited generation\"::Generated classes after build do not match what was committed" \ No newline at end of file + git add . + git update-index --refresh + git diff-index --name-status --exit-code HEAD tensorflow-core/tensorflow-core-api/src/gen/** > changes.txt || echo "::error file=changes.txt,line=0,title=\"Un-commited generation\"::Generated classes after build do not match what was committed" \ No newline at end of file From 80bb0a895cdfbb0fe04bfd9f06596d3ae2ea7080 Mon Sep 17 00:00:00 2001 From: Ryan Nett Date: Thu, 14 Oct 2021 20:16:11 -0700 Subject: [PATCH 04/11] Try inline action Signed-off-by: Ryan Nett --- .github/workflows/ci.yml | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 829edf75461..2a6b80ce0a3 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -41,8 +41,11 @@ jobs: - name: Run lint checks run: | mvn compiler:compile -Pdev,jdk11 -B -U -e - - name: Check for un-committed generation - uses: ./.github/actions/check-generation + - shell: bash + run: | + git add . + git update-index --refresh + git diff-index --name-status --exit-code HEAD tensorflow-core/tensorflow-core-api/src/gen/** > changes.txt || echo "::error file=changes.txt,line=0,title=\"Un-commited generation\"::Generated classes after build do not match what was committed" check-format: if: github.event_name == 'pull_request' runs-on: ubuntu-latest From c2e4b4afefb82d62e546c10fdc46f5f598cabe16 Mon Sep 17 00:00:00 2001 From: Ryan Nett Date: Thu, 14 Oct 2021 20:27:02 -0700 Subject: [PATCH 05/11] Try manually installing git Signed-off-by: Ryan Nett --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 2a6b80ce0a3..4ce9c093876 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -26,7 +26,7 @@ jobs: run: | yum -y update yum -y install centos-release-scl-rh epel-release - yum -y install java-11-openjdk-devel devtoolset-7 + yum -y install java-11-openjdk-devel devtoolset-7 git echo Downloading Maven curl -L https://archive.apache.org/dist/maven/maven-3/3.6.3/binaries/apache-maven-3.6.3-bin.tar.gz -o $HOME/apache-maven-3.6.3-bin.tar.gz tar xzf $HOME/apache-maven-3.6.3-bin.tar.gz -C /opt/ From fc73e62c350cd040a02afb131eb79821f183b685 Mon Sep 17 00:00:00 2001 From: Ryan Nett Date: Thu, 14 Oct 2021 20:41:44 -0700 Subject: [PATCH 06/11] Try using fatal Signed-off-by: Ryan Nett --- .github/actions/check-generation/action.yml | 2 +- .github/workflows/ci.yml | 9 +++------ 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/.github/actions/check-generation/action.yml b/.github/actions/check-generation/action.yml index 478e91bea04..e262ff99385 100644 --- a/.github/actions/check-generation/action.yml +++ b/.github/actions/check-generation/action.yml @@ -7,4 +7,4 @@ runs: run: | git add . git update-index --refresh - git diff-index --name-status --exit-code HEAD tensorflow-core/tensorflow-core-api/src/gen/** > changes.txt || echo "::error file=changes.txt,line=0,title=\"Un-commited generation\"::Generated classes after build do not match what was committed" \ No newline at end of file + git diff-index --name-status --exit-code HEAD tensorflow-core/tensorflow-core-api/src/gen/** > changes.txt || echo "::fatal file=changes.txt,line=0,title=\"Un-commited generation\"::Generated classes after build do not match what was committed" \ No newline at end of file diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 4ce9c093876..829edf75461 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -26,7 +26,7 @@ jobs: run: | yum -y update yum -y install centos-release-scl-rh epel-release - yum -y install java-11-openjdk-devel devtoolset-7 git + yum -y install java-11-openjdk-devel devtoolset-7 echo Downloading Maven curl -L https://archive.apache.org/dist/maven/maven-3/3.6.3/binaries/apache-maven-3.6.3-bin.tar.gz -o $HOME/apache-maven-3.6.3-bin.tar.gz tar xzf $HOME/apache-maven-3.6.3-bin.tar.gz -C /opt/ @@ -41,11 +41,8 @@ jobs: - name: Run lint checks run: | mvn compiler:compile -Pdev,jdk11 -B -U -e - - shell: bash - run: | - git add . - git update-index --refresh - git diff-index --name-status --exit-code HEAD tensorflow-core/tensorflow-core-api/src/gen/** > changes.txt || echo "::error file=changes.txt,line=0,title=\"Un-commited generation\"::Generated classes after build do not match what was committed" + - name: Check for un-committed generation + uses: ./.github/actions/check-generation check-format: if: github.event_name == 'pull_request' runs-on: ubuntu-latest From c54dec882bbe822894c30b437eb4b2cf8b650109 Mon Sep 17 00:00:00 2001 From: Ryan Nett Date: Thu, 14 Oct 2021 20:51:20 -0700 Subject: [PATCH 07/11] Install git again Signed-off-by: Ryan Nett --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 829edf75461..1859ad49be3 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -26,7 +26,7 @@ jobs: run: | yum -y update yum -y install centos-release-scl-rh epel-release - yum -y install java-11-openjdk-devel devtoolset-7 + yum -y install java-11-openjdk-devel devtoolset-7 git echo Downloading Maven curl -L https://archive.apache.org/dist/maven/maven-3/3.6.3/binaries/apache-maven-3.6.3-bin.tar.gz -o $HOME/apache-maven-3.6.3-bin.tar.gz tar xzf $HOME/apache-maven-3.6.3-bin.tar.gz -C /opt/ From 3a02f183d15a81774596a37550b6f114f684a4a4 Mon Sep 17 00:00:00 2001 From: Ryan Nett Date: Thu, 14 Oct 2021 21:05:30 -0700 Subject: [PATCH 08/11] Force exit on error Signed-off-by: Ryan Nett --- .github/actions/check-generation/action.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/actions/check-generation/action.yml b/.github/actions/check-generation/action.yml index e262ff99385..dd1de617f1a 100644 --- a/.github/actions/check-generation/action.yml +++ b/.github/actions/check-generation/action.yml @@ -7,4 +7,5 @@ runs: run: | git add . git update-index --refresh - git diff-index --name-status --exit-code HEAD tensorflow-core/tensorflow-core-api/src/gen/** > changes.txt || echo "::fatal file=changes.txt,line=0,title=\"Un-commited generation\"::Generated classes after build do not match what was committed" \ No newline at end of file + git diff-index --name-status --exit-code HEAD tensorflow-core/tensorflow-core-api/src/gen/** || \ + (echo "::error file=changes.txt,line=0,title=\"Un-commited generation\"::Generated classes after build do not match what was committed" ; exit 1) \ No newline at end of file From 2fbe3e78d8674f8ad1e1593b8a297013f690831b Mon Sep 17 00:00:00 2001 From: Ryan Nett Date: Thu, 14 Oct 2021 21:41:27 -0700 Subject: [PATCH 09/11] Show diff on failure Signed-off-by: Ryan Nett --- .github/actions/check-generation/action.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/actions/check-generation/action.yml b/.github/actions/check-generation/action.yml index dd1de617f1a..146b0d1718c 100644 --- a/.github/actions/check-generation/action.yml +++ b/.github/actions/check-generation/action.yml @@ -7,5 +7,5 @@ runs: run: | git add . git update-index --refresh - git diff-index --name-status --exit-code HEAD tensorflow-core/tensorflow-core-api/src/gen/** || \ - (echo "::error file=changes.txt,line=0,title=\"Un-commited generation\"::Generated classes after build do not match what was committed" ; exit 1) \ No newline at end of file + git diff-index --quiet --exit-code HEAD tensorflow-core/tensorflow-core-api/src/gen/** || \ + (git diff -- ; echo "::error file=changes.txt,line=0,title=\"Un-commited generation\"::Generated classes after build do not match what was committed" ; exit 1) \ No newline at end of file From a8d9cb1a76b63a6b5a11e8ca4f6a2f4585479740 Mon Sep 17 00:00:00 2001 From: Ryan Nett Date: Sat, 16 Oct 2021 15:36:17 -0700 Subject: [PATCH 10/11] Show diff output Signed-off-by: Ryan Nett --- .github/actions/check-generation/action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/actions/check-generation/action.yml b/.github/actions/check-generation/action.yml index 146b0d1718c..a3332f99a9c 100644 --- a/.github/actions/check-generation/action.yml +++ b/.github/actions/check-generation/action.yml @@ -8,4 +8,4 @@ runs: git add . git update-index --refresh git diff-index --quiet --exit-code HEAD tensorflow-core/tensorflow-core-api/src/gen/** || \ - (git diff -- ; echo "::error file=changes.txt,line=0,title=\"Un-commited generation\"::Generated classes after build do not match what was committed" ; exit 1) \ No newline at end of file + (git --no-pager diff HEAD -- ; echo "::error file=changes.txt,line=0,title=\"Un-commited generation\"::Generated classes after build do not match what was committed" ; exit 1) \ No newline at end of file From b26f5e0cb8515333a09c4553b3a333c60f01f3ac Mon Sep 17 00:00:00 2001 From: Ryan Nett Date: Sat, 16 Oct 2021 15:57:58 -0700 Subject: [PATCH 11/11] Fix format and update generated ops file Signed-off-by: Ryan Nett --- .../annotations/org/tensorflow/op/Ops.java | 64 +++++++++---------- 1 file changed, 32 insertions(+), 32 deletions(-) diff --git a/tensorflow-core/tensorflow-core-api/src/gen/annotations/org/tensorflow/op/Ops.java b/tensorflow-core/tensorflow-core-api/src/gen/annotations/org/tensorflow/op/Ops.java index b4ab7753142..4728f0a0c89 100644 --- a/tensorflow-core/tensorflow-core-api/src/gen/annotations/org/tensorflow/op/Ops.java +++ b/tensorflow-core/tensorflow-core-api/src/gen/annotations/org/tensorflow/op/Ops.java @@ -341,70 +341,70 @@ * } */ public final class Ops { - public final NnOps nn; - - public final SummaryOps summary; - - public final ImageOps image; + public final AudioOps audio; - public final RaggedOps ragged; + public final BitwiseOps bitwise; public final DataOps data; - public final ShapeOps shape; + public final DtypesOps dtypes; + + public final ImageOps image; public final IoOps io; - public final DtypesOps dtypes; + public final LinalgOps linalg; - public final XlaOps xla; + public final MathOps math; - public final LinalgOps linalg; + public final NnOps nn; - public final RandomOps random; + public final QuantizationOps quantization; - public final StringsOps strings; + public final RaggedOps ragged; - public final SparseOps sparse; + public final RandomOps random; - public final BitwiseOps bitwise; + public final ShapeOps shape; - public final TpuOps tpu; + public final SignalOps signal; - public final MathOps math; + public final SparseOps sparse; - public final AudioOps audio; + public final StringsOps strings; - public final SignalOps signal; + public final SummaryOps summary; + + public final TpuOps tpu; public final TrainOps train; - public final QuantizationOps quantization; + public final XlaOps xla; private final Scope scope; private Ops(Scope scope) { this.scope = scope; - nn = new NnOps(this); - summary = new SummaryOps(this); - image = new ImageOps(this); - ragged = new RaggedOps(this); + audio = new AudioOps(this); + bitwise = new BitwiseOps(this); data = new DataOps(this); - shape = new ShapeOps(this); - io = new IoOps(this); dtypes = new DtypesOps(this); - xla = new XlaOps(this); + image = new ImageOps(this); + io = new IoOps(this); linalg = new LinalgOps(this); + math = new MathOps(this); + nn = new NnOps(this); + quantization = new QuantizationOps(this); + ragged = new RaggedOps(this); random = new RandomOps(this); - strings = new StringsOps(this); + shape = new ShapeOps(this); + signal = new SignalOps(this); sparse = new SparseOps(this); - bitwise = new BitwiseOps(this); + strings = new StringsOps(this); + summary = new SummaryOps(this); tpu = new TpuOps(this); - math = new MathOps(this); - audio = new AudioOps(this); - signal = new SignalOps(this); train = new TrainOps(this); - quantization = new QuantizationOps(this); + xla = new XlaOps(this); } /**