End to end example for MLIR

329 views
Skip to first unread message

john Mattew

unread,
Apr 14, 2020, 2:21:21 PM4/14/20
to ml...@tensorflow.org
Dear MLIR community,

I am new to the MLIR, and I was wondering there is an example of running any model (MNIST, Alex, Resnet,..) on any target such as x86 or ARM?  

I did look at the toy example which seems useful, and I was looking for an example to support the full network.

Kind regards,
John. 


Brehler, Marius

unread,
Apr 15, 2020, 9:19:43 AM4/15/20
to john Mattew, ml...@tensorflow.org

Hi Mattew,

you might want to take a look to IREE, https://github.com/google/iree, which is an MLIR-based end-to-end compiler.

Best,
Marius

--
You received this message because you are subscribed to the Google Groups "MLIR" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mlir+uns...@tensorflow.org.
To view this discussion on the web visit https://groups.google.com/a/tensorflow.org/d/msgid/mlir/CACYt%3Dq0%2BuzND4m%3D2%3DDUykTVQ%2BBAsCf7%3DAjWMufsnWepYkhS%3Dsw%40mail.gmail.com.

Stella Laurenzo

unread,
Apr 15, 2020, 12:40:33 PM4/15/20
to Brehler, Marius, john Mattew, ml...@tensorflow.org
On Wed, Apr 15, 2020 at 6:19 AM Brehler, Marius <marius....@iml.fraunhofer.de> wrote:

Hi Mattew,

you might want to take a look to IREE, https://github.com/google/iree, which is an MLIR-based end-to-end compiler.


(Which desparately needs a "pip install" option still - so build from source only atm.  Also, we are hopefully on a final sprint now to get the stock vision models running (Resnet, Mobilenets, etc)).

Best,
Marius

On 4/14/20 8:21 PM, john Mattew wrote:
Dear MLIR community,

I am new to the MLIR, and I was wondering there is an example of running any model (MNIST, Alex, Resnet,..) on any target such as x86 or ARM?  

I did look at the toy example which seems useful, and I was looking for an example to support the full network.

Kind regards,
John. 


--
You received this message because you are subscribed to the Google Groups "MLIR" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mlir+uns...@tensorflow.org.
To view this discussion on the web visit https://groups.google.com/a/tensorflow.org/d/msgid/mlir/CACYt%3Dq0%2BuzND4m%3D2%3DDUykTVQ%2BBAsCf7%3DAjWMufsnWepYkhS%3Dsw%40mail.gmail.com.

--
You received this message because you are subscribed to the Google Groups "MLIR" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mlir+uns...@tensorflow.org.

john Mattew

unread,
Apr 15, 2020, 4:54:34 PM4/15/20
to Stella Laurenzo, Brehler, Marius, ml...@tensorflow.org
Dear Stella and Brehler,

Thank you very much for the prompt answer. 

Maybe asking resent, or mobilenet running with MLIR too ambiguous. So, I was wondering is there a small example that I can use to run and understand how MLIR dialect and MLIR based compiler works?

IREE seems very interesting, and I will definitely spend some time to familiarize myself with it.  
 
Kind regards,
John. 


Stella Laurenzo

unread,
Apr 15, 2020, 5:06:02 PM4/15/20
to john Mattew, Brehler, Marius, ml...@tensorflow.org
On Wed, Apr 15, 2020 at 1:54 PM john Mattew <johnma...@gmail.com> wrote:
Dear Stella and Brehler,

Thank you very much for the prompt answer. 

Maybe asking resent, or mobilenet running with MLIR too ambiguous. So, I was wondering is there a small example that I can use to run and understand how MLIR dialect and MLIR based compiler works?

I wouldn't say "ambiguous" -- but the IREE work to get these working on CPU/GPU is down to "the last couple of op patterns" right now. It should be any day now to minimally working. Note, however, that we expect substantial time and investment is still required to get to competitive performance. Most of this investment should apply to all MLIR-based tooling, not just IREE.

Here is IREE's basic colab for training a TensorFlow based MNIST model and compiling it for execution (on a vulkan-based GPU in this case, but the LLVM cpu backend should also work): https://github.com/google/iree/blob/master/colab/mnist_tensorflow.ipynb (note that this is not the simplest possible use of the APIs -- it pulls things apart specifically for hackability of the example)

Also, obligatory note: IREE is a specific project that is using and pushing MLIR-technology forward by providing a workflow for ahead-of-time compilation of ML models for small(er)/resource-constrained devices. We're trying to build things in a way that will make us successful in pushing the agenda that IREE has while investing in the core to make other such novel uses equally possible.
 

