Commit Graph

103 Commits

Author SHA1 Message Date
mindspore-ci-bot 5b95409022 !13512 add some expander ops
From: @zengzitao
Reviewed-by: 
Signed-off-by:
2021-03-19 15:00:23 +08:00
mindspore-ci-bot 2fadad0875 !13121 expander lamb_apply_optimizer_assign
From: @wenfangpei
Reviewed-by: 
Signed-off-by:
2021-03-19 14:59:37 +08:00
wenfangpei 043a558ae2 expander lamb_apply_optimizer_assign 2021-03-19 09:54:10 +08:00
zengzitao d0a656f3cd add some expander ops 2021-03-18 19:03:36 +08:00
dayschan a2967330ea Normalize the Reduce nodes' axis in GraphKernel
changed all reduce axis to non-negative value
2021-03-16 15:55:50 +08:00
tronzhang 9530904ef7 only through pass target depend 2021-03-12 09:30:01 +08:00
mindspore-ci-bot bc38590e53 !12926 【GraphKernel】Process for UpdateState node
From: @dayschan
Reviewed-by: @gaoxiong1,@ckey_dou
Signed-off-by: @ckey_dou
2021-03-10 16:12:17 +08:00
mindspore-ci-bot 54fc5e0d2b !12234 [GraphKernel] Support pipeline optimization for parallel fusion.
From: @tronzhang
Reviewed-by: 
Signed-off-by:
2021-03-10 16:11:59 +08:00
dayschan 49f78d5424 Bugfix about execution-order after GraphKernelSplitter
1. Removed the deprecated pass "EliminateGetitemForControlDepend"
2. Spread the MakeTuple in UpdateState's input at PreProcess, so that all inputs are directly connected
   to UpdateState, I dont need to consider the condition "Getitem-MakeTuple-UpdateState'.
   after this pass, the UpdateState(U, make_tuple(op1, op2, ...)) was changed to UpdateState(U, op1, op2, ...)
3. Shrink the UpdateState's inputs at PostProcess. The reverse operation of the above pass.
   recovered the UpdateState's format for the process after GraphKernel.
4. Add a pass ExtendOutputForUpdateState, it's the main job of this commit.
   Consider this situation:
   A Cast op has multiple users in a composite kernel, while it's also in the output list and connects to
     an external UpdateState. In the pass "ShapeOpsSplitter", it will be duplicated. after that, only one replica will be connected
     to the external UpdateState, others will be connected to its original users respectively.
   After the pass "GraphKernelSplitter", only one part will be connected to this UpdateState, the execution order of other nodes cannot be ensured.
   This pass extended the node that connects to UpdateState, if a node has an external UpdateState user, all outputs that depend on this node
     will be connected to this UpdateState. It may add many redundant edges, the next pass will handle it.
5. Add a pass MergeOutputForUpdateState after GraphKernelSplitter.
   if an UpdateState has multiple inputs from the same node, only one edge will be kept.
2021-03-09 19:12:36 +08:00
tronzhang 7252ffb66b pipeline optimization for parallel fusion 2021-03-09 17:07:24 +08:00
LianLiguang 4acab81599 using cpp infer firstly 2021-03-09 15:37:17 +08:00
tronzhang 36e65601d1 absorb real scalar tensor 2021-03-02 10:19:57 +08:00
dayschan c165ab5bb1 Combine the GraphKernelOptimization of Gpu and Ascend
removed one cse from GPU passes,
some common passes was enabled for Ascend.
2021-03-01 14:14:12 +08:00
dayschan 9d572f3963 Refactor GraphKernelExpander (2nd submission)
Changed the expander to class, and used the class name to identify the operator.
Moved the original op logic into the `_expand` function; added a `_check` function to check op inputs.

