-
Notifications
You must be signed in to change notification settings - Fork 59
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
DaphneDSL: Matrix literals #358
Comments
Thanks for suggesting this, @RetoKrummenacher. This is a great idea (and actually has been on my personal wish list for a while). We'll definitely implement this feature. |
Assigned to @akroviakov. |
@akroviakov: A few hints on the most important points (as discussed today):
|
@pdamme I have a few further questions:
return builder.create<mlir::daphne::MatrixConstantOp>(loc, utils.matrixOf(builder.getIntegerType(64, false)),
static_cast<mlir::Value>(
builder.create<mlir::daphne::ConstantOp>(
loc,
builder.getIntegerAttr(builder.getIntegerType(64, false), reinterpret_cast<uint64_t>(mat)))
)
));
And I'm not sure of its exact origin. What could cause this, was it because I chose to go the "expression of literals" way? |
Hi @akroviakov,
Hope that helps. |
@pdamme Thanks for explanations. Yes, that is the parser rule I used. I was wondering whether the emphasis on matrix literal could mean it to be an explicit literal like:
And thanks for your explanation regarding And the final question: since our rule defines matrix content as |
* DaphneDSL matrix literal - Creates a `DenseMatrix` with shape (nx1) of type `int64_t`, `double` or `bool` inside `DaphneDSLVisitor`. - Usage example: `x = [1, 2, 3]` or `x = [1.1, 2.2, 3.3]` or `x = [true, false, true]`. - Throws error in case of: - - You try to create a matrix with mixed types (e.g., `x = [1, 2.2, 3]`). - - You try to create an empty matrix: can't infer the type. - - You use a not yet defined in `ValueTypeUtils` type (e.g., `const char*`). - A light `bool` type support for `DenseMatrix` is added (for print and reshape kernels). - Closes #358.
Thanks for your PR, @akroviakov. I've just merged it in and left a comment on your final question there. |
Presently, it is not possible to generate a matrix with desired values. Like a magic square with predefined values at desired position. Currently, such a matrix needs to be created with a series of
fill
,cbind
andrbind
operations.There are several possible ways to provide this:
This would be useful for example when solving given small systems of linear equations. Then the matrix can be created directly in DaphneDSL instead of importing it from a file.
The text was updated successfully, but these errors were encountered: