1 | /* Copyright 2020 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 | #include "tensorflow/c/eager/tracing_utils.h" |
16 | |
17 | #include "tensorflow/c/eager/c_api_unified_experimental_internal.h" |
18 | #include "tensorflow/c/experimental/gradients/tape/tape_operation.h" |
19 | #include "tensorflow/core/lib/llvm_rtti/llvm_rtti.h" |
20 | #include "tensorflow/core/platform/errors.h" |
21 | |
22 | namespace tensorflow { |
23 | namespace tracing { |
24 | |
25 | Status MaybeSetOpName(AbstractOperation* op, const char* op_name) { |
26 | if (isa<TracingOperation>(op)) { |
27 | TF_RETURN_IF_ERROR(dyn_cast<TracingOperation>(op)->SetOpName(op_name)); |
28 | } |
29 | if (isa<gradients::TapeOperation>(op)) { |
30 | TF_RETURN_IF_ERROR(MaybeSetOpName( |
31 | dyn_cast<gradients::TapeOperation>(op)->GetBackingOperation(), |
32 | op_name)); |
33 | } |
34 | return OkStatus(); |
35 | } |
36 | } // namespace tracing |
37 | } // namespace tensorflow |
38 |