Coder Social home page Coder Social logo

metagraph-dev / pymlir Goto Github PK

View Code? Open in Web Editor NEW

This project forked from spcl/pymlir

2.0 2.0 5.0 102 KB

Python interface for MLIR - the Multi-Level Intermediate Representation

License: BSD 3-Clause "New" or "Revised" License

Python 95.92% MLIR 4.08%

pymlir's People

Contributors

jim22k avatar joker-eph avatar kaushikcfd avatar paul-tqh-nguyen avatar tbennun avatar

Stargazers

 avatar  avatar

Watchers

 avatar

pymlir's Issues

mlir.astnodes.Function.dump doesn't use the visibility attribute

We currently lose the visibility attribute of "private" when round tripping MLIR input text through PyMLIR in this example:

>>> import mlir
>>> input_string = "func private @resize_pointers(!llvm.ptr<i8>, index, index) -> ()"
>>> mlir.parse_string(input_string).body[0].dump()
'func @resize_pointers(!llvm.ptr< i8 >, index, index) {\n}'
>>> 

Invalid dense constant assignment being parsed.

import mlir

mlir_text = r"""

func @bad_func() -> tensor<8xf32> {
  %0 = constant dense<0.0> : tensor<8xf32> : tensor<8xf32> 
  return %0 : tensor<8xf32>
}

"""

print(mlir_text)

mlir.parse_string(mlir_text)

This should not parse. It does parse.

Ideally, %0 = constant dense<0.0> : tensor<8xf32> : tensor<8xf32> would cause an exception to be raised.

Proximal cause:

Perhaps having this parse is a non-issue since one could argue that it might be syntactically valid (which I'm not sure I agree with) but is semantically invalid.

Generate many tests for PyMLIR

Here's an algorithm to generate tons of tests:

  • For each dialect file found here:
    • For each DialectOp in the dialect file:
      • For each use of a rule from mlir.lark in the DialectOp:
        • Recursively go down the tree for the mlir.lark rule and generate as many examples as possible.
        • See if these examples are accepted by mlir-opt with no passes specified.

This will require an intractable amount of work, so it might not be motivated until MLIR is more stable, but it might be motivated in the future as I suspect the rules in mlir.lark are not as robust or correct as we need it to be.

This might have helped us discover #7 earlier. I suspect that there are similar problems with how standard_attribute is currently defined (either with how it's defined or with how it's used in the dialects currently).

The MLIR docs provide rules for their syntax (e.g. here), and as far as I can tell by my cursory look, these rules describe a context-free language, so using the CFG approach taken so far via lark should in theory work. Perhaps just going down the syntax rules as listed in the MLIR docs could work as a better first step to make sure we have sufficient test coverage of things that should be accepted before we start testing things that should be not accepted.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.