-
Notifications
You must be signed in to change notification settings - Fork 0
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
flow.chunk 或 tensor.chunk #1
Comments
flow.chunk 思路
channel = input.dim()
dim_size = input.shape[dim]
chunk_size = dim_size / chunks if dim_size % chunks == 0 else (int)(dim_size / chunks)
last_chunk_size = dim_size / chunks if dim_size % chunks == 0 else dim_size - (chunk_size * (chunks - 1))
chunk_dim_dict = {}
tup_ndim = []
splits = []
for chunk in range(0, chunks):
if dim_size % chunks == 0:
start = chunk * chunk_size
stop = (chunk + 1) * chunk_size
else:
start = chunk * chunk_size if chunk < chunks - 1 else chunk_size * (chunks - 1)
stop = (chunk + 1) * chunk_size if chunk < chunks - 1 else dim_size
step = 1
chunk_dim_dict.setdefault(dim, []).append([int(start), int(stop), step])
for k, v in chunk_dim_dict.items():
for v_chunk in v:
tup_list = []
for i in range(0, channel):
if i != dim:
tup_list.append([None, None, None])
else:
tup_list.append(v_chunk)
splits.append(
flow.experimental.slice(input, slice_tup_list=tup_list)
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
chunk.py
test_chunk.py
The text was updated successfully, but these errors were encountered: