-
Notifications
You must be signed in to change notification settings - Fork 957
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
rfc: propose split op for oneDNN Graph API #1628
base: rfcs
Are you sure you want to change the base?
Conversation
In static shape cases, if the input shape is known, the integration could try to convert
|
@xiang1guo, we plan to emulate dynamic shape support in IPEX with multiple compiled partitions for various static shapes. cc @chunyuan-w |
For 1, as you mentioned in the meeting, we can add another attribute to align the meaning of Pytorch. It helps for mapping, but it still just can't handle the situation when the For 2, yes, graph API doesn't guarantee the view or copy. I will add more descriptions for it. Thanks for your reminder! |
What do you mean by |
For dynamic input data [1, 28, ?](? means this dimension can be gotten in the execution stage) and the |
I see. Thanks for the example. In this case, the number of outputs from |
|
Seems for now we don't have any real case. @chunyuan-w @sanchitintel Do you have any real case about it? |
Hi @sanchitintel, by saying |
Hi @wuxun-zhang, if the input-size would change, then So, it'd be great if we could pass this value at compile time instead. IIRC, something similar is done for DynamicReshape as well. |
@ZhennanQin, currently, the IPEX/PyTorch JIT framework graph is created by tracing with a sample input, so the framework graph's nodes are specific to that input, so, for the case you mentioned, another input with a different input-shape would have generated a different graph. So, if we were to lower such an op (that would generate a different number of tensors) to oneDNN Graph, then we would encounter a runtime error with an input tensor of a different shape than profiled. (However, if we wouldn't lower such an op to oneDNN Graph, then those ops would be handled by Pytorch/IPEX eager mode.) @frost-intel @chunyuan-w, do you know how Dynamo handles such cases? Thanks! |
I would suggest adding an attribute
|
Dynamo can either use a constant input size similar to PT JIT, or it can have a dynamic size marked as a SymInt object with undetermined size. We haven't explored dynamic sizes in our Dynamo/oneDNN Graph bridge, but an attribute or flag marking a dimension as Dynamic would likely be required. |
Thanks, @chunyuan-w! If Thanks for your inputs, @frost-intel! |
a8d4b09
to
4d27c53
Compare
@chunyuan-w @sanchitintel @retonym @ZhennanQin @yifeizh2 I just updated the RFC and added an option2 per pytorch team's request. Please help to review the option2 again, if confirmed, our final implementation will be based on this option. |
| input | `src` | input data | Required | f32,f16,bf16* | | ||
| attribute | `axis` | Specifies which dimension to split along. | Required | s64 | | ||
| attribute | `num_splits` | number of outputs into which the input tensor data will be split along axis dimension. | optional | s64 | | ||
| attribute | `size_split` | size for single output tensor along axis dimension. | optional | s64 | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
during graph build stage, what if size_split
is specified while input shape is unknown? How to determine the output number?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That case you mentioned is a dynamic case that is not supported and has not been encountered yet. Once the dynamic shape feature lands in the future release, we can take it into consideration. cc @wuxun-zhang .
The option2 here is for the convenience of integration on the IPEX side which can simply map the size_split_or_sections
into size_split
during the build stage.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's not a dynamic shape case. FWK won't provide concrete shapes during the graph build stage even for models with static shapes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
during graph build stage, what if
size_split
is specified while input shape is unknown? How to determine the output number?
Why need to determine the output number at graph build stage?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why need to determine the output number at graph build stage?
If you don't know the output number, how to build the graph after this op? A simple example is split+concat, how to collect all the outputs from split and feed them into contact op?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see, it's related to how bridge pass framework's graph to oneDNN Graph. We may need framework team to help answer, cc @chunyuan-w @sanchitintel @retonym.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do I understand correctly that this is a case where the graph structure depends on the input shapes? In the current integration, the graph will only be built once. I feel like it does not work anymore in such cases. Let me check with @jgong5 & @sanchitintel on it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@chunyuan-w, I agree that this case would encounter a runtime error with our multiple compiled partitions per partition approach. I think we can't solve this problem without re-creating the graph.
|
||
#### operations used in Frameworks and toolkit | ||
|
||
| Tensorflow | Argument Name | Description | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As TF workloads moves to XLA compiler path, and Pytorch move to Torchdynamic/TorchInductor, FW operations are decomposed to XLA HLO op or Pytorch PrimTorch OP. These operations usually has simpler semantics. oneDNN Graph operation should first consider what is the basic operation we need to support, and usually these operation design would give better insight - what operations are popular (those unpopular ones may not lowered to these simple ops), and how the basic operations look like.
Could you please also include how these two set operations support split?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi, @Jianhui-Li, just checked the XLA and PrimTorch, these two operations don't directly support Split
.
- TensorFlow's
Split
will be lowered to XLA HLO Slice op. I have updated the definition of XLA HLOSlice
in this section. - For Pytorch/PrimTorch, when Torch IR is lowered to Aten IR/Prim IR, the
torch.Split
will callaten.Split
and there is no decomposition to PrimTorch ops happening during this stage. And inductor will loweraten.Split
toslice
in its implementation.
cc @retonym @chunyuan-w
4d27c53
to
6f09b5b
Compare
This RFC is to add a new Split operation to oneDNN graph API opset.
The rendered version: link