tensorbored 2.21.0rc1769983804__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- tensorbored/__init__.py +112 -0
- tensorbored/_vendor/__init__.py +0 -0
- tensorbored/_vendor/bleach/__init__.py +125 -0
- tensorbored/_vendor/bleach/_vendor/__init__.py +0 -0
- tensorbored/_vendor/bleach/_vendor/html5lib/__init__.py +35 -0
- tensorbored/_vendor/bleach/_vendor/html5lib/_ihatexml.py +289 -0
- tensorbored/_vendor/bleach/_vendor/html5lib/_inputstream.py +918 -0
- tensorbored/_vendor/bleach/_vendor/html5lib/_tokenizer.py +1735 -0
- tensorbored/_vendor/bleach/_vendor/html5lib/_trie/__init__.py +5 -0
- tensorbored/_vendor/bleach/_vendor/html5lib/_trie/_base.py +40 -0
- tensorbored/_vendor/bleach/_vendor/html5lib/_trie/py.py +67 -0
- tensorbored/_vendor/bleach/_vendor/html5lib/_utils.py +159 -0
- tensorbored/_vendor/bleach/_vendor/html5lib/constants.py +2946 -0
- tensorbored/_vendor/bleach/_vendor/html5lib/filters/__init__.py +0 -0
- tensorbored/_vendor/bleach/_vendor/html5lib/filters/alphabeticalattributes.py +29 -0
- tensorbored/_vendor/bleach/_vendor/html5lib/filters/base.py +12 -0
- tensorbored/_vendor/bleach/_vendor/html5lib/filters/inject_meta_charset.py +73 -0
- tensorbored/_vendor/bleach/_vendor/html5lib/filters/lint.py +93 -0
- tensorbored/_vendor/bleach/_vendor/html5lib/filters/optionaltags.py +207 -0
- tensorbored/_vendor/bleach/_vendor/html5lib/filters/sanitizer.py +916 -0
- tensorbored/_vendor/bleach/_vendor/html5lib/filters/whitespace.py +38 -0
- tensorbored/_vendor/bleach/_vendor/html5lib/html5parser.py +2795 -0
- tensorbored/_vendor/bleach/_vendor/html5lib/serializer.py +409 -0
- tensorbored/_vendor/bleach/_vendor/html5lib/treeadapters/__init__.py +30 -0
- tensorbored/_vendor/bleach/_vendor/html5lib/treeadapters/genshi.py +54 -0
- tensorbored/_vendor/bleach/_vendor/html5lib/treeadapters/sax.py +50 -0
- tensorbored/_vendor/bleach/_vendor/html5lib/treebuilders/__init__.py +88 -0
- tensorbored/_vendor/bleach/_vendor/html5lib/treebuilders/base.py +417 -0
- tensorbored/_vendor/bleach/_vendor/html5lib/treebuilders/dom.py +239 -0
- tensorbored/_vendor/bleach/_vendor/html5lib/treebuilders/etree.py +343 -0
- tensorbored/_vendor/bleach/_vendor/html5lib/treebuilders/etree_lxml.py +392 -0
- tensorbored/_vendor/bleach/_vendor/html5lib/treewalkers/__init__.py +154 -0
- tensorbored/_vendor/bleach/_vendor/html5lib/treewalkers/base.py +252 -0
- tensorbored/_vendor/bleach/_vendor/html5lib/treewalkers/dom.py +43 -0
- tensorbored/_vendor/bleach/_vendor/html5lib/treewalkers/etree.py +131 -0
- tensorbored/_vendor/bleach/_vendor/html5lib/treewalkers/etree_lxml.py +215 -0
- tensorbored/_vendor/bleach/_vendor/html5lib/treewalkers/genshi.py +69 -0
- tensorbored/_vendor/bleach/_vendor/parse.py +1078 -0
- tensorbored/_vendor/bleach/callbacks.py +32 -0
- tensorbored/_vendor/bleach/html5lib_shim.py +757 -0
- tensorbored/_vendor/bleach/linkifier.py +633 -0
- tensorbored/_vendor/bleach/parse_shim.py +1 -0
- tensorbored/_vendor/bleach/sanitizer.py +638 -0
- tensorbored/_vendor/bleach/six_shim.py +19 -0
- tensorbored/_vendor/webencodings/__init__.py +342 -0
- tensorbored/_vendor/webencodings/labels.py +231 -0
- tensorbored/_vendor/webencodings/mklabels.py +59 -0
- tensorbored/_vendor/webencodings/x_user_defined.py +325 -0
- tensorbored/assets.py +36 -0
- tensorbored/auth.py +102 -0
- tensorbored/backend/__init__.py +0 -0
- tensorbored/backend/application.py +604 -0
- tensorbored/backend/auth_context_middleware.py +38 -0
- tensorbored/backend/client_feature_flags.py +113 -0
- tensorbored/backend/empty_path_redirect.py +46 -0
- tensorbored/backend/event_processing/__init__.py +0 -0
- tensorbored/backend/event_processing/data_ingester.py +276 -0
- tensorbored/backend/event_processing/data_provider.py +535 -0
- tensorbored/backend/event_processing/directory_loader.py +142 -0
- tensorbored/backend/event_processing/directory_watcher.py +272 -0
- tensorbored/backend/event_processing/event_accumulator.py +950 -0
- tensorbored/backend/event_processing/event_file_inspector.py +463 -0
- tensorbored/backend/event_processing/event_file_loader.py +292 -0
- tensorbored/backend/event_processing/event_multiplexer.py +521 -0
- tensorbored/backend/event_processing/event_util.py +68 -0
- tensorbored/backend/event_processing/io_wrapper.py +223 -0
- tensorbored/backend/event_processing/plugin_asset_util.py +104 -0
- tensorbored/backend/event_processing/plugin_event_accumulator.py +721 -0
- tensorbored/backend/event_processing/plugin_event_multiplexer.py +522 -0
- tensorbored/backend/event_processing/reservoir.py +266 -0
- tensorbored/backend/event_processing/tag_types.py +29 -0
- tensorbored/backend/experiment_id.py +71 -0
- tensorbored/backend/experimental_plugin.py +51 -0
- tensorbored/backend/http_util.py +263 -0
- tensorbored/backend/json_util.py +70 -0
- tensorbored/backend/path_prefix.py +67 -0
- tensorbored/backend/process_graph.py +74 -0
- tensorbored/backend/security_validator.py +202 -0
- tensorbored/compat/__init__.py +69 -0
- tensorbored/compat/proto/__init__.py +0 -0
- tensorbored/compat/proto/allocation_description_pb2.py +35 -0
- tensorbored/compat/proto/api_def_pb2.py +82 -0
- tensorbored/compat/proto/attr_value_pb2.py +80 -0
- tensorbored/compat/proto/cluster_pb2.py +58 -0
- tensorbored/compat/proto/config_pb2.py +271 -0
- tensorbored/compat/proto/coordination_config_pb2.py +45 -0
- tensorbored/compat/proto/cost_graph_pb2.py +87 -0
- tensorbored/compat/proto/cpp_shape_inference_pb2.py +70 -0
- tensorbored/compat/proto/debug_pb2.py +65 -0
- tensorbored/compat/proto/event_pb2.py +149 -0
- tensorbored/compat/proto/full_type_pb2.py +74 -0
- tensorbored/compat/proto/function_pb2.py +157 -0
- tensorbored/compat/proto/graph_debug_info_pb2.py +111 -0
- tensorbored/compat/proto/graph_pb2.py +41 -0
- tensorbored/compat/proto/histogram_pb2.py +39 -0
- tensorbored/compat/proto/meta_graph_pb2.py +254 -0
- tensorbored/compat/proto/node_def_pb2.py +61 -0
- tensorbored/compat/proto/op_def_pb2.py +81 -0
- tensorbored/compat/proto/resource_handle_pb2.py +48 -0
- tensorbored/compat/proto/rewriter_config_pb2.py +93 -0
- tensorbored/compat/proto/rpc_options_pb2.py +35 -0
- tensorbored/compat/proto/saved_object_graph_pb2.py +193 -0
- tensorbored/compat/proto/saver_pb2.py +38 -0
- tensorbored/compat/proto/step_stats_pb2.py +116 -0
- tensorbored/compat/proto/struct_pb2.py +144 -0
- tensorbored/compat/proto/summary_pb2.py +111 -0
- tensorbored/compat/proto/tensor_description_pb2.py +38 -0
- tensorbored/compat/proto/tensor_pb2.py +68 -0
- tensorbored/compat/proto/tensor_shape_pb2.py +46 -0
- tensorbored/compat/proto/tfprof_log_pb2.py +307 -0
- tensorbored/compat/proto/trackable_object_graph_pb2.py +90 -0
- tensorbored/compat/proto/types_pb2.py +105 -0
- tensorbored/compat/proto/variable_pb2.py +62 -0
- tensorbored/compat/proto/verifier_config_pb2.py +38 -0
- tensorbored/compat/proto/versions_pb2.py +35 -0
- tensorbored/compat/tensorflow_stub/__init__.py +38 -0
- tensorbored/compat/tensorflow_stub/app.py +124 -0
- tensorbored/compat/tensorflow_stub/compat/__init__.py +131 -0
- tensorbored/compat/tensorflow_stub/compat/v1/__init__.py +20 -0
- tensorbored/compat/tensorflow_stub/dtypes.py +692 -0
- tensorbored/compat/tensorflow_stub/error_codes.py +169 -0
- tensorbored/compat/tensorflow_stub/errors.py +507 -0
- tensorbored/compat/tensorflow_stub/flags.py +124 -0
- tensorbored/compat/tensorflow_stub/io/__init__.py +17 -0
- tensorbored/compat/tensorflow_stub/io/gfile.py +1011 -0
- tensorbored/compat/tensorflow_stub/pywrap_tensorflow.py +285 -0
- tensorbored/compat/tensorflow_stub/tensor_shape.py +1035 -0
- tensorbored/context.py +129 -0
- tensorbored/data/__init__.py +0 -0
- tensorbored/data/grpc_provider.py +365 -0
- tensorbored/data/ingester.py +46 -0
- tensorbored/data/proto/__init__.py +0 -0
- tensorbored/data/proto/data_provider_pb2.py +517 -0
- tensorbored/data/proto/data_provider_pb2_grpc.py +374 -0
- tensorbored/data/provider.py +1365 -0
- tensorbored/data/server_ingester.py +301 -0
- tensorbored/data_compat.py +159 -0
- tensorbored/dataclass_compat.py +224 -0
- tensorbored/default.py +124 -0
- tensorbored/errors.py +130 -0
- tensorbored/lazy.py +99 -0
- tensorbored/main.py +48 -0
- tensorbored/main_lib.py +62 -0
- tensorbored/manager.py +487 -0
- tensorbored/notebook.py +441 -0
- tensorbored/plugin_util.py +266 -0
- tensorbored/plugins/__init__.py +0 -0
- tensorbored/plugins/audio/__init__.py +0 -0
- tensorbored/plugins/audio/audio_plugin.py +229 -0
- tensorbored/plugins/audio/metadata.py +69 -0
- tensorbored/plugins/audio/plugin_data_pb2.py +37 -0
- tensorbored/plugins/audio/summary.py +230 -0
- tensorbored/plugins/audio/summary_v2.py +124 -0
- tensorbored/plugins/base_plugin.py +367 -0
- tensorbored/plugins/core/__init__.py +0 -0
- tensorbored/plugins/core/core_plugin.py +981 -0
- tensorbored/plugins/custom_scalar/__init__.py +0 -0
- tensorbored/plugins/custom_scalar/custom_scalars_plugin.py +320 -0
- tensorbored/plugins/custom_scalar/layout_pb2.py +85 -0
- tensorbored/plugins/custom_scalar/metadata.py +35 -0
- tensorbored/plugins/custom_scalar/summary.py +79 -0
- tensorbored/plugins/debugger_v2/__init__.py +0 -0
- tensorbored/plugins/debugger_v2/debug_data_multiplexer.py +631 -0
- tensorbored/plugins/debugger_v2/debug_data_provider.py +634 -0
- tensorbored/plugins/debugger_v2/debugger_v2_plugin.py +504 -0
- tensorbored/plugins/distribution/__init__.py +0 -0
- tensorbored/plugins/distribution/compressor.py +158 -0
- tensorbored/plugins/distribution/distributions_plugin.py +116 -0
- tensorbored/plugins/distribution/metadata.py +19 -0
- tensorbored/plugins/graph/__init__.py +0 -0
- tensorbored/plugins/graph/graph_util.py +129 -0
- tensorbored/plugins/graph/graphs_plugin.py +336 -0
- tensorbored/plugins/graph/keras_util.py +328 -0
- tensorbored/plugins/graph/metadata.py +42 -0
- tensorbored/plugins/histogram/__init__.py +0 -0
- tensorbored/plugins/histogram/histograms_plugin.py +144 -0
- tensorbored/plugins/histogram/metadata.py +63 -0
- tensorbored/plugins/histogram/plugin_data_pb2.py +34 -0
- tensorbored/plugins/histogram/summary.py +234 -0
- tensorbored/plugins/histogram/summary_v2.py +292 -0
- tensorbored/plugins/hparams/__init__.py +14 -0
- tensorbored/plugins/hparams/_keras.py +93 -0
- tensorbored/plugins/hparams/api.py +130 -0
- tensorbored/plugins/hparams/api_pb2.py +208 -0
- tensorbored/plugins/hparams/backend_context.py +606 -0
- tensorbored/plugins/hparams/download_data.py +158 -0
- tensorbored/plugins/hparams/error.py +26 -0
- tensorbored/plugins/hparams/get_experiment.py +71 -0
- tensorbored/plugins/hparams/hparams_plugin.py +206 -0
- tensorbored/plugins/hparams/hparams_util_pb2.py +69 -0
- tensorbored/plugins/hparams/json_format_compat.py +38 -0
- tensorbored/plugins/hparams/list_metric_evals.py +57 -0
- tensorbored/plugins/hparams/list_session_groups.py +1040 -0
- tensorbored/plugins/hparams/metadata.py +125 -0
- tensorbored/plugins/hparams/metrics.py +41 -0
- tensorbored/plugins/hparams/plugin_data_pb2.py +69 -0
- tensorbored/plugins/hparams/summary.py +205 -0
- tensorbored/plugins/hparams/summary_v2.py +597 -0
- tensorbored/plugins/image/__init__.py +0 -0
- tensorbored/plugins/image/images_plugin.py +232 -0
- tensorbored/plugins/image/metadata.py +65 -0
- tensorbored/plugins/image/plugin_data_pb2.py +34 -0
- tensorbored/plugins/image/summary.py +159 -0
- tensorbored/plugins/image/summary_v2.py +130 -0
- tensorbored/plugins/mesh/__init__.py +14 -0
- tensorbored/plugins/mesh/mesh_plugin.py +292 -0
- tensorbored/plugins/mesh/metadata.py +152 -0
- tensorbored/plugins/mesh/plugin_data_pb2.py +37 -0
- tensorbored/plugins/mesh/summary.py +251 -0
- tensorbored/plugins/mesh/summary_v2.py +214 -0
- tensorbored/plugins/metrics/__init__.py +0 -0
- tensorbored/plugins/metrics/metadata.py +17 -0
- tensorbored/plugins/metrics/metrics_plugin.py +623 -0
- tensorbored/plugins/pr_curve/__init__.py +0 -0
- tensorbored/plugins/pr_curve/metadata.py +75 -0
- tensorbored/plugins/pr_curve/plugin_data_pb2.py +34 -0
- tensorbored/plugins/pr_curve/pr_curves_plugin.py +241 -0
- tensorbored/plugins/pr_curve/summary.py +574 -0
- tensorbored/plugins/profile_redirect/__init__.py +0 -0
- tensorbored/plugins/profile_redirect/profile_redirect_plugin.py +49 -0
- tensorbored/plugins/projector/__init__.py +67 -0
- tensorbored/plugins/projector/metadata.py +26 -0
- tensorbored/plugins/projector/projector_config_pb2.py +54 -0
- tensorbored/plugins/projector/projector_plugin.py +795 -0
- tensorbored/plugins/projector/tf_projector_plugin/index.js +32 -0
- tensorbored/plugins/projector/tf_projector_plugin/projector_binary.html +524 -0
- tensorbored/plugins/projector/tf_projector_plugin/projector_binary.js +15536 -0
- tensorbored/plugins/scalar/__init__.py +0 -0
- tensorbored/plugins/scalar/metadata.py +60 -0
- tensorbored/plugins/scalar/plugin_data_pb2.py +34 -0
- tensorbored/plugins/scalar/scalars_plugin.py +181 -0
- tensorbored/plugins/scalar/summary.py +109 -0
- tensorbored/plugins/scalar/summary_v2.py +124 -0
- tensorbored/plugins/text/__init__.py +0 -0
- tensorbored/plugins/text/metadata.py +62 -0
- tensorbored/plugins/text/plugin_data_pb2.py +34 -0
- tensorbored/plugins/text/summary.py +114 -0
- tensorbored/plugins/text/summary_v2.py +124 -0
- tensorbored/plugins/text/text_plugin.py +288 -0
- tensorbored/plugins/wit_redirect/__init__.py +0 -0
- tensorbored/plugins/wit_redirect/wit_redirect_plugin.py +49 -0
- tensorbored/program.py +910 -0
- tensorbored/summary/__init__.py +35 -0
- tensorbored/summary/_output.py +124 -0
- tensorbored/summary/_tf/__init__.py +14 -0
- tensorbored/summary/_tf/summary/__init__.py +178 -0
- tensorbored/summary/_writer.py +105 -0
- tensorbored/summary/v1.py +51 -0
- tensorbored/summary/v2.py +25 -0
- tensorbored/summary/writer/__init__.py +13 -0
- tensorbored/summary/writer/event_file_writer.py +291 -0
- tensorbored/summary/writer/record_writer.py +50 -0
- tensorbored/util/__init__.py +0 -0
- tensorbored/util/encoder.py +116 -0
- tensorbored/util/grpc_util.py +311 -0
- tensorbored/util/img_mime_type_detector.py +40 -0
- tensorbored/util/io_util.py +20 -0
- tensorbored/util/lazy_tensor_creator.py +110 -0
- tensorbored/util/op_evaluator.py +104 -0
- tensorbored/util/platform_util.py +20 -0
- tensorbored/util/tb_logging.py +24 -0
- tensorbored/util/tensor_util.py +617 -0
- tensorbored/util/timing.py +122 -0
- tensorbored/version.py +21 -0
- tensorbored/webfiles.zip +0 -0
- tensorbored-2.21.0rc1769983804.dist-info/METADATA +49 -0
- tensorbored-2.21.0rc1769983804.dist-info/RECORD +271 -0
- tensorbored-2.21.0rc1769983804.dist-info/WHEEL +5 -0
- tensorbored-2.21.0rc1769983804.dist-info/entry_points.txt +6 -0
- tensorbored-2.21.0rc1769983804.dist-info/licenses/LICENSE +739 -0
- tensorbored-2.21.0rc1769983804.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
# Copyright 2018 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.
|
|
14
|
+
# ==============================================================================
|
|
15
|
+
|
|
16
|
+
# Contains error codes defined in tensorflow/core/lib/core/error_codes.proto
|
|
17
|
+
|
|
18
|
+
# Not an error; returned on success
|
|
19
|
+
OK = 0
|
|
20
|
+
|
|
21
|
+
# The operation was cancelled (typically by the caller).
|
|
22
|
+
CANCELLED = 1
|
|
23
|
+
|
|
24
|
+
"""
|
|
25
|
+
Unknown error. An example of where this error may be returned is
|
|
26
|
+
if a Status value received from another address space belongs to
|
|
27
|
+
an error-space that is not known in this address space. Also
|
|
28
|
+
errors raised by APIs that do not return enough error information
|
|
29
|
+
may be converted to this error.
|
|
30
|
+
"""
|
|
31
|
+
UNKNOWN = 2
|
|
32
|
+
|
|
33
|
+
"""
|
|
34
|
+
Client specified an invalid argument. Note that this differs
|
|
35
|
+
from FAILED_PRECONDITION. INVALID_ARGUMENT indicates arguments
|
|
36
|
+
that are problematic regardless of the state of the system
|
|
37
|
+
(e.g., a malformed file name).
|
|
38
|
+
"""
|
|
39
|
+
INVALID_ARGUMENT = 3
|
|
40
|
+
|
|
41
|
+
"""
|
|
42
|
+
Deadline expired before operation could complete. For operations
|
|
43
|
+
that change the state of the system, this error may be returned
|
|
44
|
+
even if the operation has completed successfully. For example, a
|
|
45
|
+
successful response from a server could have been delayed long
|
|
46
|
+
enough for the deadline to expire.
|
|
47
|
+
"""
|
|
48
|
+
DEADLINE_EXCEEDED = 4
|
|
49
|
+
|
|
50
|
+
"""
|
|
51
|
+
Some requested entity (e.g., file or directory) was not found.
|
|
52
|
+
For privacy reasons, this code *may* be returned when the client
|
|
53
|
+
does not have the access right to the entity.
|
|
54
|
+
"""
|
|
55
|
+
NOT_FOUND = 5
|
|
56
|
+
|
|
57
|
+
"""
|
|
58
|
+
Some entity that we attempted to create (e.g., file or directory)
|
|
59
|
+
already exists.
|
|
60
|
+
"""
|
|
61
|
+
ALREADY_EXISTS = 6
|
|
62
|
+
|
|
63
|
+
"""
|
|
64
|
+
The caller does not have permission to execute the specified
|
|
65
|
+
operation. PERMISSION_DENIED must not be used for rejections
|
|
66
|
+
caused by exhausting some resource (use RESOURCE_EXHAUSTED
|
|
67
|
+
instead for those errors). PERMISSION_DENIED must not be
|
|
68
|
+
used if the caller can not be identified (use UNAUTHENTICATED
|
|
69
|
+
instead for those errors).
|
|
70
|
+
"""
|
|
71
|
+
PERMISSION_DENIED = 7
|
|
72
|
+
|
|
73
|
+
"""
|
|
74
|
+
Some resource has been exhausted, perhaps a per-user quota, or
|
|
75
|
+
perhaps the entire file system is out of space.
|
|
76
|
+
"""
|
|
77
|
+
RESOURCE_EXHAUSTED = 8
|
|
78
|
+
|
|
79
|
+
"""
|
|
80
|
+
Operation was rejected because the system is not in a state
|
|
81
|
+
required for the operation's execution. For example, directory
|
|
82
|
+
to be deleted may be non-empty, an rmdir operation is applied to
|
|
83
|
+
a non-directory, etc.
|
|
84
|
+
A litmus test that may help a service implementor in deciding
|
|
85
|
+
between FAILED_PRECONDITION, ABORTED, and UNAVAILABLE:
|
|
86
|
+
(a) Use UNAVAILABLE if the client can retry just the failing call.
|
|
87
|
+
(b) Use ABORTED if the client should retry at a higher-level
|
|
88
|
+
(e.g., restarting a read-modify-write sequence).
|
|
89
|
+
(c) Use FAILED_PRECONDITION if the client should not retry until
|
|
90
|
+
the system state has been explicitly fixed. E.g., if an "rmdir"
|
|
91
|
+
fails because the directory is non-empty, FAILED_PRECONDITION
|
|
92
|
+
should be returned since the client should not retry unless
|
|
93
|
+
they have first fixed up the directory by deleting files from it.
|
|
94
|
+
(d) Use FAILED_PRECONDITION if the client performs conditional
|
|
95
|
+
REST Get/Update/Delete on a resource and the resource on the
|
|
96
|
+
server does not match the condition. E.g., conflicting
|
|
97
|
+
read-modify-write on the same resource.
|
|
98
|
+
"""
|
|
99
|
+
FAILED_PRECONDITION = 9
|
|
100
|
+
|
|
101
|
+
"""
|
|
102
|
+
The operation was aborted, typically due to a concurrency issue
|
|
103
|
+
like sequencer check failures, transaction aborts, etc.
|
|
104
|
+
|
|
105
|
+
See litmus test above for deciding between FAILED_PRECONDITION,
|
|
106
|
+
ABORTED, and UNAVAILABLE.
|
|
107
|
+
"""
|
|
108
|
+
ABORTED = 10
|
|
109
|
+
|
|
110
|
+
"""
|
|
111
|
+
Operation tried to iterate past the valid input range. E.g., seeking or
|
|
112
|
+
reading past end of file.
|
|
113
|
+
|
|
114
|
+
Unlike INVALID_ARGUMENT, this error indicates a problem that may
|
|
115
|
+
be fixed if the system state changes. For example, a 32-bit file
|
|
116
|
+
system will generate INVALID_ARGUMENT if asked to read at an
|
|
117
|
+
offset that is not in the range [0,2^32-1], but it will generate
|
|
118
|
+
OUT_OF_RANGE if asked to read from an offset past the current
|
|
119
|
+
file size.
|
|
120
|
+
|
|
121
|
+
There is a fair bit of overlap between FAILED_PRECONDITION and
|
|
122
|
+
OUT_OF_RANGE. We recommend using OUT_OF_RANGE (the more specific
|
|
123
|
+
error) when it applies so that callers who are iterating through
|
|
124
|
+
a space can easily look for an OUT_OF_RANGE error to detect when
|
|
125
|
+
they are done.
|
|
126
|
+
"""
|
|
127
|
+
OUT_OF_RANGE = 11
|
|
128
|
+
|
|
129
|
+
# Operation is not implemented or not supported/enabled in this service.
|
|
130
|
+
UNIMPLEMENTED = 12
|
|
131
|
+
|
|
132
|
+
"""
|
|
133
|
+
Internal errors. Means some invariant expected by the underlying
|
|
134
|
+
system has been broken. If you see one of these errors,
|
|
135
|
+
something is very broken.
|
|
136
|
+
"""
|
|
137
|
+
INTERNAL = 13
|
|
138
|
+
|
|
139
|
+
"""
|
|
140
|
+
The service is currently unavailable. This is a most likely a
|
|
141
|
+
transient condition and may be corrected by retrying with
|
|
142
|
+
a backoff.
|
|
143
|
+
|
|
144
|
+
See litmus test above for deciding between FAILED_PRECONDITION,
|
|
145
|
+
ABORTED, and UNAVAILABLE.
|
|
146
|
+
"""
|
|
147
|
+
UNAVAILABLE = 14
|
|
148
|
+
|
|
149
|
+
# Unrecoverable data loss or corruption.
|
|
150
|
+
DATA_LOSS = 15
|
|
151
|
+
|
|
152
|
+
"""
|
|
153
|
+
The request does not have valid authentication credentials for the
|
|
154
|
+
operation.
|
|
155
|
+
"""
|
|
156
|
+
UNAUTHENTICATED = 16
|
|
157
|
+
|
|
158
|
+
"""
|
|
159
|
+
An extra enum entry to prevent people from writing code that
|
|
160
|
+
fails to compile when a new code is added.
|
|
161
|
+
|
|
162
|
+
Nobody should ever reference this enumeration entry. In particular,
|
|
163
|
+
if you write C++ code that switches on this enumeration, add a default:
|
|
164
|
+
case instead of a case that mentions this enumeration entry.
|
|
165
|
+
|
|
166
|
+
Nobody should rely on the value (currently 20) listed here. It
|
|
167
|
+
may change in the future.
|
|
168
|
+
"""
|
|
169
|
+
DO_NOT_USE_RESERVED_FOR_FUTURE_EXPANSION_USE_DEFAULT_IN_SWITCH_INSTEAD_ = 20
|
|
@@ -0,0 +1,507 @@
|
|
|
1
|
+
# Copyright 2015 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.
|
|
14
|
+
# ==============================================================================
|
|
15
|
+
"""Exception types for TensorFlow errors."""
|
|
16
|
+
|
|
17
|
+
import traceback
|
|
18
|
+
import warnings
|
|
19
|
+
|
|
20
|
+
from . import error_codes
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
# @tf_export("OpError", "errors.OpError")
|
|
24
|
+
class OpError(Exception):
|
|
25
|
+
"""A generic error that is raised when TensorFlow execution fails.
|
|
26
|
+
|
|
27
|
+
Whenever possible, the session will raise a more specific subclass
|
|
28
|
+
of `OpError` from the `tf.errors` module.
|
|
29
|
+
"""
|
|
30
|
+
|
|
31
|
+
def __init__(self, node_def, op, message, error_code):
|
|
32
|
+
"""Creates a new `OpError` indicating that a particular op failed.
|
|
33
|
+
|
|
34
|
+
Args:
|
|
35
|
+
node_def: The `node_def_pb2.NodeDef` proto representing the op that
|
|
36
|
+
failed, if known; otherwise None.
|
|
37
|
+
op: The `ops.Operation` that failed, if known; otherwise None.
|
|
38
|
+
message: The message string describing the failure.
|
|
39
|
+
error_code: The `error_codes.Code` describing the error.
|
|
40
|
+
"""
|
|
41
|
+
super().__init__()
|
|
42
|
+
self._message = message
|
|
43
|
+
self._node_def = node_def
|
|
44
|
+
self._op = op
|
|
45
|
+
self._error_code = error_code
|
|
46
|
+
|
|
47
|
+
@property
|
|
48
|
+
def message(self):
|
|
49
|
+
"""The error message that describes the error."""
|
|
50
|
+
return self._message
|
|
51
|
+
|
|
52
|
+
@property
|
|
53
|
+
def op(self):
|
|
54
|
+
"""The operation that failed, if known.
|
|
55
|
+
|
|
56
|
+
*N.B.* If the failed op was synthesized at runtime, e.g. a `Send`
|
|
57
|
+
or `Recv` op, there will be no corresponding
|
|
58
|
+
@{tf.Operation}
|
|
59
|
+
object. In that case, this will return `None`, and you should
|
|
60
|
+
instead use the @{tf.OpError.node_def} to
|
|
61
|
+
discover information about the op.
|
|
62
|
+
|
|
63
|
+
Returns:
|
|
64
|
+
The `Operation` that failed, or None.
|
|
65
|
+
"""
|
|
66
|
+
return self._op
|
|
67
|
+
|
|
68
|
+
@property
|
|
69
|
+
def error_code(self):
|
|
70
|
+
"""The integer error code that describes the error."""
|
|
71
|
+
return self._error_code
|
|
72
|
+
|
|
73
|
+
@property
|
|
74
|
+
def node_def(self):
|
|
75
|
+
"""The `NodeDef` proto representing the op that failed."""
|
|
76
|
+
return self._node_def
|
|
77
|
+
|
|
78
|
+
def __str__(self):
|
|
79
|
+
if self._op is not None:
|
|
80
|
+
output = [
|
|
81
|
+
"%s\n\nCaused by op %r, defined at:\n"
|
|
82
|
+
% (self.message, self._op.name)
|
|
83
|
+
]
|
|
84
|
+
curr_traceback_list = traceback.format_list(self._op.traceback)
|
|
85
|
+
output.extend(curr_traceback_list)
|
|
86
|
+
# pylint: disable=protected-access
|
|
87
|
+
original_op = self._op._original_op
|
|
88
|
+
# pylint: enable=protected-access
|
|
89
|
+
while original_op is not None:
|
|
90
|
+
output.append(
|
|
91
|
+
"\n...which was originally created as op %r, defined at:\n"
|
|
92
|
+
% (original_op.name,)
|
|
93
|
+
)
|
|
94
|
+
prev_traceback_list = curr_traceback_list
|
|
95
|
+
curr_traceback_list = traceback.format_list(
|
|
96
|
+
original_op.traceback
|
|
97
|
+
)
|
|
98
|
+
|
|
99
|
+
# Attempt to elide large common subsequences of the subsequent
|
|
100
|
+
# stack traces.
|
|
101
|
+
#
|
|
102
|
+
# TODO(mrry): Consider computing the actual longest common subsequence.
|
|
103
|
+
is_eliding = False
|
|
104
|
+
elide_count = 0
|
|
105
|
+
last_elided_line = None
|
|
106
|
+
for line, line_in_prev in zip(
|
|
107
|
+
curr_traceback_list, prev_traceback_list
|
|
108
|
+
):
|
|
109
|
+
if line == line_in_prev:
|
|
110
|
+
if is_eliding:
|
|
111
|
+
elide_count += 1
|
|
112
|
+
last_elided_line = line
|
|
113
|
+
else:
|
|
114
|
+
output.append(line)
|
|
115
|
+
is_eliding = True
|
|
116
|
+
elide_count = 0
|
|
117
|
+
else:
|
|
118
|
+
if is_eliding:
|
|
119
|
+
if elide_count > 0:
|
|
120
|
+
output.extend(
|
|
121
|
+
[
|
|
122
|
+
"[elided %d identical lines from previous traceback]\n"
|
|
123
|
+
% (elide_count - 1,),
|
|
124
|
+
last_elided_line,
|
|
125
|
+
]
|
|
126
|
+
)
|
|
127
|
+
is_eliding = False
|
|
128
|
+
output.extend(line)
|
|
129
|
+
|
|
130
|
+
# pylint: disable=protected-access
|
|
131
|
+
original_op = original_op._original_op
|
|
132
|
+
# pylint: enable=protected-access
|
|
133
|
+
output.append(
|
|
134
|
+
"\n%s (see above for traceback): %s\n"
|
|
135
|
+
% (type(self).__name__, self.message)
|
|
136
|
+
)
|
|
137
|
+
return "".join(output)
|
|
138
|
+
else:
|
|
139
|
+
return self.message
|
|
140
|
+
|
|
141
|
+
|
|
142
|
+
OK = error_codes.OK
|
|
143
|
+
# tf_export("errors.OK").export_constant(__name__, "OK")
|
|
144
|
+
CANCELLED = error_codes.CANCELLED
|
|
145
|
+
# tf_export("errors.CANCELLED").export_constant(__name__, "CANCELLED")
|
|
146
|
+
UNKNOWN = error_codes.UNKNOWN
|
|
147
|
+
# tf_export("errors.UNKNOWN").export_constant(__name__, "UNKNOWN")
|
|
148
|
+
INVALID_ARGUMENT = error_codes.INVALID_ARGUMENT
|
|
149
|
+
# tf_export("errors.INVALID_ARGUMENT").export_constant(__name__,
|
|
150
|
+
# "INVALID_ARGUMENT")
|
|
151
|
+
DEADLINE_EXCEEDED = error_codes.DEADLINE_EXCEEDED
|
|
152
|
+
# tf_export("errors.DEADLINE_EXCEEDED").export_constant(__name__,
|
|
153
|
+
# "DEADLINE_EXCEEDED")
|
|
154
|
+
NOT_FOUND = error_codes.NOT_FOUND
|
|
155
|
+
# tf_export("errors.NOT_FOUND").export_constant(__name__, "NOT_FOUND")
|
|
156
|
+
ALREADY_EXISTS = error_codes.ALREADY_EXISTS
|
|
157
|
+
# tf_export("errors.ALREADY_EXISTS").export_constant(__name__, "ALREADY_EXISTS")
|
|
158
|
+
PERMISSION_DENIED = error_codes.PERMISSION_DENIED
|
|
159
|
+
# tf_export("errors.PERMISSION_DENIED").export_constant(__name__,
|
|
160
|
+
# "PERMISSION_DENIED")
|
|
161
|
+
UNAUTHENTICATED = error_codes.UNAUTHENTICATED
|
|
162
|
+
# tf_export("errors.UNAUTHENTICATED").export_constant(__name__, "UNAUTHENTICATED")
|
|
163
|
+
RESOURCE_EXHAUSTED = error_codes.RESOURCE_EXHAUSTED
|
|
164
|
+
# tf_export("errors.RESOURCE_EXHAUSTED").export_constant(__name__,
|
|
165
|
+
# "RESOURCE_EXHAUSTED")
|
|
166
|
+
FAILED_PRECONDITION = error_codes.FAILED_PRECONDITION
|
|
167
|
+
# tf_export("errors.FAILED_PRECONDITION").export_constant(__name__,
|
|
168
|
+
# "FAILED_PRECONDITION")
|
|
169
|
+
ABORTED = error_codes.ABORTED
|
|
170
|
+
# tf_export("errors.ABORTED").export_constant(__name__, "ABORTED")
|
|
171
|
+
OUT_OF_RANGE = error_codes.OUT_OF_RANGE
|
|
172
|
+
# tf_export("errors.OUT_OF_RANGE").export_constant(__name__, "OUT_OF_RANGE")
|
|
173
|
+
UNIMPLEMENTED = error_codes.UNIMPLEMENTED
|
|
174
|
+
# tf_export("errors.UNIMPLEMENTED").export_constant(__name__, "UNIMPLEMENTED")
|
|
175
|
+
INTERNAL = error_codes.INTERNAL
|
|
176
|
+
# tf_export("errors.INTERNAL").export_constant(__name__, "INTERNAL")
|
|
177
|
+
UNAVAILABLE = error_codes.UNAVAILABLE
|
|
178
|
+
# tf_export("errors.UNAVAILABLE").export_constant(__name__, "UNAVAILABLE")
|
|
179
|
+
DATA_LOSS = error_codes.DATA_LOSS
|
|
180
|
+
# tf_export("errors.DATA_LOSS").export_constant(__name__, "DATA_LOSS")
|
|
181
|
+
|
|
182
|
+
|
|
183
|
+
# @tf_export("errors.CancelledError")
|
|
184
|
+
class CancelledError(OpError):
|
|
185
|
+
"""Raised when an operation or step is cancelled.
|
|
186
|
+
|
|
187
|
+
For example, a long-running operation (e.g.
|
|
188
|
+
@{tf.QueueBase.enqueue} may be
|
|
189
|
+
cancelled by running another operation (e.g.
|
|
190
|
+
@{tf.QueueBase.close},
|
|
191
|
+
or by @{tf.Session.close}.
|
|
192
|
+
A step that is running such a long-running operation will fail by raising
|
|
193
|
+
`CancelledError`.
|
|
194
|
+
|
|
195
|
+
@@__init__
|
|
196
|
+
"""
|
|
197
|
+
|
|
198
|
+
def __init__(self, node_def, op, message):
|
|
199
|
+
"""Creates a `CancelledError`."""
|
|
200
|
+
super().__init__(node_def, op, message, CANCELLED)
|
|
201
|
+
|
|
202
|
+
|
|
203
|
+
# @tf_export("errors.UnknownError")
|
|
204
|
+
class UnknownError(OpError):
|
|
205
|
+
"""Unknown error.
|
|
206
|
+
|
|
207
|
+
An example of where this error may be returned is if a Status value
|
|
208
|
+
received from another address space belongs to an error-space that
|
|
209
|
+
is not known to this address space. Also errors raised by APIs that
|
|
210
|
+
do not return enough error information may be converted to this
|
|
211
|
+
error.
|
|
212
|
+
|
|
213
|
+
@@__init__
|
|
214
|
+
"""
|
|
215
|
+
|
|
216
|
+
def __init__(self, node_def, op, message, error_code=UNKNOWN):
|
|
217
|
+
"""Creates an `UnknownError`."""
|
|
218
|
+
super().__init__(node_def, op, message, error_code)
|
|
219
|
+
|
|
220
|
+
|
|
221
|
+
# @tf_export("errors.InvalidArgumentError")
|
|
222
|
+
class InvalidArgumentError(OpError):
|
|
223
|
+
"""Raised when an operation receives an invalid argument.
|
|
224
|
+
|
|
225
|
+
This may occur, for example, if an operation is receives an input
|
|
226
|
+
tensor that has an invalid value or shape. For example, the
|
|
227
|
+
@{tf.matmul} op will raise this
|
|
228
|
+
error if it receives an input that is not a matrix, and the
|
|
229
|
+
@{tf.reshape} op will raise
|
|
230
|
+
this error if the new shape does not match the number of elements in the input
|
|
231
|
+
tensor.
|
|
232
|
+
|
|
233
|
+
@@__init__
|
|
234
|
+
"""
|
|
235
|
+
|
|
236
|
+
def __init__(self, node_def, op, message):
|
|
237
|
+
"""Creates an `InvalidArgumentError`."""
|
|
238
|
+
super().__init__(node_def, op, message, INVALID_ARGUMENT)
|
|
239
|
+
|
|
240
|
+
|
|
241
|
+
# @tf_export("errors.DeadlineExceededError")
|
|
242
|
+
class DeadlineExceededError(OpError):
|
|
243
|
+
"""Raised when a deadline expires before an operation could complete.
|
|
244
|
+
|
|
245
|
+
This exception is not currently used.
|
|
246
|
+
|
|
247
|
+
@@__init__
|
|
248
|
+
"""
|
|
249
|
+
|
|
250
|
+
def __init__(self, node_def, op, message):
|
|
251
|
+
"""Creates a `DeadlineExceededError`."""
|
|
252
|
+
super().__init__(node_def, op, message, DEADLINE_EXCEEDED)
|
|
253
|
+
|
|
254
|
+
|
|
255
|
+
# @tf_export("errors.NotFoundError")
|
|
256
|
+
class NotFoundError(OpError):
|
|
257
|
+
"""Raised when a requested entity (e.g., a file or directory) was not
|
|
258
|
+
found.
|
|
259
|
+
|
|
260
|
+
For example, running the
|
|
261
|
+
@{tf.WholeFileReader.read}
|
|
262
|
+
operation could raise `NotFoundError` if it receives the name of a file that
|
|
263
|
+
does not exist.
|
|
264
|
+
|
|
265
|
+
@@__init__
|
|
266
|
+
"""
|
|
267
|
+
|
|
268
|
+
def __init__(self, node_def, op, message):
|
|
269
|
+
"""Creates a `NotFoundError`."""
|
|
270
|
+
super().__init__(node_def, op, message, NOT_FOUND)
|
|
271
|
+
|
|
272
|
+
|
|
273
|
+
# @tf_export("errors.AlreadyExistsError")
|
|
274
|
+
class AlreadyExistsError(OpError):
|
|
275
|
+
"""Raised when an entity that we attempted to create already exists.
|
|
276
|
+
|
|
277
|
+
For example, running an operation that saves a file
|
|
278
|
+
(e.g. @{tf.train.Saver.save})
|
|
279
|
+
could potentially raise this exception if an explicit filename for an
|
|
280
|
+
existing file was passed.
|
|
281
|
+
|
|
282
|
+
@@__init__
|
|
283
|
+
"""
|
|
284
|
+
|
|
285
|
+
def __init__(self, node_def, op, message):
|
|
286
|
+
"""Creates an `AlreadyExistsError`."""
|
|
287
|
+
super().__init__(node_def, op, message, ALREADY_EXISTS)
|
|
288
|
+
|
|
289
|
+
|
|
290
|
+
# @tf_export("errors.PermissionDeniedError")
|
|
291
|
+
class PermissionDeniedError(OpError):
|
|
292
|
+
"""Raised when the caller does not have permission to run an operation.
|
|
293
|
+
|
|
294
|
+
For example, running the
|
|
295
|
+
@{tf.WholeFileReader.read}
|
|
296
|
+
operation could raise `PermissionDeniedError` if it receives the name of a
|
|
297
|
+
file for which the user does not have the read file permission.
|
|
298
|
+
|
|
299
|
+
@@__init__
|
|
300
|
+
"""
|
|
301
|
+
|
|
302
|
+
def __init__(self, node_def, op, message):
|
|
303
|
+
"""Creates a `PermissionDeniedError`."""
|
|
304
|
+
super().__init__(node_def, op, message, PERMISSION_DENIED)
|
|
305
|
+
|
|
306
|
+
|
|
307
|
+
# @tf_export("errors.UnauthenticatedError")
|
|
308
|
+
class UnauthenticatedError(OpError):
|
|
309
|
+
"""The request does not have valid authentication credentials.
|
|
310
|
+
|
|
311
|
+
This exception is not currently used.
|
|
312
|
+
|
|
313
|
+
@@__init__
|
|
314
|
+
"""
|
|
315
|
+
|
|
316
|
+
def __init__(self, node_def, op, message):
|
|
317
|
+
"""Creates an `UnauthenticatedError`."""
|
|
318
|
+
super().__init__(node_def, op, message, UNAUTHENTICATED)
|
|
319
|
+
|
|
320
|
+
|
|
321
|
+
# @tf_export("errors.ResourceExhaustedError")
|
|
322
|
+
class ResourceExhaustedError(OpError):
|
|
323
|
+
"""Some resource has been exhausted.
|
|
324
|
+
|
|
325
|
+
For example, this error might be raised if a per-user quota is
|
|
326
|
+
exhausted, or perhaps the entire file system is out of space.
|
|
327
|
+
|
|
328
|
+
@@__init__
|
|
329
|
+
"""
|
|
330
|
+
|
|
331
|
+
def __init__(self, node_def, op, message):
|
|
332
|
+
"""Creates a `ResourceExhaustedError`."""
|
|
333
|
+
super().__init__(node_def, op, message, RESOURCE_EXHAUSTED)
|
|
334
|
+
|
|
335
|
+
|
|
336
|
+
# @tf_export("errors.FailedPreconditionError")
|
|
337
|
+
class FailedPreconditionError(OpError):
|
|
338
|
+
"""Operation was rejected because the system is not in a state to execute
|
|
339
|
+
it.
|
|
340
|
+
|
|
341
|
+
This exception is most commonly raised when running an operation
|
|
342
|
+
that reads a @{tf.Variable}
|
|
343
|
+
before it has been initialized.
|
|
344
|
+
|
|
345
|
+
@@__init__
|
|
346
|
+
"""
|
|
347
|
+
|
|
348
|
+
def __init__(self, node_def, op, message):
|
|
349
|
+
"""Creates a `FailedPreconditionError`."""
|
|
350
|
+
super().__init__(node_def, op, message, FAILED_PRECONDITION)
|
|
351
|
+
|
|
352
|
+
|
|
353
|
+
# @tf_export("errors.AbortedError")
|
|
354
|
+
class AbortedError(OpError):
|
|
355
|
+
"""The operation was aborted, typically due to a concurrent action.
|
|
356
|
+
|
|
357
|
+
For example, running a
|
|
358
|
+
@{tf.QueueBase.enqueue}
|
|
359
|
+
operation may raise `AbortedError` if a
|
|
360
|
+
@{tf.QueueBase.close} operation
|
|
361
|
+
previously ran.
|
|
362
|
+
|
|
363
|
+
@@__init__
|
|
364
|
+
"""
|
|
365
|
+
|
|
366
|
+
def __init__(self, node_def, op, message):
|
|
367
|
+
"""Creates an `AbortedError`."""
|
|
368
|
+
super().__init__(node_def, op, message, ABORTED)
|
|
369
|
+
|
|
370
|
+
|
|
371
|
+
# @tf_export("errors.OutOfRangeError")
|
|
372
|
+
class OutOfRangeError(OpError):
|
|
373
|
+
"""Raised when an operation iterates past the valid input range.
|
|
374
|
+
|
|
375
|
+
This exception is raised in "end-of-file" conditions, such as when a
|
|
376
|
+
@{tf.QueueBase.dequeue}
|
|
377
|
+
operation is blocked on an empty queue, and a
|
|
378
|
+
@{tf.QueueBase.close}
|
|
379
|
+
operation executes.
|
|
380
|
+
|
|
381
|
+
@@__init__
|
|
382
|
+
"""
|
|
383
|
+
|
|
384
|
+
def __init__(self, node_def, op, message):
|
|
385
|
+
"""Creates an `OutOfRangeError`."""
|
|
386
|
+
super().__init__(node_def, op, message, OUT_OF_RANGE)
|
|
387
|
+
|
|
388
|
+
|
|
389
|
+
# @tf_export("errors.UnimplementedError")
|
|
390
|
+
class UnimplementedError(OpError):
|
|
391
|
+
"""Raised when an operation has not been implemented.
|
|
392
|
+
|
|
393
|
+
Some operations may raise this error when passed otherwise-valid
|
|
394
|
+
arguments that it does not currently support. For example, running
|
|
395
|
+
the @{tf.nn.max_pool} operation
|
|
396
|
+
would raise this error if pooling was requested on the batch dimension,
|
|
397
|
+
because this is not yet supported.
|
|
398
|
+
|
|
399
|
+
@@__init__
|
|
400
|
+
"""
|
|
401
|
+
|
|
402
|
+
def __init__(self, node_def, op, message):
|
|
403
|
+
"""Creates an `UnimplementedError`."""
|
|
404
|
+
super().__init__(node_def, op, message, UNIMPLEMENTED)
|
|
405
|
+
|
|
406
|
+
|
|
407
|
+
# @tf_export("errors.InternalError")
|
|
408
|
+
class InternalError(OpError):
|
|
409
|
+
"""Raised when the system experiences an internal error.
|
|
410
|
+
|
|
411
|
+
This exception is raised when some invariant expected by the runtime
|
|
412
|
+
has been broken. Catching this exception is not recommended.
|
|
413
|
+
|
|
414
|
+
@@__init__
|
|
415
|
+
"""
|
|
416
|
+
|
|
417
|
+
def __init__(self, node_def, op, message):
|
|
418
|
+
"""Creates an `InternalError`."""
|
|
419
|
+
super().__init__(node_def, op, message, INTERNAL)
|
|
420
|
+
|
|
421
|
+
|
|
422
|
+
# @tf_export("errors.UnavailableError")
|
|
423
|
+
class UnavailableError(OpError):
|
|
424
|
+
"""Raised when the runtime is currently unavailable.
|
|
425
|
+
|
|
426
|
+
This exception is not currently used.
|
|
427
|
+
|
|
428
|
+
@@__init__
|
|
429
|
+
"""
|
|
430
|
+
|
|
431
|
+
def __init__(self, node_def, op, message):
|
|
432
|
+
"""Creates an `UnavailableError`."""
|
|
433
|
+
super().__init__(node_def, op, message, UNAVAILABLE)
|
|
434
|
+
|
|
435
|
+
|
|
436
|
+
# @tf_export("errors.DataLossError")
|
|
437
|
+
class DataLossError(OpError):
|
|
438
|
+
"""Raised when unrecoverable data loss or corruption is encountered.
|
|
439
|
+
|
|
440
|
+
For example, this may be raised by running a
|
|
441
|
+
@{tf.WholeFileReader.read}
|
|
442
|
+
operation, if the file is truncated while it is being read.
|
|
443
|
+
|
|
444
|
+
@@__init__
|
|
445
|
+
"""
|
|
446
|
+
|
|
447
|
+
def __init__(self, node_def, op, message):
|
|
448
|
+
"""Creates a `DataLossError`."""
|
|
449
|
+
super().__init__(node_def, op, message, DATA_LOSS)
|
|
450
|
+
|
|
451
|
+
|
|
452
|
+
_CODE_TO_EXCEPTION_CLASS = {
|
|
453
|
+
CANCELLED: CancelledError,
|
|
454
|
+
UNKNOWN: UnknownError,
|
|
455
|
+
INVALID_ARGUMENT: InvalidArgumentError,
|
|
456
|
+
DEADLINE_EXCEEDED: DeadlineExceededError,
|
|
457
|
+
NOT_FOUND: NotFoundError,
|
|
458
|
+
ALREADY_EXISTS: AlreadyExistsError,
|
|
459
|
+
PERMISSION_DENIED: PermissionDeniedError,
|
|
460
|
+
UNAUTHENTICATED: UnauthenticatedError,
|
|
461
|
+
RESOURCE_EXHAUSTED: ResourceExhaustedError,
|
|
462
|
+
FAILED_PRECONDITION: FailedPreconditionError,
|
|
463
|
+
ABORTED: AbortedError,
|
|
464
|
+
OUT_OF_RANGE: OutOfRangeError,
|
|
465
|
+
UNIMPLEMENTED: UnimplementedError,
|
|
466
|
+
INTERNAL: InternalError,
|
|
467
|
+
UNAVAILABLE: UnavailableError,
|
|
468
|
+
DATA_LOSS: DataLossError,
|
|
469
|
+
}
|
|
470
|
+
|
|
471
|
+
_EXCEPTION_CLASS_TO_CODE = dict(
|
|
472
|
+
((class_, code) for (code, class_) in _CODE_TO_EXCEPTION_CLASS.items())
|
|
473
|
+
)
|
|
474
|
+
|
|
475
|
+
|
|
476
|
+
# @tf_export("errors.exception_type_from_error_code")
|
|
477
|
+
def exception_type_from_error_code(error_code):
|
|
478
|
+
return _CODE_TO_EXCEPTION_CLASS[error_code]
|
|
479
|
+
|
|
480
|
+
|
|
481
|
+
# @tf_export("errors.error_code_from_exception_type")
|
|
482
|
+
def error_code_from_exception_type(cls):
|
|
483
|
+
return _EXCEPTION_CLASS_TO_CODE[cls]
|
|
484
|
+
|
|
485
|
+
|
|
486
|
+
def _make_specific_exception(node_def, op, message, error_code):
|
|
487
|
+
try:
|
|
488
|
+
exc_type = exception_type_from_error_code(error_code)
|
|
489
|
+
return exc_type(node_def, op, message)
|
|
490
|
+
except KeyError:
|
|
491
|
+
warnings.warn("Unknown error code: %d" % error_code)
|
|
492
|
+
return UnknownError(node_def, op, message, error_code)
|
|
493
|
+
|
|
494
|
+
|
|
495
|
+
# Named like a function for backwards compatibility with the
|
|
496
|
+
# @tf_contextlib.contextmanager version, which was switched to a class to avoid
|
|
497
|
+
# some object creation overhead.
|
|
498
|
+
# TODO(b/77295559): expand use of TF_Status* SWIG typemap and deprecate this.
|
|
499
|
+
# @tf_export("errors.raise_exception_on_not_ok_status") # pylint: disable=invalid-name
|
|
500
|
+
class raise_exception_on_not_ok_status:
|
|
501
|
+
"""Context manager to check for C API status."""
|
|
502
|
+
|
|
503
|
+
def __enter__(self):
|
|
504
|
+
return "Status not OK"
|
|
505
|
+
|
|
506
|
+
def __exit__(self, type_arg, value_arg, traceback_arg):
|
|
507
|
+
return False # False values do not suppress exceptions
|