Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
OpenDAS
ColossalAI
Commits
522f0174
Commit
522f0174
authored
Dec 23, 2022
by
oahzxl
Browse files
code style
parent
774d34f1
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
25 additions
and
14 deletions
+25
-14
chunk_codegen.py
chunk_codegen.py
+25
-14
No files found.
chunk_codegen.py
View file @
522f0174
...
...
@@ -1004,7 +1004,7 @@ class FlowTracer(object):
# if already in node_info, arg dim must be same
if
arg_node
in
all_node_info
:
if
all_node_info
[
arg_node
][
'
chunk_dim
'
]
!=
arg_dim
:
if
all_node_info
[
arg_node
][
"
chunk_dim
"
]
!=
arg_dim
:
return
False
all_node_info
[
arg_node
][
"fix_dim"
]
=
list
(
set
(
all_node_info
[
arg_node
][
"fix_dim"
]
+
arg_fix_dim
)
...
...
@@ -1132,9 +1132,12 @@ class FlowTracer(object):
# get all possible prepose nodes
maybe_prepose_nodes
=
[]
for
node
,
node_info
in
all_node_info
.
items
():
if
node_info
[
'
chunk_dim
'
]
is
None
:
if
node_info
[
"
chunk_dim
"
]
is
None
:
maybe_prepose_nodes
.
append
(
node
)
maybe_prepose_nodes
.
sort
(
key
=
lambda
x
:
_find_idx_by_name
(
x
.
name
,
index_tracer
.
nodes_list
),
reverse
=
True
)
# from last node to first node
maybe_prepose_nodes
.
sort
(
key
=
lambda
x
:
_find_idx_by_name
(
x
.
name
,
index_tracer
.
nodes_list
),
reverse
=
True
,
)
# from last node to first node
prepose_nodes
=
[]
# set every node as root, search its args, if all legal, turn root and args as prepose nodes
while
len
(
maybe_prepose_nodes
)
>
0
:
...
...
@@ -1151,15 +1154,23 @@ class FlowTracer(object):
if
type
(
cur_prepose_node_arg
)
!=
type
(
cur_prepose_node
):
continue
# out of loop
if
not
(
start_idx
<=
_find_idx_by_name
(
cur_prepose_node_arg
.
name
,
self
.
node_list
)
<
end_idx
):
if
not
(
start_idx
<=
_find_idx_by_name
(
cur_prepose_node_arg
.
name
,
self
.
node_list
)
<
end_idx
):
continue
# compute op in loop
elif
cur_prepose_node_arg
in
all_node_info
:
if
all_node_info
[
cur_prepose_node_arg
][
'
chunk_dim
'
]
is
None
:
if
all_node_info
[
cur_prepose_node_arg
][
"
chunk_dim
"
]
is
None
:
tmp_next_prepose_nodes
.
append
(
cur_prepose_node_arg
)
else
:
prepose_flag
=
False
break
;
break
;
break
break
break
break
# non compute op
else
:
tmp_next_prepose_nodes
.
append
(
cur_prepose_node_arg
)
...
...
@@ -1175,7 +1186,9 @@ class FlowTracer(object):
if
n
in
maybe_prepose_nodes
:
maybe_prepose_nodes
.
remove
(
n
)
# sort by index
prepose_nodes
.
sort
(
key
=
lambda
x
:
_find_idx_by_name
(
x
.
name
,
index_tracer
.
nodes_list
))
prepose_nodes
.
sort
(
key
=
lambda
x
:
_find_idx_by_name
(
x
.
name
,
index_tracer
.
nodes_list
)
)
chunk_info
[
"args"
][
"prepose_nodes"
]
=
prepose_nodes
# we need to log input nodes to avoid deleteing them in the loop
...
...
@@ -1183,9 +1196,7 @@ class FlowTracer(object):
# also need to get some prepose node's arg out of non_chunk_inputs
for
n
in
prepose_nodes
:
chunk_node_list
.
remove
(
n
)
non_chunk_inputs
=
_find_chunk_all_input_nodes
(
chunk_node_list
)
non_chunk_inputs
=
_find_chunk_all_input_nodes
(
chunk_node_list
)
for
i
in
non_chunk_inputs
:
if
i
not
in
chunk_info
[
"inputs"
]
and
i
not
in
prepose_nodes
:
chunk_info
[
"inputs_non_chunk"
].
append
(
i
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment