Open
Conversation
- Create arith_to_xls.h header with pattern population function - Implement populateArithToXlsPatterns in arith_to_xls.cc - Integrate arith-to-xls pattern application in translation pipeline - Add translate_arith_addf_folding.mlir test for constant folding validation
- Added multiple MLIR test files for arithmetic operations, including `or`, `xor`, `subi`, `muli`, `divsi`, `divui`, `remsi`, `remui`, `shli`, and `shrui` to validate the conversion from MLIR arith dialect to XLS dialect. -streamline the test suite. - Created a new `tensor_ops.mlir` file to test various tensor operations, including empty tensors, inline dense tensors, and tensor extraction. - Deleted unnecessary translation tests for arith - Enhanced the `xls_translate` tool to support tensor operations and dense resource extraction, including zero-initialization for empty tensors. - Updated the translation patterns to handle dense resource elements and added new patterns for resource-backed constants. - Registered the Linalg dialect in the translation tool to support additional operations.
- Add linalg-to-xls pass for converting linalg.generic to arith operations - Support element-wise operations: addf, mulf, subf, cmpf, select - Add automatic xls=true attribute management via add-xls-attributes pass - Integrate with mlir_to_xls_ir build rule for seamless conversion - Clean up test data and remove unsupported complex patterns - Remove example files and build targets for linalg_generic*
…tions - Add LinalgElementwiseToArithPattern supporting multi-input operations with single arithmetic operations - Add LinalgFillToTensorSplatPattern for fill operations - Add LinalgComplexToDslxPattern for complex operations requiring DSLX codegen - Implement input detection that ignores unused inputs in multi-input operations - Support mixed tensor-scalar combinations with automatic scalar-to-tensor conversion - Add test suite in linalg_generic_ops.mlir covering all supported patterns - Clean up and refactor linalg_to_xls.cc removing unnecessary comments and debug code - Add DSLX codegen infrastructure for future complex operation support - Add linalg analysis library for structured operation analysis Pattern priority: - Fill operations (benefit=25): Convert to tensor.splat - Element-wise operations (benefit=20): Convert to arith operations - Complex operations (benefit=10): Route to DSLX codegen Supported operations: - Tensor + Tensor, Tensor + Scalar, Scalar + Tensor - Multi-input with unused inputs (e.g., 3 inputs, only 2 used) - Fill operations with constants - All arithmetic operations: addf, mulf, subf Complex operations (multiple operations, reductions) are routed to DSLX codegen for future implementation.
This commit implements a complete MLIR Linalg-to-XLS transformation pipeline with the following components: Core Analysis: - LinalgGeneric analysis and internal representation - Broadcast analysis for tensor operations - Loop scheduling with ordering, tiling, and unrolling - Unroll planning for multi-dimensional lane operations Code Generation: - DSLX code generation from analyzed Linalg operations - Reduction utilities with serial, tree, and Kahan policies - Lane operations for unrolled loop handling - Region body lowering and evaluation Testing: - Comprehensive test suite covering all components - Broadcast analysis tests (T1-T5) - Schedule generation tests (T1-T7) - Scalar interpreter tests (T1-T6) - Reduction utilities tests - Unroll planning tests - Lane operations tests - DSLX codegen tests Key Features: - Support for 4D tensor operations with mixed indexing - Broadcasting analysis and validation - Multiple reduction policies (serial, tree, Kahan) - Multi-dimensional unrolling with lane planning - DSLX code generation with proper array handling - Zero-initialization and accumulator logic - Comprehensive error handling and validation Architecture: - Modular design with clear separation of concerns - Type-safe internal representations - Extensible reduction and unrolling systems - Clean, well-documented codebase - Full test coverage for all components This implementation provides a solid foundation for transforming MLIR Linalg operations into XLS-compatible DSLX code, enabling high-level tensor operations to be compiled to hardware.
- Add comprehensive LinalgReductionToXlsPattern for reduction operations - Implement full analysis pipeline: LinalgGeneric → BroadcastAnalysis → Schedule → UnrollPlan - Add DSLX code generation with complete end-to-end transformation - Support n-dimensional tensors and unlimited loop scaling - Generate functional DSLX code from complex linalg.generic operations - Include detailed debug output for pipeline validation - Update BUILD files for renamed dslx_codegen components The pipeline now successfully transforms MLIR linalg.generic operations through complete analysis and generates executable DSLX code, supporting complex reduction patterns with n-dimensional tensors and unlimited loop structures. Tested with complex_linalg_example.mlir showing full pipeline execution from 4D tensor analysis to DSLX code generation.
- Fix BuildZeroTensor to generate correct 1D array syntax with ellipsis - Fix GetReturnType to flatten multi-dimensional outputs to 1D arrays - Ensure proper type inference with float32::F32 and type aliases - Generated DSLX now compiles and runs successfully with type_inference_v2 The codegen now produces syntactically correct DSLX that can be interpreted and tested, providing a solid foundation for implementing loop body logic. Signed-off-by: Alireza <alirezazd@gmail.com>
- Delete xls/contrib/mlir/testdata/linalg/ directory and all test files - Delete xls/contrib/mlir/transforms/linalg/analysis/ directory - Clean up old test infrastructure files
- Add LinalgCodegenConfig singleton for global configuration management - Implement EvalLinalgGeneric with broadcast analysis and validation - Add GenerateSchedule with loop ordering policies (kPreserve default) - Add GenerateUnrollPlan with configurable unrolling - Add DslxCodegen with simplified interface for DSLX emission - Consolidate linalg evaluation into flat directory structure - Clean up code style: remove verbose comments, uniformize patterns - Add helper functions and reduction utilities - Support serial reduction policy with no tiling by default
- Implement consistent error handling pattern with detailed error messages - Extract ValidateReduction() and refactor DeriveShapes() for better organization - Reorder LinalgEvalResults fields and update constructor signature - Simplify function names and remove redundant fields - Use std::pair for shapes and improve forward declarations
Remove old/unused files: - dslx_codegen.cc/h (replaced by dslxgen.cc/h) - lane_ops.cc/h (functionality moved elsewhere) - reduction.cc/h (consolidated into main evaluation) - reduction_utils.cc/h (utilities moved to core functions) - unroll_plan_gen.cc/h (unused planning code) These files were cleaned up during the linalg evaluation refactoring.
- Extract schedule-related types to schedule_types.h - Improve error handling consistency in linalg_eval.cc
- Implement DslxGen class for converting Linalg ops to DSLX - Add DSLX statement types with factory methods (MakeLet, MakeFor, MakeUpdate) - Support nested parallel and reduction loops with proper accumulator management - Generate complete DSLX functions with headers, signatures, and loop bodies
- Change input operand names from 'input0/input1' to 'arg0/arg1' to avoid XLS reserved word - Restore testdata BUILD.bazel to match main repository - Delete unused linalg_to_xls.mlir test file
…trix multiplication - Fix floating-point comparison syntax (float32::gt_2 for boolean results) - Add support for cmpf_ogt and select operations in DSLX generation - Implement proper if-then-else syntax for conditional expressions - Add ExtractActualReductionOp to identify primary reduction operations - Support multiplication reductions with correct initialization (F32_ONE) - Fix tensor.splat output validation to allow both 0.0 and 1.0 initialization - Validate reduction operations to only accept add, sub, mul (reject others) - Enhance error messages with LinalgGenericToString for better debugging
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.