| 38 | } |
| 39 | |
| 40 | TFE_TensorHandle* TFE_TensorHandleCache::Lookup( |
| 41 | PyObject* value, tensorflow::DataType dtype, |
| 42 | absl::string_view device_name) const { |
| 43 | CHECK_NOTNULL(value); |
| 44 | const auto& it = cache.find(Key{PyObjectPtr{value}, dtype, device_name}); |
| 45 | if (it == cache.end()) { |
| 46 | scalar_cache_misses->GetCell()->IncrementBy(1); |
| 47 | return nullptr; |
| 48 | } |
| 49 | |
| 50 | scalar_cache_hits->GetCell()->IncrementBy(1); |
| 51 | auto* handle = it->second; |
| 52 | handle->Ref(); |
| 53 | return new TFE_TensorHandle(handle); |
| 54 | } |
| 55 | |
| 56 | void TFE_TensorHandleCache::Insert(PyObject* value, tensorflow::DataType dtype, |
| 57 | absl::string_view device_name, |
no test coverage detected