Use decorator to register the whitelist formats that operator supports,
and the decorator will change the `_check` function to check the formats.
2021-02-22 14:49:21 +08:00
mindspore-ci-bot aa71118a99 !12281 fix exec order bug about monad and add test_case in ci
From: @zengzitao
Reviewed-by: 
Signed-off-by:
2021-02-19 11:06:27 +08:00
zengzitao ef3507e973 fix exec order bug about monad 2021-02-18 11:01:06 +08:00
mindspore-ci-bot 30005c9c64 !12301 [GraphKernel] Eliminate redundant split nodes.
From: @tronzhang
Reviewed-by: @gaoxiong1,@anyrenwei
Signed-off-by: @anyrenwei
2021-02-10 14:33:20 +08:00
tronzhang be2b9978be exclude special node when expand or basic fusion 2021-02-09 16:13:35 +08:00
tronzhang e953705521 eliminate redundant split ops 2021-02-09 14:10:57 +08:00
He Wei 7d9a783993 [auto-monad] Support side-effects by auto-monad
The basic idea is: exploits data dependency to control the execution order
of side-effect operations, and keep the semantics of ANF unchanged.

The ControlDepend primitive is removed and there are two primitives added:

1. UpdateState:
```
  a = Assign(para, value)
```
became:
```
  a = Assign(para, value, u)
  u = UpdateState(u, a)
```

2. Load:
```
  x = Add(para, value)
```
became:
```
  p = Load(para, u)
  x = Add(p, value)
  u = UpdateState(u, p)
```
2021-02-08 09:01:15 +08:00
dayschan e0e6c39eae Refactor GraphKernelExpander (1st submission)
Decoupled from the front-end interfaces.
1. Removed the call to "Renormalize".
   Completed the infer-format in model_builder.
   Only used the device shape and device format to
   infer an abstract shape without considering padding.
2. Removed the call to python's Primitive interfaces.
   The "Renormalize" relies on the PrimitivePy, so they can be
   removed together. After that, the functions "ConstAttrToInput",
   "DeleteAttrInInput" and related can be removed.
3. Reuse the AkgKernelJsonGenerator in GraphKernelExpander.
   1) set the attribute "extract_opinfo_from_anf" to true, so that
   the generator can handle the basic operator with anf info.
   2) added a function "extract_expand_info" in expander.py
   to convert the json into a more friendly format. The attrs
   was converted to a dict instead of a list.
4. Scalars only support DefaultFormat.
   Removed the argument "format" from graph_builder.value
