chore: import upstream snapshot with attribution
cffconvert / validate (push) Has been skipped
License Check / license-check (push) Failing after 2s

This commit is contained in:
wehub-resource-sync
2026-07-13 12:14:16 +08:00
commit 8a852e4b4e
36502 changed files with 9277225 additions and 0 deletions
@@ -0,0 +1,79 @@
load("@xla//third_party/rules_python/python:py_binary.bzl", "py_binary")
load("//tensorflow:tensorflow.bzl", "if_oss")
load("//tensorflow:tensorflow.default.bzl", "filegroup")
load("//tensorflow/compiler/mlir:glob_lit_test.bzl", "glob_lit_tests")
# copybara:uncomment package(default_applicable_licenses = ["//tensorflow:LICENSE"])
licenses(["notice"])
glob_lit_tests(
name = "all_tests",
data = [
":debug_info_files",
":test_utilities",
],
driver = "@llvm-project//mlir:run_lit.sh",
test_file_exts = [
"pbtxt",
# "py", TODO(b/150304798)
],
)
# Bundle together all the debug info files that are used by the tests.
filegroup(
name = "debug_info_files",
srcs = glob(
["**/*.debug"],
),
)
# Bundle together all of the test utilities that are used by tests.
filegroup(
name = "test_utilities",
testonly = True,
data = [
":concrete_function_error",
":saved_model_error",
"//tensorflow/compiler/mlir/lite:flatbuffer_to_string",
"//tensorflow/compiler/mlir/lite:tf_tfl_translate",
"@llvm-project//llvm:FileCheck",
"@llvm-project//llvm:not",
],
)
py_binary(
name = "saved_model_error",
srcs = ["saved_model_error.py"],
exec_properties = if_oss(
None,
select({
"@bazel_tools//tools/cpp:asan_build": {"cpp_link.mem": "20g"},
"//conditions:default": None,
}),
),
main = "saved_model_error.py",
strict_deps = True,
deps = [
"//tensorflow:tensorflow_py",
"@absl_py//absl:app",
],
)
py_binary(
name = "concrete_function_error",
srcs = ["concrete_function_error.py"],
exec_properties = if_oss(
None,
select({
"@bazel_tools//tools/cpp:asan_build": {"cpp_link.mem": "20g"},
"//conditions:default": None,
}),
),
main = "concrete_function_error.py",
strict_deps = True,
deps = [
"//tensorflow:tensorflow_py",
"@absl_py//absl:app",
],
)
@@ -0,0 +1,72 @@
# Copyright 2019 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.
# ==============================================================================
"""Test file to display the error message and verify it with FileCheck."""
# RUN: %p/concrete_function_error | FileCheck %s
import sys
from absl import app
import tensorflow.compat.v2 as tf
if hasattr(tf, 'enable_v2_behavior'):
tf.enable_v2_behavior()
class TestGraphDebugInfo(object):
"""Test stack trace can be displayed."""
def testConcreteFunctionDebugInfo(self):
"""Create a concrete func with unsupported ops, and convert it."""
@tf.function(
input_signature=[tf.TensorSpec(shape=[3, 3], dtype=tf.float32)])
def model(x):
y = tf.math.betainc(x, 0.5, 1.0) # Not supported
return y + y
func = model.get_concrete_function()
converter = tf.lite.TFLiteConverter.from_concrete_functions([func], model)
converter.convert()
# pylint: disable=line-too-long
# CHECK-LABEL: testConcreteFunctionDebugInfo
# CHECK: error: 'tf.Betainc' op is neither a custom op nor a flex op
# CHECK: attrs=attr_protos, op_def=op_def)
# CHECK: ^
# CHECK: {{.*tensorflow/python/ops/gen_math_ops.py:[0-9]+:[0-9]+: note: called from}}
# CHECK: "Betainc", a=a, b=b, x=x, name=name)
# CHECK: ^
# CHECK: {{.*tensorflow/compiler/mlir/lite/tests/debuginfo/concrete_function_error.py:[0-9]+:[0-9]+: note: called from}}
# CHECK: y = tf.math.betainc(x, 0.5, 1.0) # Not supported
# CHECK: ^
# CHECK: <unknown>:0: error: failed while converting: 'main'
# pylint: enable=line-too-long
def main(argv):
if len(argv) > 1:
raise app.UsageError('Too many command-line arguments.')
try:
TestGraphDebugInfo().testConcreteFunctionDebugInfo()
except Exception as e: # pylint: disable=broad-except
sys.stdout.write('testConcreteFunctionDebugInfo')
sys.stdout.write(str(e))
if __name__ == '__main__':
app.run(main)
@@ -0,0 +1,82 @@
# Copyright 2019 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.
# ==============================================================================
"""Test file to display the error message and verify it with FileCheck."""
# RUN: %p/saved_model_error | FileCheck %s
import sys
from absl import app
import tensorflow.compat.v2 as tf
if hasattr(tf, 'enable_v2_behavior'):
tf.enable_v2_behavior()
class TestModule(tf.Module):
"""The test model has unsupported op."""
@tf.function(input_signature=[tf.TensorSpec(shape=[3, 3], dtype=tf.float32)])
def model(self, x):
y = tf.math.betainc(x, 0.5, 1.0) # Not supported
return y + y
class TestGraphDebugInfo(object):
"""Test stack trace can be displayed."""
def testSavedModelDebugInfo(self):
"""Save a saved model with unsupported ops, and then load and convert it."""
# saved the model
test_model = TestModule()
saved_model_path = '/tmp/test.saved_model'
save_options = tf.saved_model.SaveOptions(save_debug_info=True)
tf.saved_model.save(test_model, saved_model_path, options=save_options)
# load the model and convert
converter = tf.lite.TFLiteConverter.from_saved_model(saved_model_path)
converter.convert()
# pylint: disable=line-too-long
# CHECK-LABEL: testSavedModelDebugInfo
# CHECK: error: 'tf.Betainc' op is neither a custom op nor a flex op
# CHECK: attrs=attr_protos, op_def=op_def)
# CHECK: ^
# CHECK: {{.*tensorflow/python/ops/gen_math_ops.py:[0-9]+:[0-9]+: note: called from}}
# CHECK: "Betainc", a=a, b=b, x=x, name=name)
# CHECK: ^
# CHECK: {{.*tensorflow/compiler/mlir/lite/tests/debuginfo/saved_model_error.py:[0-9]+:[0-9]+: note: called from}}
# CHECK: y = tf.math.betainc(x, 0.5, 1.0) # Not supported
# CHECK: ^
# CHECK: <unknown>:0: error: failed while converting: 'main'
# pylint: enable=line-too-long
def main(argv):
"""test driver method writes the error message to stdout."""
if len(argv) > 1:
raise app.UsageError('Too many command-line arguments.')
try:
TestGraphDebugInfo().testSavedModelDebugInfo()
except Exception as e: # pylint: disable=broad-except
sys.stdout.write('testSavedModelDebugInfo')
sys.stdout.write(str(e))
if __name__ == '__main__':
app.run(main)
File diff suppressed because one or more lines are too long
@@ -0,0 +1,175 @@
files: "fake/user/code/file_A.py"
files: "fake/user/code/file_B.py"
files: "fake/user/code/file_C.py"
files: "fake/user/code/file_D.py"
files: "fake/user/code/file_E.py"
files: "fake/user/code/file_F.py"
files: "fake/user/code/file_G.py"
files: "fake/user/code/file_H.py"
files: "fake/user/code/file_I.py"
files: "fake/user/code/file_J.py"
files: "fake/user/code/file_K.py"
files: "fake/user/code/file_L.py"
files: "fake/user/code/file_M.py"
files: "fake/user/code/file_N.py"
files: "fake/user/code/file_O.py"
files: "fake/user/code/file_P.py"
files: "fake/user/code/file_Q.py"
files: "fake/user/code/file_R.py"
files: "fake/user/code/file_S.py"
files: "fake/user/code/file_T.py"
files: "fake/user/code/file_U.py"
files: "fake/user/code/file_V.py"
files: "fake/user/code/file_W.py"
files: "fake/user/code/file_X.py"
files: "fake/user/code/file_Y.py"
files: "fake/user/code/file_Z.py"
files: "fake/user/code/file_1.py"
files: "fake/user/code/file_2.py"
files: "fake/user/code/file_3.py"
files: "fake/user/code/file_4.py"
files: "fake/user/code/file_5.py"
files: "fake/user/code/file_6.py"
files: "fake/user/code/file_a.py"
files: "fake/user/code/file_b.py"
files: "fake/user/code/file_c.py"
files: "fake/user/code/file_d.py"
files: "fake/user/code/file_e.py"
files: "fake/user/code/file_f.py"
files: "fake/user/code/file_g.py"
files: "fake/user/code/file_h.py"
files: "fake/user/code/file_i.py"
files: "fake/user/code/file_j.py"
files: "fake/user/code/file_k.py"
files: "fake/user/code/file_l.py"
files: "fake/user/code/file_m.py"
files: "fake/user/code/file_n.py"
files: "fake/user/code/file_o.py"
files: "fake/user/code/file_p.py"
files: "fake/user/code/file_q.py"
files: "fake/user/code/file_r.py"
files: "fake/user/code/file_s.py"
files: "fake/user/code/file_t.py"
files: "fake/user/code/file_u.py"
files: "fake/user/code/file_v.py"
files: "fake/user/code/file_w.py"
files: "fake/user/code/file_x.py"
files: "fake/user/code/file_y.py"
files: "fake/user/code/file_z.py"
traces {
key: "MobilenetV1/Conv2d_0/BatchNorm/beta@"
value {
file_line_cols {
file_index: 33
line: 383
}
}
}
traces {
key: "MobilenetV1/Conv2d_0/BatchNorm/beta/read@"
value {
file_line_cols {
file_index: 49
line: 886
}
}
}
traces {
key: "MobilenetV1/Conv2d_0/BatchNorm/gamma@"
value {
file_line_cols {
file_index: 38
line: 777
}
}
}
traces {
key: "MobilenetV1/Conv2d_0/BatchNorm/gamma/read@"
value {
file_line_cols {
file_index: 49
line: 915
}
}
}
traces {
key: "MobilenetV1/Conv2d_0/BatchNorm/moving_mean@"
value {
file_line_cols {
file_index: 44
line: 793
}
}
}
traces {
key: "MobilenetV1/Conv2d_0/BatchNorm/moving_mean/read@"
value {
file_line_cols {
file_index: 49
line: 335
}
}
}
traces {
key: "MobilenetV1/Conv2d_0/BatchNorm/moving_variance@"
value {
file_line_cols {
file_index: 44
line: 386
}
}
}
traces {
key: "MobilenetV1/Conv2d_0/BatchNorm/moving_variance/read@"
value {
file_line_cols {
file_index: 49
line: 492
}
}
}
traces {
key: "MobilenetV1/Conv2d_0/weights@"
value {
file_line_cols {
file_index: 54
line: 649
}
}
}
traces {
key: "MobilenetV1/Conv2d_0/weights/read@"
value {
file_line_cols {
file_index: 49
line: 421
}
}
}
traces {
key: "MobilenetV1/MobilenetV1/Conv2d_0/BatchNorm/FusedBatchNorm@"
value {
file_line_cols {
file_index: 5
line: 362
}
}
}
traces {
key: "MobilenetV1/MobilenetV1/Conv2d_0/Conv2D@"
value {
file_line_cols {
file_index: 2
line: 27
}
}
}
traces {
key: "input@"
value {
file_line_cols {
file_index: 40
line: 690
}
}
}
File diff suppressed because one or more lines are too long
@@ -0,0 +1,187 @@
files: "fake/user/code/file_A.py"
files: "fake/user/code/file_B.py"
files: "fake/user/code/file_C.py"
files: "fake/user/code/file_D.py"
files: "fake/user/code/file_E.py"
files: "fake/user/code/file_F.py"
files: "fake/user/code/file_G.py"
files: "fake/user/code/file_H.py"
files: "fake/user/code/file_I.py"
files: "fake/user/code/file_J.py"
files: "fake/user/code/file_K.py"
files: "fake/user/code/file_L.py"
files: "fake/user/code/file_M.py"
files: "fake/user/code/file_N.py"
files: "fake/user/code/file_O.py"
files: "fake/user/code/file_P.py"
files: "fake/user/code/file_Q.py"
files: "fake/user/code/file_R.py"
files: "fake/user/code/file_S.py"
files: "fake/user/code/file_T.py"
files: "fake/user/code/file_U.py"
files: "fake/user/code/file_V.py"
files: "fake/user/code/file_W.py"
files: "fake/user/code/file_X.py"
files: "fake/user/code/file_Y.py"
files: "fake/user/code/file_Z.py"
files: "fake/user/code/file_1.py"
files: "fake/user/code/file_2.py"
files: "fake/user/code/file_3.py"
files: "fake/user/code/file_4.py"
files: "fake/user/code/file_5.py"
files: "fake/user/code/file_6.py"
files: "fake/user/code/file_a.py"
files: "fake/user/code/file_b.py"
files: "fake/user/code/file_c.py"
files: "fake/user/code/file_d.py"
files: "fake/user/code/file_e.py"
files: "fake/user/code/file_f.py"
files: "fake/user/code/file_g.py"
files: "fake/user/code/file_h.py"
files: "fake/user/code/file_i.py"
files: "fake/user/code/file_j.py"
files: "fake/user/code/file_k.py"
files: "fake/user/code/file_l.py"
files: "fake/user/code/file_m.py"
files: "fake/user/code/file_n.py"
files: "fake/user/code/file_o.py"
files: "fake/user/code/file_p.py"
files: "fake/user/code/file_q.py"
files: "fake/user/code/file_r.py"
files: "fake/user/code/file_s.py"
files: "fake/user/code/file_t.py"
files: "fake/user/code/file_u.py"
files: "fake/user/code/file_v.py"
files: "fake/user/code/file_w.py"
files: "fake/user/code/file_x.py"
files: "fake/user/code/file_y.py"
files: "fake/user/code/file_z.py"
traces {
key: "MobilenetV1/Conv2d_0/BatchNorm/beta@"
value {
file_line_cols {
file_index: 33
line: 383
}
}
}
traces {
key: "MobilenetV1/Conv2d_0/BatchNorm/beta/read@"
value {
file_line_cols {
file_index: 49
line: 886
}
}
}
traces {
key: "MobilenetV1/Conv2d_0/BatchNorm/gamma@"
value {
file_line_cols {
file_index: 38
line: 777
}
}
}
traces {
key: "MobilenetV1/Conv2d_0/BatchNorm/gamma/read@"
value {
file_line_cols {
file_index: 49
line: 915
}
}
}
traces {
key: "MobilenetV1/Conv2d_0/BatchNorm/moving_mean@"
value {
file_line_cols {
file_index: 44
line: 793
}
}
}
traces {
key: "MobilenetV1/Conv2d_0/BatchNorm/moving_mean/read@"
value {
file_line_cols {
file_index: 49
line: 335
}
}
}
traces {
key: "MobilenetV1/Conv2d_0/BatchNorm/moving_variance@"
value {
file_line_cols {
file_index: 44
line: 386
}
}
}
traces {
key: "MobilenetV1/Conv2d_0/BatchNorm/moving_variance/read@"
value {
file_line_cols {
file_index: 49
line: 492
}
}
}
traces {
key: "MobilenetV1/Conv2d_0/weights@"
value {
file_line_cols {
file_index: 54
line: 649
}
}
}
traces {
key: "MobilenetV1/Conv2d_0/weights/read@"
value {
file_line_cols {
file_index: 49
line: 421
}
}
}
traces {
key: "MobilenetV1/MobilenetV1/Conv2d_0/BatchNorm/FusedBatchNorm@"
value {
file_line_cols {
file_index: 5
line: 362
}
}
}
traces {
key: "MobilenetV1/MobilenetV1/Conv2d_0/Conv2D@"
value {
file_line_cols {
file_index: 2
line: 27
}
file_line_cols {
file_index: 3
line: 28
}
file_line_cols {
file_index: 4
line: 29
}
file_line_cols {
file_index: 5
line: 30
}
}
}
traces {
key: "input@"
value {
file_line_cols {
file_index: 40
line: 690
}
}
}