def get_async(self, key, value, wait_id=None): """ pull parameter Parameters ---------- key: the uint32 or uint64 key tensor value: The params tensor wait_id: The wait id """ if wait_id is not None: self.wait(wait_id) check_call( LIB.KVTableGetFromLocal(self.handle, key.handle, value.handle)) else: id = ctypes.c_int() check_call( LIB.KVTableGetAsync(self.handle, key.handle, value.handle, ctypes.byref(id))) return id
def add_async(self, key, grad, option={}): """ push grads Parameters ---------- key: the uint32 or uint64 key tensor grad: The param grads """ keys = [] values = [] for key, value in option.iteritems(): keys.append(c_str(key)) values.append(c_str(value)) id = ctypes.c_int() check_call( LIB.KVTableGetAsync(self.handle, key.handle, grad.handle, ctypes.byref(id), c_array(ctypes.c_char_p, keys), c_array(ctypes.c_char_p, values))) return id