5. Moved the expander op list from graph_kernel_helper.cc to graph_kernel_expander.cc
2021-02-07 10:48:23 +08:00
mindspore-ci-bot 5bbf009829 !12108 [GraphKernel] Set attribute to node safely.
From: @tronzhang
Reviewed-by: @ckey_dou
Signed-off-by:
2021-02-07 10:05:49 +08:00
jinyaohui 30a27b2adb modify Gelu、FastGelu to GeLU and FastGeLU 2021-02-05 17:19:52 +08:00
tronzhang c1e63d4824 set attr safetly 2021-02-05 09:12:27 +08:00
jinyaohui d9be0c102d add some ops 2021-02-03 19:47:53 +08:00
mindspore-ci-bot f9d9bba927 !12006 [GraphKernel][Gpu]enable GraphKernel for layernorm and layernormGrad (sync from r1.1)
From: @hanhuifeng2020
Reviewed-by: @gaoxiong1,@anyrenwei
Signed-off-by: @anyrenwei
2021-02-03 17:58:37 +08:00
mindspore-ci-bot 0ff27ef3b4 !11930 【GraphKernel】Replace Assign with InplaceAssign
From: @dayschan
Reviewed-by: @gaoxiong1,@dylangeng
Signed-off-by: @gaoxiong1
2021-02-03 11:04:07 +08:00
hanhuifeng2020 c5f261d894 enable GraphKernel for layernorm and layernormGrad (sync from r1.1) 2021-02-02 19:58:54 +08:00
mindspore-ci-bot a24ff36d9c !11777 stitch fusion
From: @r1chardf1d0
Reviewed-by: 
Signed-off-by:
2021-02-02 10:49:04 +08:00
mindspore-ci-bot 9efbef72fc !11622 【GraphKernel】Moved ShapeOpsSplitter before GraphKernelSplitter
From: @dayschan
Reviewed-by: @gaoxiong1,@dylangeng
Signed-off-by: @gaoxiong1
2021-02-02 10:46:45 +08:00
l00591931 9ec100d069 Change TensorAdd to Add, from r1.1 to master 2021-02-01 17:53:52 +08:00
dayschan 08345c54ea [GraphKernel] Replace Assign with InplaceAssign
1. added a pass to replace Assign with InplaceAssign.
2. bugfix in eliminate_redundant_output. the side-effect node should not be eliminated.
3. bugfix in graph_kernel/splitter.py, the kernel includes InplaceAssign should be a composite node.
4. added two tool functions GetAllInputDeviceTypes and GetAllOutputDeviceTypes into AnfAlgo.
5. do not fuse a single Assign in pass BasicOpsFusion.
2021-02-01 17:15:35 +08:00
dayschan 8a09279ec3 Moved ShapeOpsSplitter before GraphKernelSplitter, changed it to process sub func_graph only. 2021-02-01 11:20:13 +08:00
r1chardf1d0 9d6392c5c5 stitch info 2021-02-01 10:20:55 +08:00
tronzhang d078cbfa99 support parallel fusion 2021-01-27 17:27:13 +08:00
dayschan 27b4e1653a Raise akg ReduceSum precision
Cast the float16-input to float32 before ReduceSum, and cast back to float16 after ReduceSum.
If the op after this ReduceSum is a casting from float16 to float32, then it can be eliminated.
2021-01-26 14:49:48 +08:00
dayschan b9b4a5e5f7 Add a restriction for getitem in basic_ops_fusion.
this commit reverts the modification for basic_ops_fusion.cc in 8af78cd5c,
the getitem should be fused with its all users.
(no bug. but when the network is large, it works very slowly, this's a temporary solution)
2021-01-08 10:48:58 +08:00
dayschan 8af78cd5ce Added ExpandDims into GPU fusion list
what's more:
  remove one restriction of getitem in ops fusion.
  add a while loop for the ShapeOpsSplitter pass.
  add ExpandDims into shape_ops list.
2021-01-03 15:25:09 +08:00
looop5 0a62d42d65 add reorder_ops pass in graph kernel 2020-12-29 10:27:47 +08:00
dayschan 26ac9167f8 Enhance the fusion capacity for getitem nodes.
fixbug in ReplaceNewFuseCNode
add a pass to eliminate repeated output after cse
fixbug in graph_kernel_splitter
do not fuse reshape op as output in costmodel.
2020-12-21 20:22:26 +08:00
mindspore-ci-bot 481a95cade !9714 [GraphKernel] When atomic clean node list is not empty, clean batch in once.
From: @tronzhang
Reviewed-by: @gaoxiong1,@ckey_dou
Signed-off-by: @ckey_dou
2020-12-09 18:54:50 +08:00
mindspore-ci-bot 037a121e05 !9691 expand ClipByNormNoDivSum in graph kernel
From: @looop5
Reviewed-by: @gaoxiong1,@ckey_dou
Signed-off-by: @ckey_dou
2020-12-09 16:07:50 +08:00
tronzhang 68868ab438 clean batch when nodes is not empty 2020-12-09 15:54:29 +08:00
tronzhang 056d7ffc56 clean batch buffer in once 2020-12-09 10:21:08 +08:00
looop5 fa519433ef expand ClipByNormNoDivSum 2020-12-09 09:25:56 +08:00
mindspore-ci-bot 7b311f7d2a !9570 Modifications for GraphKernel
From: @dayschan
Reviewed-by: @gaoxiong1,@ckey_dou
Signed-off-by: @ckey_dou
2020-12-08 09:29:04 +08:00
tronzhang 2b88731417 change atomic add struct and add new condition for controldepend 2020-12-07 17:36:35 +08:00
dayschan 6be3cc6f0d consider atomic_add strategy in graph splitter; fixbugs; fuse and inline single op 2020-12-07 15:53:32 +08:00
looop5 848be9b07c add tile to expand list
add tile expander

add BroadcastTo in model

fix BroadcastTo op calling error and infer shape

rewrite tile expander

not split broadcast_to

add SqrtGrad expander
2020-12-05 10:57:55 +08:00
dayschan e5306b913d GraphKernel Fuser
Refactor the BasicOpsFusion and CompositeOpsFusion to one pass.
Add a pass to eliminate the redundant output.

TODO: rename the file basic_ops_fusion and delete the file composite_ops_fusion
2020-12-04 11:02:36 +08:00