Hello,There are broadly two topics that I'm asking about below.1) I was looking at TensorFlow MLIR overview and I couldn't find information documenting the typical layers (dialects and conversions) to go from TF GraphDef into mid-level MLIR forms like the linalg, Affine or SCF dialects. For TF to TF Lite itself, this README.md provides a good high-level summary (although it's difficult to find and not linked from https://www.tensorflow.org/mlir/overview). But for TF through MLIR layers and code generation, there isn't such an overview AFAICS. I've learnt that this is the typical conversion pipeline:GraphDef -> MLIR TF executor -> MLIR TF Control -> MLIR TF (Standard CF) -> MLIR xla_hlo -> MLIR xla_lhlo -> linalg / affine / loops
And each of these conversions has a corresponding pass in tf-mlir-translate or tf-opt (all in tf-opt except the first which is an IR translation) with a description for the cmd line option among numerous other options. Is this all and accurate? I think it would be useful to have a README.md similar to the Lite one at https://github.com/tensorflow/tensorflow/tree/master/tensorflow/compiler/mlir/tensorflow providing a summary, especially to all those who are interested in contributing to the pipeline. Or else there could be a description of these intermediate dialects and conversion passes like there is at mlir.llvm.org (Dialects and Passes) - I guess the ones for TF MLIR aren't auto-generated and so it wouldn't be practical perhaps to maintain separately.
2) On a related note, the tensor compute dialect work/proposal in progress on MLIR's list is on developing something subsuming {xla_hlo, xla_lhlo, linalg}, and linalg is presumably expanding to the left. Given this, a few concrete questions on the roadmap reg. contributing to the larger end-to-end pipeline: would it be useful to invest more in TF to xla_hlo legalization to complete the missing pieces to get say a full model working or are most people just waiting for the "tensor compute dialect" so that the legalization from MLIR TF dialect could be done straight to that dialect when it's close to ready? Currently, linalg and lhlo are in overlapping spaces, and with known / named ops on tensor types, linalg is covering the hlo space as well already. Is there any early work on cloning the tf -> xla_hlo conversion to tf -> tcd/linalg or is that too early?
And finally, are the MLIR TF layers above the tensor compute dialect (TF executor -> TF control -> TF) mostly "design stable" with some parts yet to be implemented? Is there a particular roadmap for those?
--Thanks,Uday
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/e2fc1ffc-46d0-4722-972e-3c3078536c65%40tensorflow.org.
Hey Uday,On Tue, May 12, 2020 at 6:44 AM 'Uday Bondhugula' via MLIR <ml...@tensorflow.org> wrote:Hello,There are broadly two topics that I'm asking about below.1) I was looking at TensorFlow MLIR overview and I couldn't find information documenting the typical layers (dialects and conversions) to go from TF GraphDef into mid-level MLIR forms like the linalg, Affine or SCF dialects. For TF to TF Lite itself, this README.md provides a good high-level summary (although it's difficult to find and not linked from https://www.tensorflow.org/mlir/overview). But for TF through MLIR layers and code generation, there isn't such an overview AFAICS. I've learnt that this is the typical conversion pipeline:GraphDef -> MLIR TF executor -> MLIR TF Control -> MLIR TF (Standard CF) -> MLIR xla_hlo -> MLIR xla_lhlo -> linalg / affine / loopsNote that `MLIR TF Control` is deprecated and mostly unused (I think TFLite still has it in their pipeline but this is just a missing cleanup).
There is also some subtleties around the various HLO dialects, but on a high level picture this is correct.
And each of these conversions has a corresponding pass in tf-mlir-translate or tf-opt (all in tf-opt except the first which is an IR translation) with a description for the cmd line option among numerous other options. Is this all and accurate? I think it would be useful to have a README.md similar to the Lite one at https://github.com/tensorflow/tensorflow/tree/master/tensorflow/compiler/mlir/tensorflow providing a summary, especially to all those who are interested in contributing to the pipeline. Or else there could be a description of these intermediate dialects and conversion passes like there is at mlir.llvm.org (Dialects and Passes) - I guess the ones for TF MLIR aren't auto-generated and so it wouldn't be practical perhaps to maintain separately.These are really good question, and we're really overdue for an update on this: I actually was planning to address this last month but for various reasons it didn't happen (you may notice that I have a slot in the weekly meeting agenda for this).We've been also pivoting a lot since the beginning of 2020 to realign ourselves with respect to TFRT which is our primary runtime target at the moment. So we have actually to document and reorganize many different pipeline depending on the use-case.
2) On a related note, the tensor compute dialect work/proposal in progress on MLIR's list is on developing something subsuming {xla_hlo, xla_lhlo, linalg}, and linalg is presumably expanding to the left. Given this, a few concrete questions on the roadmap reg. contributing to the larger end-to-end pipeline: would it be useful to invest more in TF to xla_hlo legalization to complete the missing pieces to get say a full model working or are most people just waiting for the "tensor compute dialect" so that the legalization from MLIR TF dialect could be done straight to that dialect when it's close to ready? Currently, linalg and lhlo are in overlapping spaces, and with known / named ops on tensor types, linalg is covering the hlo space as well already. Is there any early work on cloning the tf -> xla_hlo conversion to tf -> tcd/linalg or is that too early?Again this is a multi-dimensional problem: for example it may depends on the horizon (next two quarters vs next year) or in terms of product integration (for example LHLO exists for the sole purpose of integrating better with XLA and having a path for incremental migration from XLA to use MLIR).The work on TCP is bootstrapping (IREE folks are mostly leading this right now in https://github.com/google/mlir-npcomp with trying to get to a quick end-to-end flow that can instruct the design.We aren't woking on TF->TCP/Linalg, on the other hand there are other changes in flights around the design of TF/HLO that may impact how we structure this in the future, but this isn't clear enough yet.
And finally, are the MLIR TF layers above the tensor compute dialect (TF executor -> TF control -> TF) mostly "design stable" with some parts yet to be implemented? Is there a particular roadmap for those?(It is TF executor -> TF, without going through control)This is likely the closest we have to be a production pipeline is our TPU XLA bridge, where we run this ahead of time / before execution: https://github.com/tensorflow/tensorflow/blob/master/tensorflow/compiler/mlir/tensorflow/transforms/bridge.cc#L74And then at runtime in a "JIT" mode we continue with this: https://github.com/tensorflow/tensorflow/blob/master/tensorflow/compiler/mlir/tensorflow/utils/compile_mlir_util.cc#L261
Note that the JIT part of the pipeline is using XLA for the backend right now and so relies on the ability to inject shapes at runtime and statically inferred the shapes for the computation.
Best,--Mehdi
Hi Mehdi,
On Wednesday, May 13, 2020 at 3:29:51 AM UTC+5:30, Mehdi AMINI wrote:Hey Uday,On Tue, May 12, 2020 at 6:44 AM 'Uday Bondhugula' via MLIR <ml...@tensorflow.org> wrote:Hello,There are broadly two topics that I'm asking about below.1) I was looking at TensorFlow MLIR overview and I couldn't find information documenting the typical layers (dialects and conversions) to go from TF GraphDef into mid-level MLIR forms like the linalg, Affine or SCF dialects. For TF to TF Lite itself, this README.md provides a good high-level summary (although it's difficult to find and not linked from https://www.tensorflow.org/mlir/overview). But for TF through MLIR layers and code generation, there isn't such an overview AFAICS. I've learnt that this is the typical conversion pipeline:GraphDef -> MLIR TF executor -> MLIR TF Control -> MLIR TF (Standard CF) -> MLIR xla_hlo -> MLIR xla_lhlo -> linalg / affine / loopsNote that `MLIR TF Control` is deprecated and mostly unused (I think TFLite still has it in their pipeline but this is just a missing cleanup).I see - but I can't immediately tell (even from the links below on the TPU XLA bridge) which pass actually finally gets you out of the executor dialect and gets you to the MLIR std TF dialect (while not going through TF control), i.e., the substitute for -tf-executor-to-control-conversion -tf-raise-control-flow.
There is also some subtleties around the various HLO dialects, but on a high level picture this is correct.And each of these conversions has a corresponding pass in tf-mlir-translate or tf-opt (all in tf-opt except the first which is an IR translation) with a description for the cmd line option among numerous other options. Is this all and accurate? I think it would be useful to have a README.md similar to the Lite one at https://github.com/tensorflow/tensorflow/tree/master/tensorflow/compiler/mlir/tensorflow providing a summary, especially to all those who are interested in contributing to the pipeline. Or else there could be a description of these intermediate dialects and conversion passes like there is at mlir.llvm.org (Dialects and Passes) - I guess the ones for TF MLIR aren't auto-generated and so it wouldn't be practical perhaps to maintain separately.These are really good question, and we're really overdue for an update on this: I actually was planning to address this last month but for various reasons it didn't happen (you may notice that I have a slot in the weekly meeting agenda for this).We've been also pivoting a lot since the beginning of 2020 to realign ourselves with respect to TFRT which is our primary runtime target at the moment. So we have actually to document and reorganize many different pipeline depending on the use-case.Thanks - this would really help!2) On a related note, the tensor compute dialect work/proposal in progress on MLIR's list is on developing something subsuming {xla_hlo, xla_lhlo, linalg}, and linalg is presumably expanding to the left. Given this, a few concrete questions on the roadmap reg. contributing to the larger end-to-end pipeline: would it be useful to invest more in TF to xla_hlo legalization to complete the missing pieces to get say a full model working or are most people just waiting for the "tensor compute dialect" so that the legalization from MLIR TF dialect could be done straight to that dialect when it's close to ready? Currently, linalg and lhlo are in overlapping spaces, and with known / named ops on tensor types, linalg is covering the hlo space as well already. Is there any early work on cloning the tf -> xla_hlo conversion to tf -> tcd/linalg or is that too early?Again this is a multi-dimensional problem: for example it may depends on the horizon (next two quarters vs next year) or in terms of product integration (for example LHLO exists for the sole purpose of integrating better with XLA and having a path for incremental migration from XLA to use MLIR).The work on TCP is bootstrapping (IREE folks are mostly leading this right now in https://github.com/google/mlir-npcomp with trying to get to a quick end-to-end flow that can instruct the design.We aren't woking on TF->TCP/Linalg, on the other hand there are other changes in flights around the design of TF/HLO that may impact how we structure this in the future, but this isn't clear enough yet.And finally, are the MLIR TF layers above the tensor compute dialect (TF executor -> TF control -> TF) mostly "design stable" with some parts yet to be implemented? Is there a particular roadmap for those?(It is TF executor -> TF, without going through control)This is likely the closest we have to be a production pipeline is our TPU XLA bridge, where we run this ahead of time / before execution: https://github.com/tensorflow/tensorflow/blob/master/tensorflow/compiler/mlir/tensorflow/transforms/bridge.cc#L74And then at runtime in a "JIT" mode we continue with this: https://github.com/tensorflow/tensorflow/blob/master/tensorflow/compiler/mlir/tensorflow/utils/compile_mlir_util.cc#L261Thanks - these are very useful references. For the TF to TPU XLA bridge, I couldn't still immediately tell from the code what the substitute for the TF executor -> TF control -> TF is, i.e., where exactly you were getting out of the TF executor dialect and into the TF dialect. (Minor: the doc comment on CreateTPUBridgePipeline is missing its second line.) And CompileSerializedMlirToXlaHlo's precondition is that its input is in the TF dialect already (although potentially with TF's control flow model). So, I'm missing a reference for the middle step.Note that the JIT part of the pipeline is using XLA for the backend right now and so relies on the ability to inject shapes at runtime and statically inferred the shapes for the computation.Thanks.- UdayBest,--Mehdi
--
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/53dd7620-75ac-41b5-a017-df9525d1918e%40tensorflow.org.
On Tue, May 12, 2020 at 6:44 AM 'Uday Bondhugula' via MLIR <ml...@tensorflow.org> wrote:Hello,There are broadly two topics that I'm asking about below.1) I was looking at TensorFlow MLIR overview and I couldn't find information documenting the typical layers (dialects and conversions) to go from TF GraphDef into mid-level MLIR forms like the linalg, Affine or SCF dialects. For TF to TF Lite itself, this README.md provides a good high-level summary (although it's difficult to find and not linked from https://www.tensorflow.org/mlir/overview). But for TF through MLIR layers and code generation, there isn't such an overview AFAICS. I've learnt that this is the typical conversion pipeline:GraphDef -> MLIR TF executor -> MLIR TF Control -> MLIR TF (Standard CF) -> MLIR xla_hlo -> MLIR xla_lhlo -> linalg / affine / loopsAnd each of these conversions has a corresponding pass in tf-mlir-translate or tf-opt (all in tf-opt except the first which is an IR translation) with a description for the cmd line option among numerous other options. Is this all and accurate? I think it would be useful to have a README.md similar to the Lite one at https://github.com/tensorflow/tensorflow/tree/master/tensorflow/compiler/mlir/tensorflow providing a summary, especially to all those who are interested in contributing to the pipeline. Or else there could be a description of these intermediate dialects and conversion passes like there is at mlir.llvm.org (Dialects and Passes) - I guess the ones for TF MLIR aren't auto-generated and so it wouldn't be practical perhaps to maintain separately.2) On a related note, the tensor compute dialect work/proposal in progress on MLIR's list is on developing something subsuming {xla_hlo, xla_lhlo, linalg}, and linalg is presumably expanding to the left. Given this, a few concrete questions on the roadmap reg. contributing to the larger end-to-end pipeline: would it be useful to invest more in TF to xla_hlo legalization to complete the missing pieces to get say a full model working or are most people just waiting for the "tensor compute dialect" so that the legalization from MLIR TF dialect could be done straight to that dialect when it's close to ready? Currently, linalg and lhlo are in overlapping spaces, and with known / named ops on tensor types, linalg is covering the hlo space as well already. Is there any early work on cloning the tf -> xla_hlo conversion to tf -> tcd/linalg or is that too early? And finally, are the MLIR TF layers above the tensor compute dialect (TF executor -> TF control -> TF) mostly "design stable" with some parts yet to be implemented? Is there a particular roadmap for those?Hi Uday!There is so much history in the TF/XLA ecosystem that it is hard to parse through. In addition, we have two compilation flows currently:
- TF->xla_hlo->IREE Flow->LinAlg->... (in use by IREE)
- TF->xla_hlo->xla_lhlo->... (in use by more traditional TF backends)
We ultimately believe that much of this can be rebased on a high level TCP abstraction, and we've found it valuable to start working on that as part of the npcomp scale model, focusing on extracting the patterns to bridge the various layers that have grown in the IREE and traditional TF side into an independent place that we can look at and evaluate how to evolve/upstream/etc. We'd like to see more convergence and upstreaming of the frontend layers, which is why we (IREE-team) are building out the npcomp prototype to aggregate the necessary pieces in preparation for concrete design discussions and upstreaming. +Sean Silva who is working on this in the mlir-npcomp repo.
In addition to this, we are continuing to push on the TF->XLA path, and it is mature enough to be handling some fairly non trivial models. Here is IREE's HLO op coverage for various backends (all exercising the HLO->LinAlg path): https://google.github.io/iree/HLOOpCoverage. We don't have a corresponding list of supported TF ops published yet, but we do have our model level
coverage annotated in the IREE's TensorFlow tests build file. Most models we care about are in the frustrating space of needing "one or two more op variants", but notably ResNet50 and MobileNet are compiling/running via both LLVM/CPU and Vulkan-SPIRV codegen paths. There are also a handful of models we track privately (mainly sequence and various audio models). Notably on the IREE side right now, these are (almost) exclusively forward-pass (inference) only, and we need to expand our inventory to include loss functions. We largely consider the TF->XLA path to be "design stable" for static shapes. Most of the work we are putting into it is either related to extending op coverage or generalizing things to have some support for dynamic shapes.
--Thanks,Uday
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 ml...@tensorflow.org.
Hi Stella,Thank you responding in detail. Some questions below.On Wednesday, May 13, 2020 at 4:02:51 AM UTC+5:30, Stella Laurenzo wrote:On Tue, May 12, 2020 at 6:44 AM 'Uday Bondhugula' via MLIR <ml...@tensorflow.org> wrote:Hello,There are broadly two topics that I'm asking about below.1) I was looking at TensorFlow MLIR overview and I couldn't find information documenting the typical layers (dialects and conversions) to go from TF GraphDef into mid-level MLIR forms like the linalg, Affine or SCF dialects. For TF to TF Lite itself, this README.md provides a good high-level summary (although it's difficult to find and not linked from https://www.tensorflow.org/mlir/overview). But for TF through MLIR layers and code generation, there isn't such an overview AFAICS. I've learnt that this is the typical conversion pipeline:GraphDef -> MLIR TF executor -> MLIR TF Control -> MLIR TF (Standard CF) -> MLIR xla_hlo -> MLIR xla_lhlo -> linalg / affine / loopsAnd each of these conversions has a corresponding pass in tf-mlir-translate or tf-opt (all in tf-opt except the first which is an IR translation) with a description for the cmd line option among numerous other options. Is this all and accurate? I think it would be useful to have a README.md similar to the Lite one at https://github.com/tensorflow/tensorflow/tree/master/tensorflow/compiler/mlir/tensorflow providing a summary, especially to all those who are interested in contributing to the pipeline. Or else there could be a description of these intermediate dialects and conversion passes like there is at mlir.llvm.org (Dialects and Passes) - I guess the ones for TF MLIR aren't auto-generated and so it wouldn't be practical perhaps to maintain separately.2) On a related note, the tensor compute dialect work/proposal in progress on MLIR's list is on developing something subsuming {xla_hlo, xla_lhlo, linalg}, and linalg is presumably expanding to the left. Given this, a few concrete questions on the roadmap reg. contributing to the larger end-to-end pipeline: would it be useful to invest more in TF to xla_hlo legalization to complete the missing pieces to get say a full model working or are most people just waiting for the "tensor compute dialect" so that the legalization from MLIR TF dialect could be done straight to that dialect when it's close to ready? Currently, linalg and lhlo are in overlapping spaces, and with known / named ops on tensor types, linalg is covering the hlo space as well already. Is there any early work on cloning the tf -> xla_hlo conversion to tf -> tcd/linalg or is that too early? And finally, are the MLIR TF layers above the tensor compute dialect (TF executor -> TF control -> TF) mostly "design stable" with some parts yet to be implemented? Is there a particular roadmap for those?Hi Uday!There is so much history in the TF/XLA ecosystem that it is hard to parse through. In addition, we have two compilation flows currently:
- TF->xla_hlo->IREE Flow->LinAlg->... (in use by IREE)
The nodes in my chain above were intended to be dialects. The above would look like <IREE flow> is replacing the conversion through lhlo with things that will hopefully get into the tensor compute dialect and merged with LinAlg? By "IREE flow", did you mean conversions or new op abstractions? I should check the code, but you perhaps meant a single conversion pass (but no new ops / dialect there).
- TF->xla_hlo->xla_lhlo->... (in use by more traditional TF backends)
We ultimately believe that much of this can be rebased on a high level TCP abstraction, and we've found it valuable to start working on that as part of the npcomp scale model, focusing on extracting the patterns to bridge the various layers that have grown in the IREE and traditional TF side into an independent place that we can look at and evaluate how to evolve/upstream/etc. We'd like to see more convergence and upstreaming of the frontend layers, which is why we (IREE-team) are building out the npcomp prototype to aggregate the necessary pieces in preparation for concrete design discussions and upstreaming. +Sean Silva who is working on this in the mlir-npcomp repo.This would be great and npcomp could also serve as an excellent reference for an end-to-end implementation of a user facing programming model - perhaps the first as well.
In addition to this, we are continuing to push on the TF->XLA path, and it is mature enough to be handling some fairly non trivial models. Here is IREE's HLO op coverage for various backends (all exercising the HLO->LinAlg path): https://google.github.io/iree/HLOOpCoverage. We don't have a corresponding list of supported TF ops published yet, but we do have our model levelThanks, this is useful. Perhaps this is what contributors should look for in the short term (my original question on what to use to get to mid-level forms of MLIR) - if you have great coverage for HLO to LinAlg already and this will perhaps evolve into the conversion into tensor compute, it probably makes sense for contributors to invest here. From LinAlg, there is already a path into Affine/SCF to go further without any uncertainty.
coverage annotated in the IREE's TensorFlow tests build file. Most models we care about are in the frustrating space of needing "one or two more op variants", but notably ResNet50 and MobileNet are compiling/running via both LLVM/CPU and Vulkan-SPIRV codegen paths. There are also a handful of models we track privately (mainly sequence and various audio models). Notably on the IREE side right now, these are (almost) exclusively forward-pass (inference) only, and we need to expand our inventory to include loss functions. We largely consider the TF->XLA path to be "design stable" for static shapes. Most of the work we are putting into it is either related to extending op coverage or generalizing things to have some support for dynamic shapes.Thanks very much - this is exactly what I was looking for! Very useful to know and really nice that you have those models working end-to-end. Has there been any thought of having such end-to-end tests in the MLIR-TensorFlow repo itself? Everything that's needed for LLVM/CPU path is already being linked in (tf-opt has everything through the MLIR LLVM dialect).
--- Uday--Thanks,Uday
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 ml...@tensorflow.org.
To view this discussion on the web visit https://groups.google.com/a/tensorflow.org/d/msgid/mlir/e2fc1ffc-46d0-4722-972e-3c3078536c65%40tensorflow.org.
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/c4963917-8e41-4aef-9523-602c787762be%40tensorflow.org.
On Tue, May 12, 2020 at 10:27 PM 'Uday Bondhugula' via MLIR <ml...@tensorflow.org> wrote:Hi Mehdi,
On Wednesday, May 13, 2020 at 3:29:51 AM UTC+5:30, Mehdi AMINI wrote:Hey Uday,On Tue, May 12, 2020 at 6:44 AM 'Uday Bondhugula' via MLIR <ml...@tensorflow.org> wrote:Hello,There are broadly two topics that I'm asking about below.1) I was looking at TensorFlow MLIR overview and I couldn't find information documenting the typical layers (dialects and conversions) to go from TF GraphDef into mid-level MLIR forms like the linalg, Affine or SCF dialects. For TF to TF Lite itself, this README.md provides a good high-level summary (although it's difficult to find and not linked from https://www.tensorflow.org/mlir/overview). But for TF through MLIR layers and code generation, there isn't such an overview AFAICS. I've learnt that this is the typical conversion pipeline:GraphDef -> MLIR TF executor -> MLIR TF Control -> MLIR TF (Standard CF) -> MLIR xla_hlo -> MLIR xla_lhlo -> linalg / affine / loopsNote that `MLIR TF Control` is deprecated and mostly unused (I think TFLite still has it in their pipeline but this is just a missing cleanup).I see - but I can't immediately tell (even from the links below on the TPU XLA bridge) which pass actually finally gets you out of the executor dialect and gets you to the MLIR std TF dialect (while not going through TF control), i.e., the substitute for -tf-executor-to-control-conversion -tf-raise-control-flow.This is the combination of `-tf-executor-island-coarsening -canonicalize`
To view this discussion on the web visit https://groups.google.com/a/tensorflow.org/d/msgid/mlir/c4963917-8e41-4aef-9523-602c787762be%40tensorflow.org.
Right now, I would interpret our work here to be a pretty decent proxy to indicate that quite a bit is working through the tf2xla bridge and fairly standard MLIR-based tooling. The next points of high level evolution of the representations will likely come from TCP and our npcomp experiments, and that will lead to some reshuffling of the component boundaries. And of course, all of this is dependent on us collectively achieving the performance metrics that get us to a point of viability.
--- Uday--Thanks,Uday
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 ml...@tensorflow.org.
To view this discussion on the web visit https://groups.google.com/a/tensorflow.org/d/msgid/mlir/e2fc1ffc-46d0-4722-972e-3c3078536c65%40tensorflow.org.
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 ml...@tensorflow.org.
To view this discussion on the web visit https://groups.google.com/a/tensorflow.org/d/msgid/mlir/c4963917-8e41-4aef-9523-602c787762be%40tensorflow.org.
--- UdayRight now, I would interpret our work here to be a pretty decent proxy to indicate that quite a bit is working through the tf2xla bridge and fairly standard MLIR-based tooling. The next points of high level evolution of the representations will likely come from TCP and our npcomp experiments, and that will lead to some reshuffling of the component boundaries. And of course, all of this is dependent on us collectively achieving the performance metrics that get us to a point of viability.--- Uday--Thanks,Uday
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 ml...@tensorflow.org.
To view this discussion on the web visit https://groups.google.com/a/tensorflow.org/d/msgid/mlir/e2fc1ffc-46d0-4722-972e-3c3078536c65%40tensorflow.org.
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 ml...@tensorflow.org.
To view this discussion on the web visit https://groups.google.com/a/tensorflow.org/d/msgid/mlir/c4963917-8e41-4aef-9523-602c787762be%40tensorflow.org.
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/dff4db69-8698-419e-b1d6-19f54a5d21d5%40tensorflow.org.
On 21/05/2020 10:05, Stella Laurenzo wrote:
> Leaving aside the above, I believe this is what you are looking for:
> https://github.com/tensorflow/tensorflow/blob/master/tensorflow/compiler/mlir/xla/transforms/xla_legalize_to_linalg.cc
Right - this is clearly a good place to seek contributions in the
interim for those not wanting to depend on three things. The link you
provided earlier https://google.github.io/iree/HLOOpCoverage shows great
HLO op coverage via IREE, but this coverage for HLO/LHLO to Linalg or
even LHLO to Affine is really small in comparison (pretty much pointwise).
https://github.com/tensorflow/tensorflow/blob/203c1de5a4e54079304f154eee1745e6ee3eb3b2/tensorflow/compiler/mlir/xla/transforms/xla_legalize_to_linalg.cc#L645
On the other hand, with the IREE part covering almost everything and is
converting from xla_hlo into linalg:
https://github.com/google/iree/blob/bb44cf05aaf761cf46c1556ce05cd79bc8a88eb0/iree/compiler/Conversion/HLOToLinalg/HLOToLinalgOnBuffers.cpp#L336
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/64e98284-2447-c23f-5ca4-3f41133da343%40iisc.ac.in.
Is there a concern on how frequently the MLIR dependency is updated on
TensorFlow vis-a-vis IREE (with the latter using something much closer
to the MLIR tip)? But this looks clearly outweighed by the other
considerations.
On Wed, May 20, 2020 at 10:07 PM 'Uday R Bondhugula' via MLIR <ml...@tensorflow.org> wrote:
On 21/05/2020 10:05, Stella Laurenzo wrote:
> Leaving aside the above, I believe this is what you are looking for:
> https://github.com/tensorflow/tensorflow/blob/master/tensorflow/compiler/mlir/xla/transforms/xla_legalize_to_linalg.cc
Right - this is clearly a good place to seek contributions in the
interim for those not wanting to depend on three things. The link you
provided earlier https://google.github.io/iree/HLOOpCoverage shows great
HLO op coverage via IREE, but this coverage for HLO/LHLO to Linalg or
even LHLO to Affine is really small in comparison (pretty much pointwise).
https://github.com/tensorflow/tensorflow/blob/203c1de5a4e54079304f154eee1745e6ee3eb3b2/tensorflow/compiler/mlir/xla/transforms/xla_legalize_to_linalg.cc#L645
On the other hand, with the IREE part covering almost everything and is
converting from xla_hlo into linalg:
https://github.com/google/iree/blob/bb44cf05aaf761cf46c1556ce05cd79bc8a88eb0/iree/compiler/Conversion/HLOToLinalg/HLOToLinalgOnBuffers.cpp#L336
This is mostly an intermediate solution till we can have a more robust solution in core. As an example,- xla_hlo.reduce is lowered to a linalg.indexed_generic op to handle the initialization value.- it might be better to convert xla_hlo.pad operation to a linalg.pad operation in the long-term.- The lowering of xla_hlo.reduce_window to linalg.pool* operations is an example of the experimentation. We were planning to lower these to linalg.indexed_generic as well, but later decided to add pooling operations since it seemed like the right approach for linalg. But here too, we havent really worked out how to handle padding (and if it even makes sense to handle it in the op itself or to have a separate pad operation as mentioned above).Once we have a better idea of how these ops can be lowered and fused effectively, we plan to move them out of IREE into either Tensorflow HLO -> Linalg conversion, or MLIR core.
To view this discussion on the web visit https://groups.google.com/a/tensorflow.org/d/msgid/mlir/CAArwm2Y2W8%3DfUJmMFXXnTY11YzSBbAvDu3W5z-ZimKjJcg8C-Q%40mail.gmail.com.
On Wed, May 20, 2020 at 10:32 PM 'Mahesh Ravishankar' via MLIR <ml...@tensorflow.org> wrote:On Wed, May 20, 2020 at 10:07 PM 'Uday R Bondhugula' via MLIR <ml...@tensorflow.org> wrote:
On 21/05/2020 10:05, Stella Laurenzo wrote:
> Leaving aside the above, I believe this is what you are looking for:
> https://github.com/tensorflow/tensorflow/blob/master/tensorflow/compiler/mlir/xla/transforms/xla_legalize_to_linalg.cc
Right - this is clearly a good place to seek contributions in the
interim for those not wanting to depend on three things. The link you
provided earlier https://google.github.io/iree/HLOOpCoverage shows great
HLO op coverage via IREE, but this coverage for HLO/LHLO to Linalg or
even LHLO to Affine is really small in comparison (pretty much pointwise).
https://github.com/tensorflow/tensorflow/blob/203c1de5a4e54079304f154eee1745e6ee3eb3b2/tensorflow/compiler/mlir/xla/transforms/xla_legalize_to_linalg.cc#L645
On the other hand, with the IREE part covering almost everything and is
converting from xla_hlo into linalg:
https://github.com/google/iree/blob/bb44cf05aaf761cf46c1556ce05cd79bc8a88eb0/iree/compiler/Conversion/HLOToLinalg/HLOToLinalgOnBuffers.cpp#L336
This is mostly an intermediate solution till we can have a more robust solution in core. As an example,- xla_hlo.reduce is lowered to a linalg.indexed_generic op to handle the initialization value.- it might be better to convert xla_hlo.pad operation to a linalg.pad operation in the long-term.- The lowering of xla_hlo.reduce_window to linalg.pool* operations is an example of the experimentation. We were planning to lower these to linalg.indexed_generic as well, but later decided to add pooling operations since it seemed like the right approach for linalg. But here too, we havent really worked out how to handle padding (and if it even makes sense to handle it in the op itself or to have a separate pad operation as mentioned above).Once we have a better idea of how these ops can be lowered and fused effectively, we plan to move them out of IREE into either Tensorflow HLO -> Linalg conversion, or MLIR core.HLO conversion can’t be in Core as there is a dependency on TF.I am with Uday here, I don’t understand why these haven’t been developed in TF in the first place?
On Thu, May 21, 2020 at 8:49 AM Mehdi AMINI <joke...@gmail.com> wrote:On Wed, May 20, 2020 at 10:32 PM 'Mahesh Ravishankar' via MLIR <ml...@tensorflow.org> wrote:On Wed, May 20, 2020 at 10:07 PM 'Uday R Bondhugula' via MLIR <ml...@tensorflow.org> wrote:
On 21/05/2020 10:05, Stella Laurenzo wrote:
> Leaving aside the above, I believe this is what you are looking for:
> https://github.com/tensorflow/tensorflow/blob/master/tensorflow/compiler/mlir/xla/transforms/xla_legalize_to_linalg.cc
Right - this is clearly a good place to seek contributions in the
interim for those not wanting to depend on three things. The link you
provided earlier https://google.github.io/iree/HLOOpCoverage shows great
HLO op coverage via IREE, but this coverage for HLO/LHLO to Linalg or
even LHLO to Affine is really small in comparison (pretty much pointwise).
https://github.com/tensorflow/tensorflow/blob/203c1de5a4e54079304f154eee1745e6ee3eb3b2/tensorflow/compiler/mlir/xla/transforms/xla_legalize_to_linalg.cc#L645
On the other hand, with the IREE part covering almost everything and is
converting from xla_hlo into linalg:
https://github.com/google/iree/blob/bb44cf05aaf761cf46c1556ce05cd79bc8a88eb0/iree/compiler/Conversion/HLOToLinalg/HLOToLinalgOnBuffers.cpp#L336
This is mostly an intermediate solution till we can have a more robust solution in core. As an example,- xla_hlo.reduce is lowered to a linalg.indexed_generic op to handle the initialization value.- it might be better to convert xla_hlo.pad operation to a linalg.pad operation in the long-term.- The lowering of xla_hlo.reduce_window to linalg.pool* operations is an example of the experimentation. We were planning to lower these to linalg.indexed_generic as well, but later decided to add pooling operations since it seemed like the right approach for linalg. But here too, we havent really worked out how to handle padding (and if it even makes sense to handle it in the op itself or to have a separate pad operation as mentioned above).Once we have a better idea of how these ops can be lowered and fused effectively, we plan to move them out of IREE into either Tensorflow HLO -> Linalg conversion, or MLIR core.HLO conversion can’t be in Core as there is a dependency on TF.I am with Uday here, I don’t understand why these haven’t been developed in TF in the first place?
- UdayMost of it has. What remains in IREE either has a) an IREE dependency that can not yet be represented in either upstream repo, or b) was more intertwined in the recent past and just hasn't been moved yet. If there are specific things left in IREE's HLOToLinAlg tree which don't depend on IREE dialects and are useful in the TensorFlow tree, then they can be moved.—Mehdi
--
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/d3973111-397c-45ba-b3bd-4b67b9bb79b5%40tensorflow.org.
HLO conversion can’t be in Core as there is a dependency on TF.I am with Uday here, I don’t understand why these haven’t been developed in TF in the first place?These are lowered from HLO to Linalg on buffers, which is valid to do within IREE due to IREE's architecture. There is a question of buffer allocation that has been solved in IREE before codegen. IIUC in TF the plan is to use XLA-HLO to XLA-LHLO to Linalg on buffers (using XLA's machinery).We dont plan to use LHLO in IREE. Maybe some, if not all of this code can be made to work for both IREE and XLA (just like pointwise ops exist today). We can move things into TF (or some repo that has HLO dialect).I still don't see the reasoning that this has to stay outside because it is evolving or is taking a shortcut as far as the conversion goes. The key point is that the TF tree itself doesn't have an alternative for this missing stuff: both of your ends are in TF/MLIR proper, and the bridge between the two is outside TF! (note the vast difference in op coverage via IREE vs in TF proper). I'm afraid this would only delay or hurt both adoption and contributions because one'd have to look at three repositories here. There are several dialects that are already evolving and improving their lowering paths while being in MLIR in-tree - IMO that needn't be the reason to keep the conversions out because AFAIK there is no alternate competing path in tree nor any proposal to build such (I'm referring to HLO to LinAlg and thus from TF to mid-level forms). But I saw at least a couple of requests on discourse asking for an end-to-end reference path - so there are definitely folks waiting to use and contribute. And for the conversions part, external folks contributing to them while they are in IREE is often a stretch and doesn't look practical - it's a big level of indirection when the original thing being looked at is TF and MLIR.Uday, I don't disagree with the criticism, and I suspect that there is not an answer that will satisfy you in the short term. *I* am also frustrated by the lack of a complete story in TensorFlow itself, but being aware of some of the directions being pursued am possibly willing to extend more credit towards progress being made to getting out of this current transient state."Simply" moving IREE into TensorFlow is not in the cards for a lot reasons, both technical and non-technical. Were we to do so, it may help with some narrow, near term friction to clone and make progress on certain parts, but it comes at a pretty massive cost in terms of needing to conform to the build and dependency limitations of the TensorFlow monorepo, neither of which is conducive to either cross platform development nor external parties taking a dependency on it. Whether we agree or disagree on those points, they are important enough to IREE that we are looking to more structural changes to the TensorFlow monorepo versus dropping an entirely separate and independently buildable project into it. With that said, when the design and layering allows, we extend components directly in the TensorFlow monorepo (versus forking, etc).Consider that repository management is an evolving topic, and that, as illustrated by both the TFRT, IREE (and others), it is considered valuable to progress towards the (painful) path of decoupling components of the monorepo. The bug here is that the current state is not coherent -- not that meaningful components are being developed outside of the monorepo. I'm not going to deny, either, that the birth and history of this stuff was chaotic and unplanned: the IREE team historically was completely disjoint from TensorFlow, interacting primarily as a contributor with the value of being a first-class community member *using* both LLVM and TensorFlow technology to target resource constrained devices. Along the way, we built and contributed the HLO dialect/tools itself, the TensorFlow MLIR-SavedModel infrastructure, much of LinAlg, much of MLIR-SPIRV, a significant amount of the HLO support for dynamic shapes and a significant amount of the MLIR-tf2xla bridge. At each step, when faced with the decision to upstream something that was a clear win and where consensus on the design was feasible, we did so and continue to do so. However, conversely, when we were able to converge on a design point locally that did not have a solution upstream, we built locally to prove the concept and kept moving forward, often continuing the underlying design discussions along the way.The result, in the present day, is a mismatch on some specific maturity levels of components. It is no coincidence that the mismatches are specifically around design points that tend to differ a lot between large-scale and resource-constrained systems (i.e. buffer/memory management, approaches to fusion, concurrency modeling, etc). I can assure you that work is happening on both sides to converge to similar capability levels at these different scales.
So again, if you see specific things in the codebases that can be isolated and moved, patches are welcome: we do prioritize upstreaming such things but are sometimes lazy about it for one reason or another. Regarding collaboration on specific plans to have upstream TensorFlow emerge as a good e2e vehicle for the kind of development you are looking to do, I will need to defer to my TensorFlow colleagues.
- Uday
--
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/2c3682e8-eb62-4d4f-a9f0-95a366d10635%40tensorflow.org.
, which is valid to do within IREE due to IREE's architecture.
There is a question of buffer allocation that has been solved in IREE before codegen. IIUC in TF the plan is to use XLA-HLO to XLA-LHLO to Linalg on buffers (using XLA's machinery).We dont plan to use LHLO in IREE. Maybe some, if not all of this code can be made to work for both IREE and XLA (just like pointwise ops exist today). We can move things into TF (or some repo that has HLO dialect).
, which is valid to do within IREE due to IREE's architecture.As long as you can have a lowering path from LinAlg on tensors to something down, what is specific to IREE?There is a question of buffer allocation that has been solved in IREE before codegen. IIUC in TF the plan is to use XLA-HLO to XLA-LHLO to Linalg on buffers (using XLA's machinery).We dont plan to use LHLO in IREE. Maybe some, if not all of this code can be made to work for both IREE and XLA (just like pointwise ops exist today). We can move things into TF (or some repo that has HLO dialect).You seem to assume that because we have LHLO, we can't or won't use HLO-> "Linalg on Tensor" in any of the TF-ecosystem codegen-related project? This does not seem obvious to me though.
--
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/5b9f4f19-a236-404f-87cf-27129d98ec0e%40tensorflow.org.
HLO conversion can’t be in Core as there is a dependency on TF.I am with Uday here, I don’t understand why these haven’t been developed in TF in the first place?These are lowered from HLO to Linalg on buffersYou mean "Linalg on tensors" here I believe.No I mean HLO to Linalg on buffers. There are some operations (like matmul, conv, anything with reduction iterator types etc.) that cannot be lowered to Linalg on tensors right now. To be able to handle these HLO ops, we convert them to Linalg on buffers. We can do this within IREE cause we put them in their own dispatch regions. Since IREE allocates buffers for the inputs and outputs of the dispatch region, this conversion is possible. The ops that are converted from HLO to Linalg on buffers directly this way are the only ones in IREE. The conversion of XLA-HLO to Linalg on tensors is already in TF tree (and used in IREE).P.S. : We are aware of the phase ordering issue in IREE. Ideally we want to convert from XLA-HLO to Linalg on tensors, perform fusion and then create dispatch regions with each linalg op/remaining xla op in its own dispatch region. This patch is one step to start evaluating this, along with Linalg fusion on tensors that is also in core and these patches (here, here) should help this effort. This approach should work for TF as well, but I have to really see how that plays out. We havent really pushed on this in IREE yet cause we are currently focussing on things downstream in compilation first., which is valid to do within IREE due to IREE's architecture.As long as you can have a lowering path from LinAlg on tensors to something down, what is specific to IREE?There is a question of buffer allocation that has been solved in IREE before codegen. IIUC in TF the plan is to use XLA-HLO to XLA-LHLO to Linalg on buffers (using XLA's machinery).We dont plan to use LHLO in IREE. Maybe some, if not all of this code can be made to work for both IREE and XLA (just like pointwise ops exist today). We can move things into TF (or some repo that has HLO dialect).You seem to assume that because we have LHLO, we can't or won't use HLO-> "Linalg on Tensor" in any of the TF-ecosystem codegen-related project? This does not seem obvious to me though.I dont think I was saying that. As I mentioned above HLO -> Linalg on tensors would work for TF as well. I would hope you can use it. All that code lives in TF already (and the fusion code in MLIR core). The logic for converting XLA-HLO to Linalg on buffers that lives in IREE would be re-usable for LHLO to Linalg as well. So then it's a matter of someone picking that up and pushing that forward.I'm actually interested in this part and in contributing to it. But again there appear to be two options here. (1) The HLO to Linalg buffers stuff in IREE could be reused to do LHLO to Linalg in TF proper (removing any IREE connected stuff and integrating it in TF) and HLO to LHLO for those missing ops could also be done in TF. Does this make sense and to submit this to TF? (2) The other option: since the LHLO path would be subsumed by HLO -> Linalg on tensors -> Linalg on buffers, it may instead make sense to contribute the conversions from HLO to Linalg tensors that involve reductions. When you said that the conversion to 'linalg on tensors' for operators that involve reductions doesn't work, is it due to missing design in linalg or just the conversions missing? I assume the conversion from "linalg on tensors" to "linalg on buffers" exists in TF and MLIR proper and works for all ops (I'm just referring to naive conversion and not any buffer reuse opts)?I would really prefer (2). The issue with reductions so far is just how to handle the initialization value. Nicolas has suggested we take an extra operand in such cases.For example, current matmul in Linalg on buffers islinalg.matmul(%a, %b, %c) : memref<..>, memref<..>, memref<..>In tensors it would be%d = linalg.matmul(%a, %b, %c) : tensor<..>, tensor<..>, tensor<..> -> tensor<..>Where %c and %d have the same shape and %c is the initial value of the result tensor %d. We could potentially add an attribute to explicitly state this relationship so that the buffer allocation schemes can use to get a smaller footprint. This WIP and Nicolas can provide more details on it.Btw, I dont know if there is a standard way of going from Linalg on tensors to Linalg on buffers. MLIR core recently gained an allocator, but I am not tracking that as closely to know if it has
been used to do buffer allocation for Linalg on tensor to Linalg on buffer conversion. Nevertheless, a naive conversion should be possible. Linalg ops allow mixing tensor and buffer operands. So you can allocate in an incremental fashion.
--
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 ml...@tensorflow.org.
To view this discussion on the web visit https://groups.google.com/a/tensorflow.org/d/msgid/mlir/5b9f4f19-a236-404f-87cf-27129d98ec0e%40tensorflow.org.
--Mahesh
HLO conversion can’t be in Core as there is a dependency on TF.I am with Uday here, I don’t understand why these haven’t been developed in TF in the first place?These are lowered from HLO to Linalg on buffersYou mean "Linalg on tensors" here I believe.No I mean HLO to Linalg on buffers. There are some operations (like matmul, conv, anything with reduction iterator types etc.) that cannot be lowered to Linalg on tensors right now. To be able to handle these HLO ops, we convert them to Linalg on buffers. We can do this within IREE cause we put them in their own dispatch regions. Since IREE allocates buffers for the inputs and outputs of the dispatch region, this conversion is possible. The ops that are converted from HLO to Linalg on buffers directly this way are the only ones in IREE. The conversion of XLA-HLO to Linalg on tensors is already in TF tree (and used in IREE).P.S. : We are aware of the phase ordering issue in IREE. Ideally we want to convert from XLA-HLO to Linalg on tensors, perform fusion and then create dispatch regions with each linalg op/remaining xla op in its own dispatch region. This patch is one step to start evaluating this, along with Linalg fusion on tensors that is also in core and these patches (here, here) should help this effort. This approach should work for TF as well, but I have to really see how that plays out. We havent really pushed on this in IREE yet cause we are currently focussing on things downstream in compilation first., which is valid to do within IREE due to IREE's architecture.As long as you can have a lowering path from LinAlg on tensors to something down, what is specific to IREE?There is a question of buffer allocation that has been solved in IREE before codegen. IIUC in TF the plan is to use XLA-HLO to XLA-LHLO to Linalg on buffers (using XLA's machinery).We dont plan to use LHLO in IREE. Maybe some, if not all of this code can be made to work for both IREE and XLA (just like pointwise ops exist today). We can move things into TF (or some repo that has HLO dialect).You seem to assume that because we have LHLO, we can't or won't use HLO-> "Linalg on Tensor" in any of the TF-ecosystem codegen-related project? This does not seem obvious to me though.I dont think I was saying that. As I mentioned above HLO -> Linalg on tensors would work for TF as well. I would hope you can use it. All that code lives in TF already (and the fusion code in MLIR core). The logic for converting XLA-HLO to Linalg on buffers that lives in IREE would be re-usable for LHLO to Linalg as well. So then it's a matter of someone picking that up and pushing that forward.I'm actually interested in this part and in contributing to it. But again there appear to be two options here. (1) The HLO to Linalg buffers stuff in IREE could be reused to do LHLO to Linalg in TF proper (removing any IREE connected stuff and integrating it in TF) and HLO to LHLO for those missing ops could also be done in TF. Does this make sense and to submit this to TF? (2) The other option: since the LHLO path would be subsumed by HLO -> Linalg on tensors -> Linalg on buffers, it may instead make sense to contribute the conversions from HLO to Linalg tensors that involve reductions. When you said that the conversion to 'linalg on tensors' for operators that involve reductions doesn't work, is it due to missing design in linalg or just the conversions missing? I assume the conversion from "linalg on tensors" to "linalg on buffers" exists in TF and MLIR proper and works for all ops (I'm just referring to naive conversion and not any buffer reuse opts)?I would really prefer (2). The issue with reductions so far is just how to handle the initialization value. Nicolas has suggested we take an extra operand in such cases.For example, current matmul in Linalg on buffers islinalg.matmul(%a, %b, %c) : memref<..>, memref<..>, memref<..>In tensors it would be%d = linalg.matmul(%a, %b, %c) : tensor<..>, tensor<..>, tensor<..> -> tensor<..>Where %c and %d have the same shape and %c is the initial value of the result tensor %d. We could potentially add an attribute to explicitly state this relationship so that the buffer allocation schemes can use to get a smaller footprint. This WIP and Nicolas can provide more details on it.Btw, I dont know if there is a standard way of going from Linalg on tensors to Linalg on buffers. MLIR core recently gained an allocator, but I am not tracking that as closely to know if it hasThis part would also be important to know about before jumping in.
Moreover, I ran into other issues - looks like the IREE passes aren't at all what I thought; can you see here:
- Udaybeen used to do buffer allocation for Linalg on tensor to Linalg on buffer conversion. Nevertheless, a naive conversion should be possible. Linalg ops allow mixing tensor and buffer operands. So you can allocate in an incremental fashion.----
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 ml...@tensorflow.org.
To view this discussion on the web visit https://groups.google.com/a/tensorflow.org/d/msgid/mlir/5b9f4f19-a236-404f-87cf-27129d98ec0e%40tensorflow.org.
--Mahesh
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/0ef8f688-5dba-4013-a56c-6c4a4dbe87b3%40tensorflow.org.
These are lowered from HLO to Linalg on buffers, which is valid to do within IREE due to IREE's architecture. There is a question of buffer allocation that has been solved in IREE before codegen. IIUC in TF the plan is to use XLA-HLO to XLA-LHLO to Linalg on buffers (using XLA's machinery).We dont plan to use LHLO in IREE. Maybe some, if not all of this code can be made to work for both IREE and XLA (just like pointwise ops exist today). We can move things into TF (or some repo that has HLO dialect).
On Tue, May 12, 2020 at 6:44 AM 'Uday Bondhugula' via MLIR <ml...@tensorflow.org> wrote:
Hello,
There are broadly two topics that I'm asking about below.
1) I was looking at TensorFlow MLIR overview and I couldn't find information documenting the typical layers (dialects and conversions) to go from TF GraphDef into mid-level MLIR forms like the linalg, Affine or SCF dialects. For TF to TF Lite itself, this README.md provides a good high-level summary (although it's difficult to find and not linked from https://www.tensorflow.org/mlir/overview). But for TF through MLIR layers and code generation, there isn't such an overview AFAICS. I've learnt that this is the typical conversion pipeline:
GraphDef -> MLIR TF executor -> MLIR TF Control -> MLIR TF (Standard CF) -> MLIR xla_hlo -> MLIR xla_lhlo -> linalg / affine / loops
And each of these conversions has a corresponding pass in tf-mlir-translate or tf-opt (all in tf-opt except the first which is an IR translation) with a description for the cmd line option among numerous other options. Is this all and accurate? I think it would be useful to have a README.md similar to the Lite one at https://github.com/tensorflow/tensorflow/tree/master/tensorflow/compiler/mlir/tensorflow providing a summary, especially to all those who are interested in contributing to the pipeline. Or else there could be a description of these intermediate dialects and conversion passes like there is at mlir.llvm.org (Dialects and Passes) - I guess the ones for TF MLIR aren't auto-generated and so it wouldn't be practical perhaps to maintain separately.2) On a related note, the tensor compute dialect work/proposal in progress on MLIR's list is on developing something subsuming {xla_hlo, xla_lhlo, linalg}, and linalg is presumably expanding to the left. Given this, a few concrete questions on the roadmap reg. contributing to the larger end-to-end pipeline: would it be useful to invest more in TF to xla_hlo legalization to complete the missing pieces to get say a full model working or are most people just waiting for the "tensor compute dialect" so that the legalization from MLIR TF dialect could be done straight to that dialect when it's close to ready? Currently, linalg and lhlo are in overlapping spaces, and with known / named ops on tensor types, linalg is covering the hlo space as well already. Is there any early work on cloning the tf -> xla_hlo conversion to tf -> tcd/linalg or is that too early? And finally, are the MLIR TF layers above the tensor compute dialect (TF executor -> TF control -> TF) mostly "design stable" with some parts yet to be implemented? Is there a particular roadmap for those?
Hi Uday!There is so much history in the TF/XLA ecosystem that it is hard to parse through. In addition, we have two compilation flows currently:
- TF->xla_hlo->IREE Flow->LinAlg->... (in use by IREE)
- TF->xla_hlo->xla_lhlo->... (in use by more traditional TF backends)
We ultimately believe that much of this can be rebased on a high level TCP abstraction, and we've found it valuable to start working on that as part of the npcomp scale model, focusing on extracting the patterns to bridge the various layers that have grown in the IREE and traditional TF side into an independent place that we can look at and evaluate how to evolve/upstream/etc. We'd like to see more convergence and upstreaming of the frontend layers, which is why we (IREE-team) are building out the npcomp prototype to aggregate the necessary pieces in preparation for concrete design discussions and upstreaming. +Sean Silva who is working on this in the mlir-npcomp repo.In addition to this, we are continuing to push on the TF->XLA path, and it is mature enough to be handling some fairly non trivial models. Here is IREE's HLO op coverage for various backends (all exercising the HLO->LinAlg path): https://google.github.io/iree/HLOOpCoverage. We don't have a corresponding list of supported TF ops published yet, but we do have our model level coverage annotated in the IREE's TensorFlow tests build file. Most models we care about are in the frustrating space of needing "one or two more op variants", but notably ResNet50 and MobileNet are compiling/running via both LLVM/CPU and Vulkan-SPIRV codegen paths. There are also a handful of models we track privately (mainly sequence and various audio models). Notably on the IREE side right now, these are (almost) exclusively forward-pass (inference) only, and we need to expand our inventory to include loss functions. We largely consider the TF->XLA path to be "design stable" for static shapes. Most of the work we are putting into it is either related to extending op coverage or generalizing things to have some support for dynamic shapes.
--Thanks,Uday
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 ml...@tensorflow.org.
To view this discussion on the web visit https://groups.google.com/a/tensorflow.org/d/msgid/mlir/e2fc1ffc-46d0-4722-972e-3c3078536c65%40tensorflow.org.
[Sorry for top posting, but this isn't a direct continuation although on the same topic. ]I just tried out the TF -> XLA path via MLIR (starting from GraphDef) on a VGG sized model and it's really great to see nearly all conversions working through the xla_hlo dialect with some intervention needed which I'm listing below. I'm posting this to check if someone is already working on this or if contributions are being sought to complete the missing things, or if there are any non-trivial issues preventing those.Here's the MLIR pipeline I ran the TFv2 graphdef through:$ mlir-tf-translate -graphdef-to-mlir -tf-enable-shape-inference-on-import=true model.pbtxt | tf-opt -tf-executor-island-coarsening -canonicalize -tf-decompose-resource-ops -tf-promote-resources-to-args -canonicalize -xla-legalize-tfThe only things that got in the way are:1) tf.VarIsInitializedOpI can't find this op in the tf/mlir tree but only in test cases; its bool result is unused and it appears to be a non-mutating check. It precedes every tf.ReadVariableOp. Looks like it could just be erased via a simple pattern (perhaps it just needs to be added to ops and marked side-effect free)?%outputs_102, %control_103 = tf_executor.island wraps "tf.VarIsInitializedOp"(%outputs_98) {device = ""} : (tensor<!tf.resource<tensor<64xf32>>>) -> tensor<i1>