| 148 | // container name. |
| 149 | template <typename T> |
| 150 | void AddResourceInput(const string& container, const string& name, |
| 151 | T* resource) { |
| 152 | CHECK_GT(input_types_.size(), inputs_.size()) |
| 153 | << "Adding more inputs than types; perhaps you need to call MakeOp"; |
| 154 | ResourceMgr* rm = device_->resource_manager(); |
| 155 | std::string container_name = |
| 156 | container == "" ? rm->default_container() : container; |
| 157 | EXPECT_TRUE(rm->Create(container_name, name, resource).ok()); |
| 158 | TypeIndex type_index = MakeTypeIndex<T>(); |
| 159 | ResourceHandle handle; |
| 160 | handle.set_device(device_->name()); |
| 161 | handle.set_container(container_name); |
| 162 | handle.set_name(name); |
| 163 | handle.set_hash_code(type_index.hash_code()); |
| 164 | handle.set_maybe_type_name(type_index.name()); |
| 165 | Tensor* input = new Tensor(allocator(), DT_RESOURCE, TensorShape({})); |
| 166 | input->scalar<ResourceHandle>()() = handle; |
| 167 | tensors_.push_back(input); |
| 168 | inputs_.push_back({nullptr, input}); |
| 169 | } |
| 170 | |
| 171 | // Runs an operation producing 'num_outputs' outputs. |
| 172 | // |
nothing calls this directly
no test coverage detected