xref: /aosp_15_r20/external/tensorflow/tensorflow/compiler/xla/stream_executor/lib/status.h (revision b6fb3261f9314811a0f4371741dbb8839866f948)
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 
16 
17 #ifndef TENSORFLOW_COMPILER_XLA_STREAM_EXECUTOR_LIB_STATUS_H_
18 #define TENSORFLOW_COMPILER_XLA_STREAM_EXECUTOR_LIB_STATUS_H_
19 
20 #include "absl/strings/string_view.h"
21 #include "tensorflow/compiler/xla/stream_executor/lib/error.h"  // IWYU pragma: export
22 #include "tensorflow/compiler/xla/stream_executor/platform/logging.h"
23 #include "tensorflow/core/platform/status.h"
24 
25 namespace stream_executor {
26 namespace port {
27 
28 using Status = tensorflow::Status;  // TENSORFLOW_STATUS_OK
29 
30 #define SE_CHECK_OK(val) TF_CHECK_OK(val)
31 #define SE_ASSERT_OK(val) \
32   ASSERT_EQ(::stream_executor::port::Status::OK(), (val))
33 
34 // Define some canonical error helpers.
UnimplementedError(absl::string_view message)35 inline Status UnimplementedError(absl::string_view message) {
36   return Status(error::UNIMPLEMENTED, message);
37 }
InvalidArgumentError(absl::string_view message)38 inline Status InvalidArgumentError(absl::string_view message) {
39   return Status(error::INVALID_ARGUMENT, message);
40 }
InternalError(absl::string_view message)41 inline Status InternalError(absl::string_view message) {
42   return Status(error::INTERNAL, message);
43 }
FailedPreconditionError(absl::string_view message)44 inline Status FailedPreconditionError(absl::string_view message) {
45   return Status(error::FAILED_PRECONDITION, message);
46 }
47 
48 }  // namespace port
49 }  // namespace stream_executor
50 
51 namespace perftools {
52 namespace gputools {
53 
54 // Temporarily pull stream_executor into perftools::gputools while we migrate
55 // code to the new namespace.  TODO(b/77980417): Remove this once we've
56 // completed the migration.
57 using namespace stream_executor;  // NOLINT[build/namespaces]
58 
59 }  // namespace gputools
60 }  // namespace perftools
61 
62 #endif  // TENSORFLOW_COMPILER_XLA_STREAM_EXECUTOR_LIB_STATUS_H_
63