This PR introduces the implementation of a Kernel Hint Built-In to provide matrix representation hints (Dense or Sparse) in DaphneDSL. The primary aim is to enhance matrix computations by allowing the user to specify whether a matrix should be represented in Dense or CSR (Compressed Sparse Row) format.
Key Highlights:
Implementation in DaphneDSL Built-In: The representation hint feature has been implemented as a Built-In in DaphneDSL. This functionality enables the specification of matrix representation, which can be Dense or Sparse (CSR), during matrix creation.
Canonicalize Method: The hint is realized using the canonicalize method of the RepresentationHintOp. If the matrix’s current representation does not match the desired one, it is adjusted accordingly. The canonicalize method simplifies the operation to ensure the matrix representation is appropriately set.
Source Code Modifications:
src/ir/daphneir/DaphneDialect.cpp: Added the canonicalize method in RepresentationHintOp to adjust matrix types based on the desired representation.
src/ir/daphneir/DaphneOps.td: Defined the new RepresentationHintOp in DaphneDialect for Dense and Sparse representations.
src/parser/daphnedsl/DaphneDSLBuiltins.cpp: Implemented the Built-In functions Dense and CSR that trigger the RepresentationHintOp.
Tests:
Tests for the new matrix representation hints have been added to validate both the Dense and CSR formats. These can be found in the following locations:
This PR introduces the implementation of a Kernel Hint Built-In to provide matrix representation hints (Dense or Sparse) in DaphneDSL. The primary aim is to enhance matrix computations by allowing the user to specify whether a matrix should be represented in Dense or CSR (Compressed Sparse Row) format.
Key Highlights:
Implementation in DaphneDSL Built-In: The representation hint feature has been implemented as a Built-In in DaphneDSL. This functionality enables the specification of matrix representation, which can be Dense or Sparse (CSR), during matrix creation.
Canonicalize Method: The hint is realized using the canonicalize method of the RepresentationHintOp. If the matrix’s current representation does not match the desired one, it is adjusted accordingly. The canonicalize method simplifies the operation to ensure the matrix representation is appropriately set.
Source Code Modifications:
src/ir/daphneir/DaphneDialect.cpp
: Added the canonicalize method in RepresentationHintOp to adjust matrix types based on the desired representation.src/ir/daphneir/DaphneOps.td
: Defined the new RepresentationHintOp in DaphneDialect for Dense and Sparse representations.src/parser/daphnedsl/DaphneDSLBuiltins.cpp
: Implemented the Built-In functions Dense and CSR that trigger the RepresentationHintOp.Tests: Tests for the new matrix representation hints have been added to validate both the Dense and CSR formats. These can be found in the following locations:
test/codegen/rephintop.mlir
test/api/cli/extensibility/rep_op_hint_csr_success_1.daphne
test/api/cli/extensibility/rep_op_hint_dense_success_1.daphne