未验证 提交 7ea0ff50 编写于 作者: J jwithers 提交者: GitHub

fail PRs that overwrite a set of files from upstream (#195)

* fail PRs that overwrite a set of files from upstream

* Change some names, modify Python script logic etc.

* small fixes.

* Use more restrictive TFLM-bot token.
Co-authored-by: NAdvait Jain <advaitjain@users.noreply.github.com>
Co-authored-by: NAdvait Jain <advaitjain@google.com>
上级 6197a422
name: Check TfLite Files
on:
pull_request_target:
types: [labeled]
jobs:
check_tflite_files:
runs-on: ubuntu-latest
if: |
contains(github.event.pull_request.labels.*.name, 'ci:run') &&
${{ !contains(github.event.pull_request.body, 'NO_CHECK_TFLITE_FILES') }}
name: Check PR Modifies TfLite Files
steps:
- uses: actions/checkout@v2
with:
ref: ${{ github.event.pull_request.head.sha }}
- name: Check Files
run: |
URL="https://api.github.com/repos/${{ github.repository }}/pulls/${{ github.event.pull_request.number }}/files"
PR_FILES=$(curl -s -X GET -H "Authorization: Bearer ${{ secrets.TFLM_BOT_REPO_TOKEN }}" $URL | jq -r '.[] | .filename')
rm -rf /tmp/pull_request_files.txt
echo "${PR_FILES}" >> /tmp/pull_request_files.txt
python3 ci/check_tflite_files.py /tmp/pull_request_files.txt
TFLITE_FILE_TEST_STATUS=$?
rm -f /tmp/pull_request_files.txt
exit ${TFLITE_FILE_TEST_STATUS}
# Copyright 2021 The TensorFlow Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# ==============================================================================
import argparse
import sys
if __name__=="__main__":
parser = argparse.ArgumentParser()
parser.add_argument("pr_files", help="File with list of files modified by the Pull Request", default="")
args = parser.parse_args()
tflite_files = set(line.strip() for line in open("ci/upstream_list.txt"))
pr_files = set(line.strip() for line in open(args.pr_files))
tflite_files_in_pr = tflite_files.intersection(pr_files)
if len(tflite_files_in_pr) != 0:
print("The following files should be modified in the upstream Tensorflow repo:")
print("\n".join(tflite_files_in_pr))
sys.exit(1)
else:
print("No TfLite files are modified in the PR. We can proceed.")
......@@ -31,99 +31,7 @@ rm -rf /tmp/tensorflow
git clone https://github.com/tensorflow/tensorflow.git --depth=1 /tmp/tensorflow
SHARED_TFL_CODE="\
tensorflow/lite/c/common.c \
tensorflow/lite/core/api/error_reporter.cc \
tensorflow/lite/core/api/flatbuffer_conversions.cc \
tensorflow/lite/core/api/op_resolver.cc \
tensorflow/lite/core/api/tensor_utils.cc \
tensorflow/lite/kernels/internal/quantization_util.cc \
tensorflow/lite/kernels/kernel_util.cc \
tensorflow/lite/schema/schema_utils.cc
tensorflow/lite/c/builtin_op_data.h \
tensorflow/lite/c/c_api_types.h \
tensorflow/lite/c/common.h \
tensorflow/lite/core/api/error_reporter.h \
tensorflow/lite/core/api/flatbuffer_conversions.h \
tensorflow/lite/core/api/op_resolver.h \
tensorflow/lite/core/api/tensor_utils.h \
tensorflow/lite/kernels/internal/common.h \
tensorflow/lite/kernels/internal/compatibility.h \
tensorflow/lite/kernels/internal/quantization_util.h \
tensorflow/lite/kernels/internal/reference/add.h \
tensorflow/lite/kernels/internal/reference/add_n.h \
tensorflow/lite/kernels/internal/reference/arg_min_max.h \
tensorflow/lite/kernels/internal/reference/batch_to_space_nd.h \
tensorflow/lite/kernels/internal/reference/batch_matmul.h \
tensorflow/lite/kernels/internal/reference/binary_function.h \
tensorflow/lite/kernels/internal/reference/ceil.h \
tensorflow/lite/kernels/internal/reference/comparisons.h \
tensorflow/lite/kernels/internal/reference/concatenation.h \
tensorflow/lite/kernels/internal/reference/conv.h \
tensorflow/lite/kernels/internal/reference/cumsum.h \
tensorflow/lite/kernels/internal/reference/depth_to_space.h \
tensorflow/lite/kernels/internal/reference/depthwiseconv_float.h \
tensorflow/lite/kernels/internal/reference/depthwiseconv_uint8.h \
tensorflow/lite/kernels/internal/reference/dequantize.h \
tensorflow/lite/kernels/internal/reference/elu.h \
tensorflow/lite/kernels/internal/reference/exp.h \
tensorflow/lite/kernels/internal/reference/fill.h \
tensorflow/lite/kernels/internal/reference/floor.h \
tensorflow/lite/kernels/internal/reference/floor_div.h \
tensorflow/lite/kernels/internal/reference/floor_mod.h \
tensorflow/lite/kernels/internal/reference/fully_connected.h \
tensorflow/lite/kernels/internal/reference/hard_swish.h \
tensorflow/lite/kernels/internal/reference/integer_ops/add.h \
tensorflow/lite/kernels/internal/reference/integer_ops/conv.h \
tensorflow/lite/kernels/internal/reference/integer_ops/depthwise_conv.h \
tensorflow/lite/kernels/internal/reference/integer_ops/fully_connected.h \
tensorflow/lite/kernels/internal/reference/integer_ops/logistic.h \
tensorflow/lite/kernels/internal/reference/integer_ops/l2normalization.h \
tensorflow/lite/kernels/internal/reference/integer_ops/mean.h \
tensorflow/lite/kernels/internal/reference/integer_ops/mul.h \
tensorflow/lite/kernels/internal/reference/integer_ops/pooling.h \
tensorflow/lite/kernels/internal/reference/integer_ops/tanh.h \
tensorflow/lite/kernels/internal/reference/integer_ops/transpose_conv.h \
tensorflow/lite/kernels/internal/reference/l2normalization.h \
tensorflow/lite/kernels/internal/reference/leaky_relu.h \
tensorflow/lite/kernels/internal/reference/log_softmax.h \
tensorflow/lite/kernels/internal/reference/maximum_minimum.h \
tensorflow/lite/kernels/internal/reference/mul.h \
tensorflow/lite/kernels/internal/reference/neg.h \
tensorflow/lite/kernels/internal/reference/pad.h \
tensorflow/lite/kernels/internal/reference/pooling.h \
tensorflow/lite/kernels/internal/reference/prelu.h \
tensorflow/lite/kernels/internal/reference/process_broadcast_shapes.h \
tensorflow/lite/kernels/internal/reference/quantize.h \
tensorflow/lite/kernels/internal/reference/reduce.h \
tensorflow/lite/kernels/internal/reference/requantize.h \
tensorflow/lite/kernels/internal/reference/resize_bilinear.h \
tensorflow/lite/kernels/internal/reference/resize_nearest_neighbor.h \
tensorflow/lite/kernels/internal/reference/round.h \
tensorflow/lite/kernels/internal/reference/softmax.h \
tensorflow/lite/kernels/internal/reference/space_to_batch_nd.h \
tensorflow/lite/kernels/internal/reference/space_to_depth.h \
tensorflow/lite/kernels/internal/reference/sub.h \
tensorflow/lite/kernels/internal/reference/logistic.h \
tensorflow/lite/kernels/internal/reference/strided_slice.h \
tensorflow/lite/kernels/internal/reference/tanh.h \
tensorflow/lite/kernels/internal/reference/transpose.h \
tensorflow/lite/kernels/internal/reference/transpose_conv.h \
tensorflow/lite/kernels/internal/cppmath.h \
tensorflow/lite/kernels/internal/max.h \
tensorflow/lite/kernels/internal/min.h \
tensorflow/lite/kernels/internal/portable_tensor.h \
tensorflow/lite/kernels/internal/strided_slice_logic.h \
tensorflow/lite/kernels/internal/tensor_ctypes.h \
tensorflow/lite/kernels/internal/tensor_utils_common.h \
tensorflow/lite/kernels/internal/types.h \
tensorflow/lite/kernels/kernel_util.h \
tensorflow/lite/kernels/op_macros.h \
tensorflow/lite/kernels/padding.h \
tensorflow/lite/portable_type_to_tflitetype.h \
tensorflow/lite/schema/schema_generated.h \
tensorflow/lite/schema/schema_utils.h \
"
SHARED_TFL_CODE=$(<ci/tflite_files.txt)
for filepath in ${SHARED_TFL_CODE}
do
......
tensorflow/lite/c/common.c
tensorflow/lite/core/api/error_reporter.cc
tensorflow/lite/core/api/flatbuffer_conversions.cc
tensorflow/lite/core/api/op_resolver.cc
tensorflow/lite/core/api/tensor_utils.cc
tensorflow/lite/kernels/internal/quantization_util.cc
tensorflow/lite/kernels/kernel_util.cc
tensorflow/lite/schema/schema_utils.cc
tensorflow/lite/c/builtin_op_data.h
tensorflow/lite/c/c_api_types.h
tensorflow/lite/c/common.h
tensorflow/lite/core/api/error_reporter.h
tensorflow/lite/core/api/flatbuffer_conversions.h
tensorflow/lite/core/api/op_resolver.h
tensorflow/lite/core/api/tensor_utils.h
tensorflow/lite/kernels/internal/common.h
tensorflow/lite/kernels/internal/compatibility.h
tensorflow/lite/kernels/internal/quantization_util.h
tensorflow/lite/kernels/internal/reference/add.h
tensorflow/lite/kernels/internal/reference/add_n.h
tensorflow/lite/kernels/internal/reference/arg_min_max.h
tensorflow/lite/kernels/internal/reference/batch_to_space_nd.h
tensorflow/lite/kernels/internal/reference/batch_matmul.h
tensorflow/lite/kernels/internal/reference/binary_function.h
tensorflow/lite/kernels/internal/reference/ceil.h
tensorflow/lite/kernels/internal/reference/comparisons.h
tensorflow/lite/kernels/internal/reference/concatenation.h
tensorflow/lite/kernels/internal/reference/conv.h
tensorflow/lite/kernels/internal/reference/cumsum.h
tensorflow/lite/kernels/internal/reference/depth_to_space.h
tensorflow/lite/kernels/internal/reference/depthwiseconv_float.h
tensorflow/lite/kernels/internal/reference/depthwiseconv_uint8.h
tensorflow/lite/kernels/internal/reference/dequantize.h
tensorflow/lite/kernels/internal/reference/elu.h
tensorflow/lite/kernels/internal/reference/exp.h
tensorflow/lite/kernels/internal/reference/fill.h
tensorflow/lite/kernels/internal/reference/floor.h
tensorflow/lite/kernels/internal/reference/floor_div.h
tensorflow/lite/kernels/internal/reference/floor_mod.h
tensorflow/lite/kernels/internal/reference/fully_connected.h
tensorflow/lite/kernels/internal/reference/hard_swish.h
tensorflow/lite/kernels/internal/reference/integer_ops/add.h
tensorflow/lite/kernels/internal/reference/integer_ops/conv.h
tensorflow/lite/kernels/internal/reference/integer_ops/depthwise_conv.h
tensorflow/lite/kernels/internal/reference/integer_ops/fully_connected.h
tensorflow/lite/kernels/internal/reference/integer_ops/logistic.h
tensorflow/lite/kernels/internal/reference/integer_ops/l2normalization.h
tensorflow/lite/kernels/internal/reference/integer_ops/mean.h
tensorflow/lite/kernels/internal/reference/integer_ops/mul.h
tensorflow/lite/kernels/internal/reference/integer_ops/pooling.h
tensorflow/lite/kernels/internal/reference/integer_ops/tanh.h
tensorflow/lite/kernels/internal/reference/integer_ops/transpose_conv.h
tensorflow/lite/kernels/internal/reference/l2normalization.h
tensorflow/lite/kernels/internal/reference/leaky_relu.h
tensorflow/lite/kernels/internal/reference/log_softmax.h
tensorflow/lite/kernels/internal/reference/maximum_minimum.h
tensorflow/lite/kernels/internal/reference/mul.h
tensorflow/lite/kernels/internal/reference/neg.h
tensorflow/lite/kernels/internal/reference/pad.h
tensorflow/lite/kernels/internal/reference/pooling.h
tensorflow/lite/kernels/internal/reference/prelu.h
tensorflow/lite/kernels/internal/reference/process_broadcast_shapes.h
tensorflow/lite/kernels/internal/reference/quantize.h
tensorflow/lite/kernels/internal/reference/reduce.h
tensorflow/lite/kernels/internal/reference/requantize.h
tensorflow/lite/kernels/internal/reference/resize_bilinear.h
tensorflow/lite/kernels/internal/reference/resize_nearest_neighbor.h
tensorflow/lite/kernels/internal/reference/round.h
tensorflow/lite/kernels/internal/reference/softmax.h
tensorflow/lite/kernels/internal/reference/space_to_batch_nd.h
tensorflow/lite/kernels/internal/reference/space_to_depth.h
tensorflow/lite/kernels/internal/reference/sub.h
tensorflow/lite/kernels/internal/reference/logistic.h
tensorflow/lite/kernels/internal/reference/strided_slice.h
tensorflow/lite/kernels/internal/reference/tanh.h
tensorflow/lite/kernels/internal/reference/transpose.h
tensorflow/lite/kernels/internal/reference/transpose_conv.h
tensorflow/lite/kernels/internal/cppmath.h
tensorflow/lite/kernels/internal/max.h
tensorflow/lite/kernels/internal/min.h
tensorflow/lite/kernels/internal/portable_tensor.h
tensorflow/lite/kernels/internal/strided_slice_logic.h
tensorflow/lite/kernels/internal/tensor_ctypes.h
tensorflow/lite/kernels/internal/tensor_utils_common.h
tensorflow/lite/kernels/internal/types.h
tensorflow/lite/kernels/kernel_util.h
tensorflow/lite/kernels/op_macros.h
tensorflow/lite/kernels/padding.h
tensorflow/lite/portable_type_to_tflitetype.h
tensorflow/lite/schema/schema_generated.h
tensorflow/lite/schema/schema_utils.h
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册