IREE seems very interesting, and I will definitely spend some time to familiarize myself with it.

Thanks - feel free to engage on IREE's list/discord if you'd like to get involved. 

Yong Wu

unread,
Jan 26, 2021, 7:22:31 PM1/26/21
to MLIR, Stella Laurenzo, marius....@iml.fraunhofer.de, ml...@tensorflow.org, John Mattew
Hi Stella, John,

I am curious about the e2e example too, is there any update now?  

Regards,
Yong

Stella Laurenzo

unread,
Jan 26, 2021, 9:42:09 PM1/26/21
to Yong Wu, marius....@iml.fraunhofer.de, ml...@tensorflow.org, John Mattew
On the IREE side, we have updated our colabs such that they can be directly run on free instances by installing the python wheels: https://github.com/google/iree/tree/main/colab

We have also gotten two training examples running (via Jax and TensorFlow) and are working on API refinements over the next few weeks prior to publishing.

I'm not exactly sure what you are looking for, but we are starting to have a reasonable collection of workloads running.

Yong Wu

unread,
Jan 27, 2021, 1:35:39 AM1/27/21
to MLIR, Stella Laurenzo, marius....@iml.fraunhofer.de, ml...@tensorflow.org, John Mattew, Yong Wu
Thanks Stella for sharing these docs, it helps. 

I am looking for a lowering ("TF graph" -> "MLIR TF" -> "MLIR HLO") example with public model like ResNet.

Best Wishes,
Yong

Brehler, Marius

unread,
Jan 27, 2021, 5:51:08 AM1/27/21
to Yong Wu, MLIR, Stella Laurenzo, John Mattew
Hi Yong,

If you're looking for a lowering of TF to MLIR HLO, you can may want to take a into the scripts we use for EmitC e2e testing, namely:

https://github.com/iml130/mlir-emitc/blob/main/scripts/savedmodel_to_tf_dialect.py
https://github.com/iml130/mlir-emitc/blob/main/scripts/optimize_tf_dialect.py
https://github.com/iml130/mlir-emitc/blob/main/scripts/tf_to_mhlo_dialect.py

Those are executed as part of our e2e pipeline and are closely resembling what's happening in IREE's buildTFImportPassPipeline (https://github.com/google/iree/blob/main/integrations/tensorflow/iree_tf_compiler/Passes.cpp). However, those scripts only rely on an installed TF 2.4, without the need to build TF.

Best, Marius
________________________________________
Von: Yong Wu <yong...@gmail.com>
Gesendet: Mittwoch, 27. Januar 2021 07:35:39
An: MLIR
Cc: Stella Laurenzo; Brehler, Marius; ml...@tensorflow.org; John Mattew; Yong Wu
Betreff: Re: [mlir] End to end example for MLIR

Thanks Stella for sharing these docs, it helps.

I am looking for a lowering ("TF graph" -> "MLIR TF" -> "MLIR HLO") example with public model like ResNet.

Best Wishes,
Yong

On Wednesday, January 27, 2021 at 10:42:09 AM UTC+8 Stella Laurenzo wrote:
On the IREE side, we have updated our colabs such that they can be directly run on free instances by installing the python wheels: https://github.com/google/iree/tree/main/colab

We have also gotten two training examples running (via Jax and TensorFlow) and are working on API refinements over the next few weeks prior to publishing.

I'm not exactly sure what you are looking for, but we are starting to have a reasonable collection<https://google.github.io/iree/tensorflow-coverage> of workloads running.
To view this discussion on the web visit https://groups.google.com/a/tensorflow.org/d/msgid/mlir/CACYt%3Dq0%2BuzND4m%3D2%3DDUykTVQ%2BBAsCf7%3DAjWMufsnWepYkhS%3Dsw%40mail.gmail.com<https://groups.google.com/a/tensorflow.org/d/msgid/mlir/CACYt%3Dq0%2BuzND4m%3D2%3DDUykTVQ%2BBAsCf7%3DAjWMufsnWepYkhS%3Dsw%40mail.gmail.com?utm_medium=email&utm_source=footer>.

--
You received this message because you are subscribed to the Google Groups "MLIR" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mlir+uns...@tensorflow.org.
To view this discussion on the web visit https://groups.google.com/a/tensorflow.org/d/msgid/mlir/16939C45C440C64C8E0991554E2C03701228EBD3%40iml-xc02.iml.fhg.de<https://groups.google.com/a/tensorflow.org/d/msgid/mlir/16939C45C440C64C8E0991554E2C03701228EBD3%40iml-xc02.iml.fhg.de?utm_medium=email&utm_source=footer>.
Reply all
Reply to author
Forward
0 new messages