def callZooFunc(bigdl_type, name, *args): """ Call API in PythonBigDL """ gateway = _get_gateway() args = [_py2java(gateway, a) for a in args] error = Exception("Cannot find function: %s" % name) for jinvoker in JavaCreator.instance(bigdl_type, gateway).value: # hasattr(jinvoker, name) always return true here, # so you need to invoke the method to check if it exist or not try: api = getattr(jinvoker, name) java_result = api(*args) result = _java2py(gateway, java_result) except Exception as e: error = e if not ("does not exist" in str(e) and "Method {}".format(name) in str(e)): raise e else: return result raise error
def test_save_jtensor_dict(self): tensors = {} tensors["tensor1"] = JTensor.from_ndarray(np.random.rand(3, 2)) tensors["tensor2"] = JTensor.from_ndarray(np.random.rand(3, 2)) # in old impl, this will throw an exception _py2java(self.sc, tensors)
def test_save_jtensor_dict(self): tensors = {} tensors["tensor1"] = JTensor.from_ndarray(np.random.rand(3, 2)) tensors["tensor2"] = JTensor.from_ndarray(np.random.rand(3, 2)) # in old impl, this will throw an exception _py2java(self.sc._gateway, tensors)