diff options
author | Martin Wicke <wicke@google.com> | 2017-03-23 12:31:16 -0800 |
---|---|---|
committer | TensorFlower Gardener <gardener@tensorflow.org> | 2017-03-23 13:44:29 -0700 |
commit | bc456e361d49d1d89a74b80060c70efb51fd7d87 (patch) | |
tree | 825e04287f1e2d2ac098ca3f0fdd4e361aefd68c /tensorflow/tools/compatibility | |
parent | 8ca071456537e6c96ae8896c2a20b1f08b0e59d3 (diff) |
Merge changes from github.
Change: 151046259
Diffstat (limited to 'tensorflow/tools/compatibility')
-rw-r--r-- | tensorflow/tools/compatibility/README.md | 3 | ||||
-rw-r--r-- | tensorflow/tools/compatibility/tf_upgrade.py | 25 |
2 files changed, 26 insertions, 2 deletions
diff --git a/tensorflow/tools/compatibility/README.md b/tensorflow/tools/compatibility/README.md index 9dba070a4f..aabc7b253d 100644 --- a/tensorflow/tools/compatibility/README.md +++ b/tensorflow/tools/compatibility/README.md @@ -11,7 +11,10 @@ It will print a list of errors it finds that it can't fix. You can also run it on a directory tree: ``` +# just upgrade the .py files tf_upgrade.py --intree coolcode --outtree coolcode-upgraded +# after upgrade the .py files, then copy all the other files to the outtree +tf_upgrade.py --intree coolcode --outtree coolcode-upgraded --copyotherfiles True ``` In either case, it will also dump out a report e.g. which will detail changes diff --git a/tensorflow/tools/compatibility/tf_upgrade.py b/tensorflow/tools/compatibility/tf_upgrade.py index 26bf117256..80439f835a 100644 --- a/tensorflow/tools/compatibility/tf_upgrade.py +++ b/tensorflow/tools/compatibility/tf_upgrade.py @@ -140,6 +140,7 @@ class APIChangeSpec(object): "tf.batch_svd": "tf.svd", "tf.batch_fft": "tf.fft", "tf.batch_ifft": "tf.ifft", + "tf.batch_fft2d": "tf.fft2d", "tf.batch_ifft2d": "tf.ifft2d", "tf.batch_fft3d": "tf.fft3d", "tf.batch_ifft3d": "tf.ifft3d", @@ -566,7 +567,7 @@ class TensorFlowCodeUpgrader(object): return 1, text, process_errors # pylint: enable=broad-except - def process_tree(self, root_directory, output_root_directory): + def process_tree(self, root_directory, output_root_directory, copy_other_files): """Processes upgrades on an entire tree of python files in place. Note that only Python files. If you have custom code in other languages, @@ -596,13 +597,21 @@ class TensorFlowCodeUpgrader(object): # Collect list of files to process (we do this to correctly handle if the # user puts the output directory in some sub directory of the input dir) files_to_process = [] + files_to_copy = [] for dir_name, _, file_list in os.walk(root_directory): py_files = [f for f in file_list if f.endswith(".py")] + copy_files = [f for f in file_list if not f.endswith(".py")] for filename in py_files: fullpath = os.path.join(dir_name, filename) fullpath_output = os.path.join( output_root_directory, os.path.relpath(fullpath, root_directory)) files_to_process.append((fullpath, fullpath_output)) + if copy_other_files: + for filename in copy_files: + fullpath = os.path.join(dir_name, filename) + fullpath_output = os.path.join( + output_root_directory, os.path.relpath(fullpath, root_directory)) + files_to_copy.append((fullpath, fullpath_output)) file_count = 0 tree_errors = [] @@ -619,6 +628,11 @@ class TensorFlowCodeUpgrader(object): _, l_report, l_errors = self.process_file(input_path, output_path) tree_errors += l_errors report += l_report + for input_path, output_path in files_to_copy: + output_directory = os.path.dirname(output_path) + if not os.path.isdir(output_directory): + os.makedirs(output_directory) + shutil.copy(input_path, output_path) return file_count, report, tree_errors @@ -651,6 +665,13 @@ Simple usage: help="If converting a whole tree of files, the output " "directory (relative or absolute).") parser.add_argument( + "--copyotherfiles", + dest="copy_other_files", + help=("If converting a whole tree of files, whether to " + "copy the other files."), + type=bool, + default=False) + parser.add_argument( "--reportfile", dest="report_filename", help=("The name of the file where the report log is " @@ -669,7 +690,7 @@ Simple usage: files_processed = 1 elif args.input_tree: files_processed, report_text, errors = upgrade.process_tree( - args.input_tree, args.output_tree) + args.input_tree, args.output_tree, args.copy_other_files) else: parser.print_help() if report_text: |