message: Check that "VariableV2Op" doesn't exist in a TFLite-specific pipeline.
  Adding the check in PrepareTFPass, since it is the very first TFLite pass in the pipeline.
diff: @@ -48,6 +48,7 @@ limitations under the License.
  #include "mlir/Pass/Pass.h" // from @llvm-project
  #include "mlir/Support/LLVM.h" // from @llvm-project
  #include "mlir/Support/LogicalResult.h" // from @llvm-project
  +#include "mlir/Transforms/DialectConversion.h" // from @llvm-project
  #include "tensorflow/compiler/mlir/lite/ir/tfl_ops.h"
  #include "tensorflow/compiler/mlir/lite/quantization/quantization_utils.h"
  #include "tensorflow/compiler/mlir/lite/transforms/dilated_conv.h"
  @@ -612,11 +613,35 @@ struct ConvertTFStridedSlice : public RewritePattern {
  #include "tensorflow/compiler/mlir/lite/transforms/generated_prepare_tf.inc"
  +// Returns success if all the operations in the `op`'s regions including `op`
  +// itself are legal in a TFLite pipeline.
  +LogicalResult ValidateOp(Operation *op) {
  + bool has_illegal_ops = false;
  + op->walk([&](Operation *op) {
  + if (isa<TF::VariableV2Op>(op)) {
  + has_illegal_ops = true;
  + op->emitOpError() << "is illegal in a TFLite pipeline";
  + }
  + });
  +
  + return failure(has_illegal_ops);
  +}
  +
  void PrepareTFPass::runOnFunction() {
  OwningRewritePatternList patterns;
  auto func = getFunction();
  MLIRContext *ctx = &getContext();
  + // Check illegal ops in a TFLite pipeline (e.g. trainning only ops) , since
  + // PrepareTFPass is the very first TFLite pass in the pipeline.
  + // TODO(jingpu): It might be better to split this check into its own pass
  + // to make things more modular.
  + if (failed(ValidateOp(func))) {
  + func.emitError() << "tfl-prepare-tf pass failed.";
  + signalPassFailure();
  + return;
  + }
  +
  // This pattern was intented to uses TFL QDQs to preserve the quantization
  // parameters from the TF Quant ops, thus this pattern should run with the
  // first `applyPatternsAndFoldGreedily` method, which would otherwise removes
  