| 242 | } |
| 243 | |
| 244 | void Compute(OpKernelContext* c) override { |
| 245 | if (dtype_ == DT_RESOURCE) { |
| 246 | core::RefCountPtr<Var> v; |
| 247 | OP_REQUIRES_OK(c, LookupResource(c, HandleFromInput(c, 0), &v)); |
| 248 | OP_REQUIRES_OK(c, EnsureSparseVariableAccess<Device, T>(c, v.get())); |
| 249 | mutex_lock m(*v->mu()); |
| 250 | DoCompute(c); |
| 251 | } else if (use_exclusive_lock_) { |
| 252 | // If we're here, it means the input type is a ref. |
| 253 | DCHECK(IsRefType(c->input_dtype(0))); |
| 254 | // Hold mutex while we apply updates |
| 255 | mutex_lock l(*c->input_ref_mutex(0)); |
| 256 | DoCompute(c); |
| 257 | } else { |
| 258 | DoCompute(c); |
| 259 | } |
| 260 | } |
| 261 | |
| 262 | private: |
| 263 | DataType dtype_; |
nothing calls this directly
no test coverage detected