1# Copyright 2020 The TensorFlow Authors. All Rights Reserved. 2# 3# Licensed under the Apache License, Version 2.0 (the "License"); 4# you may not use this file except in compliance with the License. 5# You may obtain a copy of the License at 6# 7# http://www.apache.org/licenses/LICENSE-2.0 8# 9# Unless required by applicable law or agreed to in writing, software 10# distributed under the License is distributed on an "AS IS" BASIS, 11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12# See the License for the specific language governing permissions and 13# limitations under the License. 14r"""Script to generate inputs/outputs exclusion lists for GradientTape. 15 16To use this script: 17 18bazel run tensorflow/python/eager:gen_gradient_input_output_exclusions -- \ 19 $PWD/tensorflow/python/eager/pywrap_gradient_exclusions.cc 20""" 21 22import argparse 23 24from tensorflow.python.eager import gradient_input_output_exclusions 25 26 27def main(output_file): 28 with open(output_file, "w") as fp: 29 fp.write(gradient_input_output_exclusions.get_contents()) 30 31 32if __name__ == "__main__": 33 arg_parser = argparse.ArgumentParser() 34 arg_parser.add_argument("output", metavar="O", type=str, help="Output file.") 35 args = arg_parser.parse_args() 36 main(args.output) 37