Skip to content

fix: stop using hex display when printElementsAttrWithHexIfLarger is …#2

Open
rudy-6-4 wants to merge 8 commits intomainfrom
fix-hex-mlir-display
Open

fix: stop using hex display when printElementsAttrWithHexIfLarger is …#2
rudy-6-4 wants to merge 8 commits intomainfrom
fix-hex-mlir-display

Conversation

@rudy-6-4
Copy link

@rudy-6-4 rudy-6-4 commented Sep 8, 2023

…not set

BourgerieQuentin and others added 8 commits March 12, 2023 19:47
Linalg named operations are currently limited to tensors and memrefs
composed of floating point, integer or complex elements and using any
other element type triggers an assertion.

This change adds support for arbitrary element types through the
specification of the arithmetic operations associated to a type in
specific attributes of a linalg named operation. The attributes' names
correspond to the short form of the arithmetic operator implemented by
the operation (i.e., add, sub, mul, max_signed, max_unsigned,
min_signed, min_unsigned, exp, abs, ceil, negf or log) and receive as
values the name of an operation and optionally a return type given
after a colon.

For example, a `linalg.matmul` operation multiplying two tensors
composed of in would be expressed as:

  linalg.matmul { add = "complex.add", mul = "complex.mul" }
    ins(%arg1, %arg2 : tensor<?x?xcomplex<f32>>, tensor<?x?xcomplex<f32>>)
    outs(%2 : tensor<?x?xcomplex<f32>>)

Sensible default values for the attributes are given for float,
integer and complex types, such that the omission of the attributes
results in the original behavior of the named operation before this
change. I.e., the expression:

  linalg.matmul { add = "arith.addf", mul = "arith.mulf" }
    ins(%arg1, %arg2 : tensor<?x?xf32>, tensor<?x?xf32>)
    outs(%2 : tensor<?x?xf32>)

and:

  linalg.matmul
    ins(%arg1, %arg2 : tensor<?x?xf32>, tensor<?x?xf32>)
    outs(%2 : tensor<?x?xf32>)

yield identical results.

By default, the result type of an operation implementing an arithmetic
operator is assumed to be identical with the type of the first
argument. If this assumption does not hold for an operation, the
result type must be specified explicitly, e.g.,

  linalg.matmul { add = "custom_add_op:restypeadd",
                  mul = "custom_mul_op:restypemul" }
    ins(%arg1, %arg2 : tensor<?x?xcomplex<f32>>, tensor<?x?xcomplex<f32>>)
    outs(%2 : tensor<?x?xcomplex<f32>>)

The extraction of operation names and result types from attributes,
proper instantiation and default values are provided by a set of
operation interfaces (one per operator) in
`LinalgFrontendInterfaces.td`. The set of operation interfaces
required for a named operation is derived transparently from the
arithmetic expressions in its YAML specification via
`mlir-linalg-ods-yaml-gen`.
Copy link
Member

@BourgerieQuentin BourgerieQuentin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's a quite invasive in the upstream project. Could we desactivate it properly from concrete?

@rudy-6-4
Copy link
Author

rudy-6-4 commented Sep 20, 2023

That's a quite invasive in the upstream project. Could we desactivate it properly from concrete?

I have not seen one. But this hard coded default value is making our MLIR not easy to read and probably bigger than needed.

@andidr @antoniupop Is it possible to the llvm AsmPrinterOptions from the Concrete Compiler ?
https://github.com/zama-ai/concrete-compiler-internal-llvm-project/pull/2/files#diff-7e43770186249840f0ec7904e2d5562c796ff993f67250c275a6d7918a95130cL174

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants