diff --git a/src/api/python/daphne/context/daphne_context.py b/src/api/python/daphne/context/daphne_context.py index 4ec5924d9..bdc1da66f 100644 --- a/src/api/python/daphne/context/daphne_context.py +++ b/src/api/python/daphne/context/daphne_context.py @@ -96,8 +96,6 @@ def from_numpy(self, mat: np.array, shared_memory=True, verbose=False, return_sh if shared_memory: # Data transfer via shared memory. address = mat.ctypes.data_as(np.ctypeslib.ndpointer(dtype=mat.dtype, ndim=1, flags='C_CONTIGUOUS')).value - upper = (address & 0xFFFFFFFF00000000) >> 32 - lower = (address & 0xFFFFFFFF) # Change the data type, if int16 or uint16 is handed over. # TODO This could change the input DataFrame. @@ -127,7 +125,7 @@ def from_numpy(self, mat: np.array, shared_memory=True, verbose=False, return_sh # TODO Raise an error here? print("unsupported numpy dtype") - res = Matrix(self, 'receiveFromNumpy', [upper, lower, rows, cols, vtc], local_data=mat) + res = Matrix(self, 'receiveFromNumpy', [address, rows, cols, vtc], local_data=mat) else: # Data transfer via a file. data_path_param = "\"" + TMP_PATH + "/{file_name}.csv\"" @@ -201,8 +199,6 @@ def from_pandas(self, df: pd.DataFrame, shared_memory=True, verbose=False, keepI print(f"from_pandas(): original DataFrame column `{column}` (#{idx}) shares memory with new numpy array: {np.shares_memory(mat, df[column].values)}") address = mat.ctypes.data_as(np.ctypeslib.ndpointer(dtype=mat.dtype, ndim=1, flags='C_CONTIGUOUS')).value - upper = (address & 0xFFFFFFFF00000000) >> 32 - lower = (address & 0xFFFFFFFF) d_type = mat.dtype if d_type == np.double or d_type == np.float64: vtc = F64 @@ -223,7 +219,7 @@ def from_pandas(self, df: pd.DataFrame, shared_memory=True, verbose=False, keepI else: raise TypeError(f'Unsupported numpy dtype in column "{column}" ({idx})') - args.append(Matrix(self, 'receiveFromNumpy', [upper, lower, len(mat), 1 , vtc], local_data=mat)) + args.append(Matrix(self, 'receiveFromNumpy', [address, len(mat), 1 , vtc], local_data=mat)) if verbose: print(f"from_pandas(): Python-side execution time for column `{column}` (#{idx}): {(time.time() - col_start_time):.10f} seconds") diff --git a/src/ir/daphneir/DaphneOps.td b/src/ir/daphneir/DaphneOps.td index b2d91310b..2b85c7ed1 100644 --- a/src/ir/daphneir/DaphneOps.td +++ b/src/ir/daphneir/DaphneOps.td @@ -1436,7 +1436,7 @@ def Daphne_WriteOp : Daphne_Op<"write"> { } def Daphne_ReceiveFromNumpyOp: Daphne_Op<"receiveFromNumpy">{ - let arguments = (ins UI32:$upper, UI32:$lower, SI64:$rows, SI64:$cols); + let arguments = (ins UI64: $address, SI64:$rows, SI64:$cols); let results = (outs MatrixOrU:$res); } diff --git a/src/parser/daphnedsl/DaphneDSLBuiltins.cpp b/src/parser/daphnedsl/DaphneDSLBuiltins.cpp index 10208d788..f88405683 100644 --- a/src/parser/daphnedsl/DaphneDSLBuiltins.cpp +++ b/src/parser/daphnedsl/DaphneDSLBuiltins.cpp @@ -1151,13 +1151,12 @@ antlrcpp::Any DaphneDSLBuiltins::build(mlir::Location loc, const std::string &fu return builder.create(loc, arg, filename).getOperation(); } if (func == "receiveFromNumpy") { - checkNumArgsExact(loc, func, numArgs, 5); + checkNumArgsExact(loc, func, numArgs, 4); - mlir::Value upper = utils.castUI32If(args[0]); - mlir::Value lower = utils.castUI32If(args[1]); - mlir::Value rows = args[2]; - mlir::Value cols = args[3]; - mlir::Value valueType = args[4]; + mlir::Value address = utils.castUI64If(args[0]); + mlir::Value rows = args[1]; + mlir::Value cols = args[2]; + mlir::Value valueType = args[3]; int64_t valueTypeCode = CompilerUtils::constantOrThrow( valueType, "the value type code in ReceiveFromNumpyOp must be a constant"); @@ -1185,7 +1184,7 @@ antlrcpp::Any DaphneDSLBuiltins::build(mlir::Location loc, const std::string &fu throw ErrorHandler::compilerError(loc, "DSLBuiltins", "invalid value type code"); return static_cast( - builder.create(loc, utils.matrixOf(vt), upper, lower, rows, cols)); + builder.create(loc, utils.matrixOf(vt), address, rows, cols)); } if (func == "saveDaphneLibResult") { checkNumArgsExact(loc, func, numArgs, 1); diff --git a/src/runtime/local/kernels/ReceiveFromNumpy.h b/src/runtime/local/kernels/ReceiveFromNumpy.h index 2e90f98f5..3d5286c8f 100644 --- a/src/runtime/local/kernels/ReceiveFromNumpy.h +++ b/src/runtime/local/kernels/ReceiveFromNumpy.h @@ -28,7 +28,7 @@ // **************************************************************************** template struct ReceiveFromNumpy { - static void apply(DTRes *&res, uint32_t upper, uint32_t lower, int64_t rows, int64_t cols, DCTX(ctx)) = delete; + static void apply(DTRes *&res, uint64_t address, int64_t rows, int64_t cols, DCTX(ctx)) = delete; }; // **************************************************************************** @@ -36,8 +36,8 @@ template struct ReceiveFromNumpy { // **************************************************************************** template -void receiveFromNumpy(DTRes *&res, uint32_t upper, int32_t lower, int64_t rows, int64_t cols, DCTX(ctx)) { - ReceiveFromNumpy::apply(res, upper, lower, rows, cols, ctx); +void receiveFromNumpy(DTRes *&res, uint64_t address, int64_t rows, int64_t cols, DCTX(ctx)) { + ReceiveFromNumpy::apply(res, address, rows, cols, ctx); } // **************************************************************************** @@ -56,9 +56,9 @@ template struct NoOpDeleter { }; template struct ReceiveFromNumpy> { - static void apply(DenseMatrix *&res, uint32_t upper, uint32_t lower, int64_t rows, int64_t cols, DCTX(ctx)) { + static void apply(DenseMatrix *&res, uint64_t address, int64_t rows, int64_t cols, DCTX(ctx)) { res = DataObjectFactory::create>( - rows, cols, std::shared_ptr((VT *)(((uint64_t)upper << 32) | lower), NoOpDeleter())); + rows, cols, std::shared_ptr((VT *)(address), NoOpDeleter())); } }; diff --git a/src/runtime/local/kernels/kernels.json b/src/runtime/local/kernels/kernels.json index 19597655e..146600d80 100644 --- a/src/runtime/local/kernels/kernels.json +++ b/src/runtime/local/kernels/kernels.json @@ -4182,12 +4182,8 @@ "name": "res" }, { - "type": "uint32_t", - "name": "upper" - }, - { - "type": "uint32_t", - "name": "lower" + "type": "uint64_t", + "name": "address" }, { "type": "int64_t",