# Copyright 2017 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. # ============================================================================== """Make HTML tables that report where TF and TOCO failed to convert models. This is primarily used by generate_examples.py. See it or `make_report_table` for more details on usage. """ from __future__ import absolute_import from __future__ import division from __future__ import print_function import cgi import json FAILED = "FAILED" SUCCESS = "SUCCESS" NOTRUN = "NOTRUN" def make_report_table(fp, title, reports): """Make an HTML report of the success/failure reports. Args: fp: File-like object in which to put the html. title: "Title of the zip file this pertains to." reports: a list of conversion attempts. (report_args, report_vals) i.e. ({"shape": [1,2,3], "type": "tf.float32"}, {"tf": "SUCCESS", "toco": "FAILURE", "toco_log": "Unsupported type.", "tf_log": ""}) """ # sort reports by if TOCO failure and then TF failure (reversed) reports.sort(key=lambda x: x[1]["toco"], reverse=False) reports.sort(key=lambda x: x[1]["tf"], reverse=True) def result_cell(x, row, col): """Produce a cell with the condition string `x`.""" s = cgi.escape(repr(x), quote=True) color = "#44ff44" if x == SUCCESS else ( "#ff4444" if x == FAILED else "#eeeeee") handler = "ShowLog(%d, %d)" % (row, col) fp.write("
\n")
fp.write(" \n")
fp.write(" \n")
fp.write("
| \n")
fp.write("