• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 #include "tensorflow/core/common_runtime/eager/eager_operation.h"
16 
17 namespace tensorflow {
SetDevice(const char * device)18 tensorflow::Status EagerOperation::SetDevice(const char* device) {
19   auto status = Status::OK();
20   tensorflow::Device* d = nullptr;
21   if (device != nullptr && strlen(device) > 0) {
22     status.Update(ctx_->FindDeviceByName(device, &d));
23   }
24   device_ = d;
25   return status;
26 }
27 
AddInput(tensorflow::TensorHandle * h)28 void EagerOperation::AddInput(tensorflow::TensorHandle* h) {
29   h->Ref();
30   inputs_.push_back(h);
31   attrs_.NumInputs(static_cast<int>(inputs_.size()));
32 }
33 
ConsumeInput(tensorflow::TensorHandle * h)34 void EagerOperation::ConsumeInput(tensorflow::TensorHandle* h) {
35   inputs_.push_back(h);
36   attrs_.NumInputs(static_cast<int>(inputs_.size()));
37 }
38 
DebugString() const39 string EagerOperation::DebugString() const {
40   string out;
41   VLOG(1) << "EagerOperation::DebugString() over " << this;
42 
43   strings::StrAppend(&out, "Name: ", name_, "\n");
44   strings::StrAppend(
45       &out, "Device: ", Device() ? Device()->DebugString() : "[]", "\n");
46   for (const auto& input : inputs_) {
47     VLOG(1) << "Input ptr: " << input;
48     strings::StrAppend(&out, "Input: ", input->DebugString(), "\n");
49   }
50 
51   NodeDef ndef;
52   Attrs().FillAttrValueMap(ndef.mutable_attr());
53   strings::StrAppend(&out, "Attrs: ", ndef.DebugString(), "\n");
54   return out;
55 }
56 
57 }  // namespace tensorflow
58