| 54 | } |
| 55 | |
| 56 | Status EvaluateNode(const NodeDef& node, const TensorVector& inputs, |
| 57 | DeviceBase* cpu_device, ResourceMgr* resource_mgr, |
| 58 | TensorVector* output) { |
| 59 | Status status; |
| 60 | std::unique_ptr<DeviceBase> device; |
| 61 | if (cpu_device == nullptr) { |
| 62 | device.reset(new DeviceSimple()); |
| 63 | cpu_device = device.get(); |
| 64 | } |
| 65 | |
| 66 | std::unique_ptr<OpKernel> op_kernel( |
| 67 | CreateOpKernel("CPU", cpu_device, cpu_device->GetAllocator({}), node, |
| 68 | TF_GRAPH_DEF_VERSION, &status)); |
| 69 | TF_RETURN_IF_ERROR(status); |
| 70 | OpKernelContext::Params params; |
| 71 | params.device = cpu_device; |
| 72 | params.frame_iter = FrameAndIter(0, 0); |
| 73 | params.inputs = &inputs; |
| 74 | params.op_kernel = op_kernel.get(); |
| 75 | params.resource_manager = resource_mgr; |
| 76 | |
| 77 | gtl::InlinedVector<AllocatorAttributes, 4> output_attrs; |
| 78 | const int num_outputs = op_kernel->num_outputs(); |
| 79 | for (int i = 0; i < num_outputs; i++) { |
| 80 | AllocatorAttributes attr; |
| 81 | attr.set_on_host(true); |
| 82 | output_attrs.push_back(attr); |
| 83 | } |
| 84 | params.output_attr_array = output_attrs.data(); |
| 85 | |
| 86 | OpKernelContext op_context(¶ms); |
| 87 | op_kernel->Compute(&op_context); |
| 88 | for (int i = 0; i < num_outputs; i++) { |
| 89 | output->push_back(op_context.release_output(i)); |
| 90 | } |
| 91 | return op_context.status(); |
| 92 | } |
| 93 | |
| 94 | } // end namespace grappler |
| 95 | } // end namespace tensorflow |
no test coverage detected