From 5255b31b5bfbbd7f06b07c993691e6a324ba1aac Mon Sep 17 00:00:00 2001 From: guopeian Date: Tue, 10 Nov 2020 16:24:26 +0800 Subject: [PATCH 1/2] LruCache python api --- tf_adapter/kernels/npu_cpu_ops.cc | 2 +- tf_adapter/ops/npu_cpu_ops.cc | 1 + tf_adapter/python/npu_bridge/npu_cpu/lru_cache.py | 1 + 3 files changed, 3 insertions(+), 1 deletion(-) diff --git a/tf_adapter/kernels/npu_cpu_ops.cc b/tf_adapter/kernels/npu_cpu_ops.cc index aec450540..51a21e9dd 100644 --- a/tf_adapter/kernels/npu_cpu_ops.cc +++ b/tf_adapter/kernels/npu_cpu_ops.cc @@ -45,7 +45,7 @@ class LruCacheOp : public ResourceOpKernel { explicit LruCacheOp(OpKernelConstruction* context) : ResourceOpKernel(context) {} void Compute(OpKernelContext* context) override { LOG(INFO) << "LruCacheOp Compute"; } private: - Status CreateResource(CacheInterface** context) override + Status CreateResource(CacheInterface** resource) override EXCLUSIVE_LOCKS_REQUIRED(mu_) { return Status::OK(); } diff --git a/tf_adapter/ops/npu_cpu_ops.cc b/tf_adapter/ops/npu_cpu_ops.cc index 8be545782..6e4a59ca0 100644 --- a/tf_adapter/ops/npu_cpu_ops.cc +++ b/tf_adapter/ops/npu_cpu_ops.cc @@ -61,6 +61,7 @@ REGISTER_OP("LruCache") .Attr("cache_size: int") .Attr("container: string = ''") .Attr("shared_name: string = 'LruCache'") + .Attr("load_factor: float = 1.0") .SetIsStateful() .SetShapeFn(shape_inference::ScalarShape); //regist cache add op diff --git a/tf_adapter/python/npu_bridge/npu_cpu/lru_cache.py b/tf_adapter/python/npu_bridge/npu_cpu/lru_cache.py index 701c5cf54..d25cb6113 100644 --- a/tf_adapter/python/npu_bridge/npu_cpu/lru_cache.py +++ b/tf_adapter/python/npu_bridge/npu_cpu/lru_cache.py @@ -2,6 +2,7 @@ from tensorflow.contrib.util import loader from tensorflow.python.framework import load_library from tensorflow.python.framework import ops from tensorflow.python.platform import resource_loader + from npu_bridge.helper import helper gen_npu_cpu_ops = helper.get_gen_ops() -- Gitee From e3f0c506fa734e69299f90b6845af7a668a1f83b Mon Sep 17 00:00:00 2001 From: guopeian Date: Tue, 10 Nov 2020 16:25:44 +0800 Subject: [PATCH 2/2] LruCache python api --- tf_adapter/python/npu_bridge/npu_cpu/lru_cache.py | 1 - 1 file changed, 1 deletion(-) diff --git a/tf_adapter/python/npu_bridge/npu_cpu/lru_cache.py b/tf_adapter/python/npu_bridge/npu_cpu/lru_cache.py index d25cb6113..701c5cf54 100644 --- a/tf_adapter/python/npu_bridge/npu_cpu/lru_cache.py +++ b/tf_adapter/python/npu_bridge/npu_cpu/lru_cache.py @@ -2,7 +2,6 @@ from tensorflow.contrib.util import loader from tensorflow.python.framework import load_library from tensorflow.python.framework import ops from tensorflow.python.platform import resource_loader - from npu_bridge.helper import helper gen_npu_cpu_ops = helper.get_gen_ops() -- Gitee