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