Confused by HLO_ReshapeOp and TF_ReshapeOp

49 views
Skip to first unread message

Ace

unread,
Jan 9, 2020, 2:07:15 AM1/9/20
to MLIR

Hi all, 

I was confused by the definition of `HLO_ReshapeOp` and `TF_ReshapeOp`.

1) `TF_ReshapeOp `:

```
def TF_ReshapeOp : TF_Op<"Reshape", [NoSideEffect]> {
  let summary = "Reshapes a tensor.";

  let description = [{
    // ....
  }];

  let arguments = (ins
    TF_Tensor:$tensor,
    TF_I32OrI64Tensor:$shape
  );

  let results = (outs
    TF_Tensor:$output
  );

  TF_DerivedOperandTypeAttr T = TF_DerivedOperandTypeAttr<0>;
  TF_DerivedOperandTypeAttr Tshape = TF_DerivedOperandTypeAttr<1>;

  let builders = [
    OpBuilder<
      "Builder* builder, OperationState& result, Value  tensor, Value  shape">
  ];

  let verifier = [{
    return Verify(*this);
  }];
}

```


2) `HLO_ReshapeOp`:

```
def HLO_ReshapeOp: HLO_Op<"reshape",
      [NoSideEffect, SameOperandsAndResultElementType]>, BASE_HLO_ReshapeOp {
  let arguments = (ins HLO_Tensor:$operand);

  let results = (outs HLO_Tensor);
  let hasFolder = 1;

  let hasCustomHLOConverter = 1;
}
```

`TF_ReshapeOp` has two inputs that make us know how to reshape input-0 by input-1.
But `HLO_ReshapeOp` has only one input, so how to express the reshape semantics.
There has no code which lowering `TF_ReshapeOp` to `HLO_ReshapeOp`, 
so here I was some confused by the op definition.

Thanks.

Ace.

Geoffrey Martin-Noble

unread,
Jan 9, 2020, 2:15:08 AM1/9/20
to Ace, MLIR
Hi Ace,

There have been more recent efforts to make the xla dialects support dynamic shapes (and I'll let those who've been involved speak to that), but at least when I originally wrote it, the HLO dialect did not allow dynamic shapes and so the target shape was fully specified by the op's result type.

Hope that helps.

Best,
Geoffrey

--
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/ea7ddf3e-c234-4a8c-8064-7d9be34817bd%40tensorflow.org.

Ace

unread,
Jan 9, 2020, 2:57:35 AM1/9/20
to MLIR
Hi Geoffrey,

Thanks Geoffrey, hope to see the long-term design and plan. 
By the way, will you change the HLO Op definition int future 
when support some new features like dynamic shape.

Best.

Ace.

在 2020年1月9日星期四 UTC+8下午3:15:08,Geoffrey Martin-Noble写道:
To unsubscribe from this group and stop receiving emails from it, send an email to ml...@tensorflow.org.

Kai Zhu

unread,
Jan 9, 2020, 3:27:51 AM1/9/20
to MLIR
Could you share some more information, or any RFCs?
We are also considering about a end2end support of dynamic shape codegen with MLIR.
To unsubscribe from this group and stop receiving emails from it, send an email to ml...@tensorflow.org.

Geoffrey Martin-Noble

unread,
Jan 9, 2020, 11:20:15 AM1/9/20
to Kai Zhu, MLIR
Just reread my email and realized that it might have been misconstrued as saying I wrote the HLO dialect. I meant to say that I wrote the reshape op in particular in the hlo mlir dialect! That's what I get for writing email late at night.

I was one of the early contributors to the xla dialects because we used them as an entry point to get some models into mlir, but it's been a little while since I worked on that. I'll let those more involved in the current work comment on the specifics of the plan for the dialects' evolution.

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/fde9c1c2-ef63-48aa-9330-3e80bd193f5f%40tensorflow.org.

Ace

unread,
Jan 9, 2020, 8:26:32 PM1/9/20
to MLIR
okay, thanks Geoffrey.


在 2020年1月10日星期五 UTC+8上午12:20:15,Geoffrey Martin-Noble写道:

Ace

unread,
Jan 9, 2020, 8:27:24 PM1/9/20
to MLIR
sorry, no RFCs so far. :(

在 2020年1月9日星期四 UTC+8下午4:27:51,Kai Zhu写道:
Reply all
Reply to author
Forward
0 new messages