Skip to content
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

Dev maxpool series op 123d #5244

Merged
merged 232 commits into from
Jul 10, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
232 commits
Select commit Hold shift + click to select a range
cae584e
add torch maxpool2d cpu kernel implementation
Flowingsun007 Dec 22, 2020
4dadae6
refine cpu implementation
Flowingsun007 Dec 23, 2020
4affab9
op gpu implemetation
Flowingsun007 Dec 23, 2020
a9d476c
bug-fix
Flowingsun007 Dec 23, 2020
2f9e0b0
refine
Flowingsun007 Dec 23, 2020
42f89e4
Merge branch 'master' into dev_torch_maxpool2d
Flowingsun007 Dec 23, 2020
3248831
add pooling kernel util
Flowingsun007 Dec 24, 2020
be837cb
Merge branch 'master' into dev_torch_maxpool2d
Flowingsun007 Dec 26, 2020
5bbb80e
reimplementation of cpu kernel
Flowingsun007 Dec 28, 2020
5b68130
gpu kernel implementation
Flowingsun007 Dec 29, 2020
2611a63
gpu kernel implementation
Flowingsun007 Dec 29, 2020
094ca23
bug fix
Flowingsun007 Dec 29, 2020
6727bdf
change indice index
Flowingsun007 Dec 30, 2020
ae5a3be
change indice index of grad compute
Flowingsun007 Dec 30, 2020
32ecd0c
add flag: return_indices
Flowingsun007 Dec 30, 2020
e36c5a2
format code
Flowingsun007 Dec 30, 2020
5bffeab
update inteface param
Flowingsun007 Dec 30, 2020
3c574ef
add param dilation
Flowingsun007 Dec 30, 2020
51a9813
bug-fix
Flowingsun007 Dec 31, 2020
50db3fe
update padding param
Flowingsun007 Dec 31, 2020
af9b8c9
add maxpool2d test case
Flowingsun007 Dec 31, 2020
0645061
format code
Flowingsun007 Dec 31, 2020
7d4a56e
Merge branch 'master' into dev_torch_maxpool2d
Flowingsun007 Dec 31, 2020
bc34495
bug fix
Flowingsun007 Jan 3, 2021
5d0664a
update tese case
Flowingsun007 Jan 3, 2021
9a104ac
update sbp of indice
Flowingsun007 Jan 3, 2021
874ecc0
Merge branch 'master' into dev_torch_maxpool2d
Flowingsun007 Jan 3, 2021
282f241
add code sample
Flowingsun007 Jan 4, 2021
a455da3
add new line
Flowingsun007 Jan 12, 2021
957ee23
Merge branch 'master' into dev_torch_maxpool2d
Flowingsun007 Jan 12, 2021
1d8f6ec
use oneflow_api.BlobDesc
Flowingsun007 Jan 12, 2021
9996fa6
add op torch maxpool1d
Flowingsun007 Jan 20, 2021
eab4ba6
add sample codes
Flowingsun007 Jan 20, 2021
f0274b0
Merge branch 'master' into dev_torch_maxpool2d
Flowingsun007 Jan 20, 2021
782c405
change dtype of indice
Flowingsun007 Jan 20, 2021
d9d0525
add torch maxpool3d interface
Flowingsun007 Jan 20, 2021
eef319f
add implementation of maxpool3d
Flowingsun007 Jan 21, 2021
5846bd4
reformat codes
Flowingsun007 Jan 21, 2021
21d8431
add atomic add
Flowingsun007 Jan 21, 2021
2be443c
bug-fix
Flowingsun007 Jan 21, 2021
86f7d75
backward bug fix
Flowingsun007 Jan 21, 2021
61985c1
update search index
Flowingsun007 Jan 22, 2021
d30d1a6
format code
Flowingsun007 Jan 22, 2021
24ee0d2
update imterface params
Flowingsun007 Jan 22, 2021
3b3351f
add sample code of maxpool3d
Flowingsun007 Jan 23, 2021
a2da604
Merge branch 'master' into dev_torch_maxpool2d
Flowingsun007 Jun 3, 2021
eb694ab
refine and add test case
Flowingsun007 Jun 10, 2021
813f379
Merge branch 'master' of https://github.com/Oneflow-Inc/oneflow
Flowingsun007 Jun 10, 2021
0aae06b
Merge branch 'master' of https://github.com/Oneflow-Inc/oneflow
Flowingsun007 Jun 10, 2021
4a38ccd
Merge branch 'master' of https://github.com/Oneflow-Inc/oneflow
Flowingsun007 Jun 10, 2021
b58b849
Merge branch 'master' of https://github.com/Oneflow-Inc/oneflow
Flowingsun007 Jun 11, 2021
b5e151a
Merge branch 'master' of https://github.com/Oneflow-Inc/oneflow
Flowingsun007 Jun 11, 2021
0ff1651
support ellipsis type slice
Flowingsun007 Jun 11, 2021
1276e65
refine
Flowingsun007 Jun 11, 2021
b9066f9
refine
Flowingsun007 Jun 11, 2021
8f81967
support slice assign ellipsis type
Flowingsun007 Jun 11, 2021
8f8cee2
refine
Flowingsun007 Jun 11, 2021
a79dcdf
Merge branch 'master' into dev_fix_slice_bug
Flowingsun007 Jun 12, 2021
81a400e
Merge branch 'master' of https://github.com/Oneflow-Inc/oneflow
Flowingsun007 Jun 12, 2021
e9e2fa4
Merge branch 'master' into dev_fix_slice_bug
Flowingsun007 Jun 13, 2021
dbdcf18
Merge branch 'master' of https://github.com/Oneflow-Inc/oneflow
Flowingsun007 Jun 13, 2021
b11243f
Merge branch 'master' into dev_fix_slice_bug
Flowingsun007 Jun 13, 2021
9c7185b
Merge branch 'master' into dev_fix_slice_bug
oneflow-ci-bot Jun 13, 2021
c8c78fb
register fn to localtensor
Flowingsun007 Jun 13, 2021
f565929
Merge branch 'dev_fix_slice_bug' of https://github.com/Oneflow-Inc/on…
Flowingsun007 Jun 13, 2021
ebc25f0
Merge branch 'dev_fix_slice_bug'
Flowingsun007 Jun 13, 2021
475bbff
Merge branch 'master' of https://github.com/Oneflow-Inc/oneflow
Flowingsun007 Jun 13, 2021
b69f554
Merge branch 'master' of https://github.com/Oneflow-Inc/oneflow
Flowingsun007 Jun 15, 2021
e8cd9e3
Merge branch 'master' of https://github.com/Oneflow-Inc/oneflow
Flowingsun007 Jun 16, 2021
a500a6d
Merge branch 'master' of https://github.com/Oneflow-Inc/oneflow
Flowingsun007 Jun 17, 2021
5387b8f
Merge branch 'master' of https://github.com/Oneflow-Inc/oneflow
Flowingsun007 Jun 17, 2021
756b0ed
Merge branch 'master' of https://github.com/Oneflow-Inc/oneflow
Flowingsun007 Jun 17, 2021
34e9fd5
Merge branch 'master' of https://github.com/Oneflow-Inc/oneflow
Flowingsun007 Jun 17, 2021
ffe3127
Merge branch 'master' into dev_torch_maxpool2d
Flowingsun007 Jun 18, 2021
bb596b1
Merge remote-tracking branch 'origin' into dev_torch_maxpool2d
Flowingsun007 Jun 18, 2021
97ed736
merge master
Flowingsun007 Jun 18, 2021
ba7eb28
Merge remote-tracking branch 'origin/master' into dev_torch_maxpool2d
Flowingsun007 Jun 18, 2021
5460d54
update maxpooling ops
Flowingsun007 Jun 18, 2021
b1121b7
refactor maxpool2d op
Flowingsun007 Jun 19, 2021
47305b3
add ceil mode testcase
Flowingsun007 Jun 19, 2021
7f20f16
Merge branch 'master' into dev_torch_maxpool2d
Flowingsun007 Jun 19, 2021
7ab390a
rm useless code
Flowingsun007 Jun 19, 2021
c16f043
Merge remote-tracking branch 'origin/master' into dev_torch_maxpool2d
Flowingsun007 Jun 19, 2021
27e673e
Merge branch 'dev_torch_maxpool2d' of https://github.com/Oneflow-Inc/…
Flowingsun007 Jun 19, 2021
1bce90a
refine
Flowingsun007 Jun 19, 2021
0a673df
refactor maxpool3d op and test cases
Flowingsun007 Jun 19, 2021
fe46223
refine
Flowingsun007 Jun 19, 2021
c530901
add maxpool1d implementation
Flowingsun007 Jun 20, 2021
0f952e9
simplify params using struct
Flowingsun007 Jun 20, 2021
2ee2632
fix sbp fn
Flowingsun007 Jun 20, 2021
46535b3
Merge branch 'master' into dev_maxpool_series_op_123d
Flowingsun007 Jun 21, 2021
a5d67ac
Merge branch 'master' of https://github.com/Oneflow-Inc/oneflow
Flowingsun007 Jun 21, 2021
daba23c
Merge branch 'master' into dev_maxpool_series_op_123d
Flowingsun007 Jun 21, 2021
e547b4b
Merge branch 'master' of https://github.com/Oneflow-Inc/oneflow
Flowingsun007 Jun 21, 2021
88c572d
Merge branch 'master' into dev_maxpool_series_op_123d
Flowingsun007 Jun 21, 2021
e040b99
Merge branch 'master' into dev_maxpool_series_op_123d
Flowingsun007 Jun 21, 2021
bc2c2ab
Merge branch 'master' into dev_maxpool_series_op_123d
Flowingsun007 Jun 21, 2021
ecffae1
del notes
Flowingsun007 Jun 22, 2021
7a3b17d
Merge branch 'master' into dev_maxpool_series_op_123d
Flowingsun007 Jun 22, 2021
2e2f748
Merge branch 'master' into dev_maxpool_series_op_123d
Flowingsun007 Jun 22, 2021
ab5ea65
Merge branch 'master' into dev_maxpool_series_op_123d
Flowingsun007 Jun 23, 2021
9dafbf4
Merge branch 'master' into dev_maxpool_series_op_123d
Flowingsun007 Jun 23, 2021
756e537
Merge branch 'master' of https://github.com/Oneflow-Inc/oneflow
Flowingsun007 Jun 24, 2021
a39271b
Merge branch 'master' of https://github.com/Oneflow-Inc/oneflow
Flowingsun007 Jun 25, 2021
4601f2e
Merge branch 'master' into dev_maxpool_series_op_123d
oneflow-ci-bot Jun 27, 2021
d5ecb51
Merge branch 'master' of https://github.com/Oneflow-Inc/oneflow
Flowingsun007 Jun 27, 2021
e45728b
Merge branch 'master' into dev_maxpool_series_op_123d
Flowingsun007 Jun 27, 2021
fd370ab
Merge branch 'master' into dev_maxpool_series_op_123d
oneflow-ci-bot Jun 28, 2021
679f91c
Merge branch 'master' into dev_maxpool_series_op_123d
oneflow-ci-bot Jun 28, 2021
f29ea09
Merge branch 'dev_maxpool_series_op_123d' of https://github.com/Onefl…
Flowingsun007 Jun 28, 2021
db1b536
Merge branch 'master' of https://github.com/Oneflow-Inc/oneflow
Flowingsun007 Jun 28, 2021
ddfd4e8
Merge branch 'master' into dev_maxpool_series_op_123d
Flowingsun007 Jun 28, 2021
75e9bca
Merge branch 'master' into dev_maxpool_series_op_123d
oneflow-ci-bot Jun 28, 2021
b66b496
refine
Flowingsun007 Jun 28, 2021
2761136
Merge branch 'dev_maxpool_series_op_123d' of https://github.com/Onefl…
Flowingsun007 Jun 28, 2021
e0dc709
Merge branch 'master' into dev_maxpool_series_op_123d
oneflow-ci-bot Jun 28, 2021
ac6a8f7
Merge branch 'master' into dev_maxpool_series_op_123d
oneflow-ci-bot Jun 28, 2021
83abbc8
Merge branch 'master' into dev_maxpool_series_op_123d
oneflow-ci-bot Jun 28, 2021
852e6cf
Merge branch 'master' into dev_maxpool_series_op_123d
oneflow-ci-bot Jun 28, 2021
433c980
Merge branch 'master' into dev_maxpool_series_op_123d
oneflow-ci-bot Jun 29, 2021
52d8378
Merge branch 'master' into dev_maxpool_series_op_123d
oneflow-ci-bot Jun 29, 2021
1684be8
Merge branch 'master' into dev_maxpool_series_op_123d
Flowingsun007 Jun 29, 2021
d27dec9
Merge branch 'master' into dev_maxpool_series_op_123d
oneflow-ci-bot Jun 29, 2021
1a37682
Merge branch 'master' into dev_maxpool_series_op_123d
oneflow-ci-bot Jun 29, 2021
c07692f
Merge branch 'master' into dev_maxpool_series_op_123d
oneflow-ci-bot Jun 29, 2021
f0a0d6c
Merge branch 'master' into dev_maxpool_series_op_123d
oneflow-ci-bot Jun 29, 2021
540e437
Merge branch 'master' into dev_maxpool_series_op_123d
oneflow-ci-bot Jun 29, 2021
3e200a7
Merge branch 'master' into dev_maxpool_series_op_123d
oneflow-ci-bot Jun 29, 2021
8707122
Merge branch 'master' into dev_maxpool_series_op_123d
oneflow-ci-bot Jun 29, 2021
269807e
Merge branch 'master' into dev_maxpool_series_op_123d
oneflow-ci-bot Jun 29, 2021
3e244e3
Merge branch 'master' into dev_maxpool_series_op_123d
oneflow-ci-bot Jun 29, 2021
c8f1a59
Merge branch 'master' into dev_maxpool_series_op_123d
oneflow-ci-bot Jun 30, 2021
20556f7
Merge branch 'master' into dev_maxpool_series_op_123d
oneflow-ci-bot Jun 30, 2021
389d94d
merge master
Flowingsun007 Jul 1, 2021
fa8ff2f
refine
Flowingsun007 Jul 1, 2021
96081f9
Merge branch 'master' into dev_maxpool_series_op_123d
Flowingsun007 Jul 1, 2021
a645722
Merge branch 'master' into dev_maxpool_series_op_123d
Flowingsun007 Jul 1, 2021
e6da168
Merge branch 'master' into dev_maxpool_series_op_123d
oneflow-ci-bot Jul 1, 2021
75acbb6
Merge branch 'master' into dev_maxpool_series_op_123d
oneflow-ci-bot Jul 1, 2021
8ebd84e
Merge branch 'master' into dev_maxpool_series_op_123d
Flowingsun007 Jul 1, 2021
192c5dc
Merge branch 'master' into dev_maxpool_series_op_123d
oneflow-ci-bot Jul 1, 2021
b18b606
Merge branch 'master' into dev_maxpool_series_op_123d
oneflow-ci-bot Jul 1, 2021
18da50a
Merge branch 'master' into dev_maxpool_series_op_123d
oneflow-ci-bot Jul 1, 2021
bdb48eb
Merge branch 'master' into dev_maxpool_series_op_123d
oneflow-ci-bot Jul 1, 2021
a94b267
add pooling functional api impl
Flowingsun007 Jul 2, 2021
8454ab4
Merge branch 'master' into dev_maxpool_series_op_123d
Flowingsun007 Jul 2, 2021
2154c34
refine
Flowingsun007 Jul 2, 2021
261e2e0
Merge branch 'master' into dev_maxpool_series_op_123d
oneflow-ci-bot Jul 2, 2021
0453233
Merge branch 'master' into dev_maxpool_series_op_123d
oneflow-ci-bot Jul 2, 2021
85671ab
update sbp fn
Flowingsun007 Jul 2, 2021
f2ea30b
Merge branches 'dev_maxpool_series_op_123d', 'dev_maxpool_series_op_1…
Flowingsun007 Jul 2, 2021
8d9fb8a
Merge branch 'master' into dev_maxpool_series_op_123d
Flowingsun007 Jul 2, 2021
2d8442d
Merge branch 'master' into dev_maxpool_series_op_123d
oneflow-ci-bot Jul 2, 2021
5e2b1b1
Merge branch 'master' into dev_maxpool_series_op_123d
oneflow-ci-bot Jul 2, 2021
b2743c0
Merge branch 'master' into dev_maxpool_series_op_123d
oneflow-ci-bot Jul 2, 2021
17acdda
Merge branch 'master' into dev_maxpool_series_op_123d
oneflow-ci-bot Jul 2, 2021
07c52b7
Merge branch 'master' into dev_maxpool_series_op_123d
oneflow-ci-bot Jul 2, 2021
d6393b6
refin thread num
Flowingsun007 Jul 3, 2021
a4701d5
refine
Flowingsun007 Jul 3, 2021
1192ffb
Merge branch 'master' into dev_maxpool_series_op_123d
Flowingsun007 Jul 3, 2021
3824428
auto format by CI
oneflow-ci-bot Jul 3, 2021
de32cda
Merge branch 'master' into dev_maxpool_series_op_123d
Flowingsun007 Jul 3, 2021
490a668
rm bn test for debug
Flowingsun007 Jul 3, 2021
e7f3fe3
limit registers num
Flowingsun007 Jul 4, 2021
d20c130
remove double dtype
Flowingsun007 Jul 4, 2021
c4e60f8
.
Flowingsun007 Jul 4, 2021
f70fe2c
auto format by CI
oneflow-ci-bot Jul 4, 2021
1a79d4f
update data type
Flowingsun007 Jul 4, 2021
e85068b
fix conflict
Flowingsun007 Jul 4, 2021
901c60c
refine
Flowingsun007 Jul 4, 2021
1c18db2
Merge branch 'master' into dev_maxpool_series_op_123d
Flowingsun007 Jul 4, 2021
31b235c
add cuda synchronize and error string capture
Flowingsun007 Jul 4, 2021
e729d5c
Merge branch 'dev_maxpool_series_op_123d' of https://github.com/Onefl…
Flowingsun007 Jul 4, 2021
c16b9ac
move synchronize placement
Flowingsun007 Jul 4, 2021
9f03564
Merge branch 'master' into dev_maxpool_series_op_123d
Flowingsun007 Jul 5, 2021
e6b27f1
Merge branch 'master' into dev_maxpool_series_op_123d
Flowingsun007 Jul 5, 2021
e6cb3a9
Merge branch 'master' of https://github.com/Oneflow-Inc/oneflow
Flowingsun007 Jul 5, 2021
df8b2dd
Merge branch 'master' into dev_maxpool_series_op_123d
Flowingsun007 Jul 5, 2021
5b7f4d9
Merge branch 'master' of https://github.com/Oneflow-Inc/oneflow
Flowingsun007 Jul 5, 2021
5b048df
debug all kernel compute
Flowingsun007 Jul 5, 2021
6a2831d
Merge branch 'master' into dev_maxpool_series_op_123d
Flowingsun007 Jul 5, 2021
3bc7fa5
Merge branch 'master' into dev_maxpool_series_op_123d
Flowingsun007 Jul 5, 2021
0df30b3
Merge branch 'master' of https://github.com/Oneflow-Inc/oneflow
Flowingsun007 Jul 6, 2021
2fd4964
Merge branch 'master' into dev_maxpool_series_op_123d
Flowingsun007 Jul 6, 2021
9778f2a
Merge branch 'dev_maxpool_series_op_123d' of https://github.com/Onefl…
Flowingsun007 Jul 6, 2021
27d2123
debug
Flowingsun007 Jul 6, 2021
a51211e
Merge branch 'master' into dev_maxpool_series_op_123d
Flowingsun007 Jul 6, 2021
790dc58
Merge branch 'master' into dev_maxpool_series_op_123d
Flowingsun007 Jul 6, 2021
d192ce7
Merge branch 'master' into dev_maxpool_series_op_123d
Flowingsun007 Jul 6, 2021
e5372b8
Merge branch 'master' into dev_maxpool_series_op_123d
Flowingsun007 Jul 6, 2021
b5b28d7
Merge branch 'master' into dev_maxpool_series_op_123d
Flowingsun007 Jul 6, 2021
8cadf4b
debug
Flowingsun007 Jul 6, 2021
2fe0add
debug
Flowingsun007 Jul 6, 2021
18b8031
debug
Flowingsun007 Jul 7, 2021
d58f501
auto format by CI
oneflow-ci-bot Jul 7, 2021
9b8b29a
debug
Flowingsun007 Jul 7, 2021
965662b
Merge branch 'master' into dev_maxpool_series_op_123d
oneflow-ci-bot Jul 7, 2021
64869be
Merge branch 'master' into dev_maxpool_series_op_123d
oneflow-ci-bot Jul 7, 2021
b47c571
Merge branch 'master' into dev_maxpool_series_op_123d
oneflow-ci-bot Jul 7, 2021
cd4c357
Merge branch 'master' into dev_maxpool_series_op_123d
oneflow-ci-bot Jul 7, 2021
ff3a668
Merge branch 'master' into dev_maxpool_series_op_123d
oneflow-ci-bot Jul 7, 2021
c9c1acf
debug std infinity
Flowingsun007 Jul 8, 2021
ce3e500
Merge branch 'master' into dev_maxpool_series_op_123d
oneflow-ci-bot Jul 8, 2021
1b3d042
Merge branch 'master' into dev_maxpool_series_op_123d
oneflow-ci-bot Jul 8, 2021
739b1e1
Merge branch 'master' into dev_maxpool_series_op_123d
oneflow-ci-bot Jul 8, 2021
c3bd7f9
Merge branch 'master' into dev_maxpool_series_op_123d
oneflow-ci-bot Jul 8, 2021
6caa953
Merge branch 'master' into dev_maxpool_series_op_123d
oneflow-ci-bot Jul 8, 2021
810450a
Merge branch 'master' into dev_maxpool_series_op_123d
oneflow-ci-bot Jul 8, 2021
b4959f0
Merge branch 'master' into dev_maxpool_series_op_123d
oneflow-ci-bot Jul 9, 2021
fecba24
Merge branch 'master' into dev_maxpool_series_op_123d
oneflow-ci-bot Jul 9, 2021
fb255ac
debug
Flowingsun007 Jul 9, 2021
3daa727
Merge branch 'dev_maxpool_series_op_123d' of https://github.com/Onefl…
Flowingsun007 Jul 9, 2021
fc65e49
Merge branch 'master' into dev_maxpool_series_op_123d
oneflow-ci-bot Jul 9, 2021
55501ad
Merge branch 'master' into dev_maxpool_series_op_123d
oneflow-ci-bot Jul 9, 2021
04318a1
add numeric utils
Flowingsun007 Jul 9, 2021
2f3ef88
Merge branches 'dev_maxpool_series_op_123d' and 'dev_maxpool_series_o…
Flowingsun007 Jul 9, 2021
94dc827
resolve confict
Flowingsun007 Jul 9, 2021
5e8a8aa
format
Flowingsun007 Jul 9, 2021
dd5921b
Merge branch 'master' into dev_maxpool_series_op_123d
oneflow-ci-bot Jul 9, 2021
6f81bd6
Merge branch 'dev_maxpool_series_op_123d' of https://github.com/Onefl…
Flowingsun007 Jul 9, 2021
a88af50
Merge branch 'master' into dev_maxpool_series_op_123d
oneflow-ci-bot Jul 9, 2021
6b22257
refine
Flowingsun007 Jul 10, 2021
08fb769
Merge branch 'dev_maxpool_series_op_123d' of https://github.com/Onefl…
Flowingsun007 Jul 10, 2021
78b771d
add reference
Flowingsun007 Jul 10, 2021
07cb3b5
remove useless header
Flowingsun007 Jul 10, 2021
268a6cb
Merge branch 'master' into dev_maxpool_series_op_123d
oneflow-ci-bot Jul 10, 2021
60c4276
move namespace to detail
Flowingsun007 Jul 10, 2021
765b511
Merge branch 'master' into dev_maxpool_series_op_123d
Flowingsun007 Jul 10, 2021
46b376b
Merge branch 'master' into dev_maxpool_series_op_123d
oneflow-ci-bot Jul 10, 2021
5ee4f8a
Merge branch 'master' into dev_maxpool_series_op_123d
oneflow-ci-bot Jul 10, 2021
9845b9d
Merge branch 'master' into dev_maxpool_series_op_123d
oneflow-ci-bot Jul 10, 2021
1942e1c
fix doctest error
Flowingsun007 Jul 10, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
120 changes: 120 additions & 0 deletions oneflow/core/autograd/gradient_funcs/pooling.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
/*
Copyright 2020 The OneFlow Authors. All rights reserved.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
#include "oneflow/core/framework/attr_map.h"
#include "oneflow/core/framework/op_expr_grad_function.h"
#include "oneflow/core/framework/op_builder.h"
#include "oneflow/core/framework/op_interpreter/op_interpreter_util.h"
#include "oneflow/core/framework/op_expr.h"
#include "oneflow/core/framework/op_expr_helper.h"
#include "oneflow/core/functional/functional.h"

namespace oneflow {
namespace one {

namespace {

struct PoolingInterpState : public OpExprInterpState {
bool requires_grad;
size_t input_index;
size_t output_index;
size_t indice_index;

std::string data_format;
std::string padding;
std::vector<int32_t> padding_before;
std::vector<int32_t> padding_after;
std::vector<int32_t> kernel_size;
std::vector<int32_t> stride;
std::vector<int32_t> dilation;
bool return_indices;
bool ceil_mode;
};

class PoolingNdGrad : public OpExprGradFunction<PoolingInterpState> {
public:
virtual ~PoolingNdGrad() = default;
Maybe<void> Init(const OpExpr& op, const std::string& mode);
Maybe<void> Capture(PoolingInterpState* ctx, const TensorTuple& inputs,
const TensorTuple& outputs, const AttrMap& attrs) const override;
Maybe<void> Apply(const PoolingInterpState* ctx, const TensorTuple& out_grads,
TensorTuple* in_grads) const override;

private:
std::string mode_;
AttrMap base_attrs_;
};

Maybe<void> PoolingNdGrad::Init(const OpExpr& op, const std::string& mode) {
const auto* fw_op_expr = dynamic_cast<const UserOpExpr*>(&op);
CHECK_NOTNULL_OR_RETURN(fw_op_expr);
base_attrs_ = MakeAttrMapFromUserOpConf(fw_op_expr->proto());
mode_ = mode;
return Maybe<void>::Ok();
}

Maybe<void> PoolingNdGrad::Capture(PoolingInterpState* ctx, const TensorTuple& inputs,
const TensorTuple& outputs, const AttrMap& attrs) const {
ctx->requires_grad = inputs.at(0)->requires_grad();
if (!ctx->requires_grad) { return Maybe<void>::Ok(); }

ctx->input_index = ctx->SaveTensorForBackward(inputs.at(0));
ctx->output_index = ctx->SaveTensorForBackward(outputs.at(0));
ctx->indice_index = ctx->SaveTensorForBackward(outputs.at(1));

ComposedAttrMap composed_attrs(attrs, base_attrs_);
ctx->data_format = JUST(composed_attrs.GetAttr<std::string>("data_format"));
ctx->padding = JUST(composed_attrs.GetAttr<std::string>("padding"));
ctx->padding_before = JUST(composed_attrs.GetAttr<std::vector<int32_t>>("padding_before"));
ctx->padding_after = JUST(composed_attrs.GetAttr<std::vector<int32_t>>("padding_after"));
ctx->kernel_size = JUST(composed_attrs.GetAttr<std::vector<int32_t>>("kernel_size"));
ctx->stride = JUST(composed_attrs.GetAttr<std::vector<int32_t>>("stride"));
ctx->dilation = JUST(composed_attrs.GetAttr<std::vector<int32_t>>("dilation"));
ctx->return_indices = JUST(composed_attrs.GetAttr<bool>("return_indices"));
ctx->ceil_mode = JUST(composed_attrs.GetAttr<bool>("ceil_mode"));
return Maybe<void>::Ok();
}

Maybe<void> PoolingNdGrad::Apply(const PoolingInterpState* ctx, const TensorTuple& out_grads,
TensorTuple* in_grads) const {
if (!ctx->requires_grad) { return Maybe<void>::Ok(); }
CHECK_LE_OR_RETURN(out_grads.size(), 2);

int32_t ndims = ctx->kernel_size.size();
const auto& input = ctx->SavedTensors().at(ctx->input_index);
const auto& output = ctx->SavedTensors().at(ctx->output_index);
const auto& indice = ctx->SavedTensors().at(ctx->indice_index);

in_grads->resize(1);
in_grads->at(0) = JUST(functional::PoolingNdGrad(
input, output, indice, out_grads.at(0), mode_, ndims, ctx->data_format, ctx->padding,
ctx->padding_before, ctx->padding_after, ctx->kernel_size, ctx->stride, ctx->dilation,
ctx->return_indices, ctx->ceil_mode));

return Maybe<void>::Ok();
}

} // namespace

class MaxpoolNdGrad final : public PoolingNdGrad {
public:
Maybe<void> Init(const OpExpr& op) override { return PoolingNdGrad::Init(op, "max"); }
};

REGISTER_OP_EXPR_GRAD_FUNCTION("maxpool_2d", MaxpoolNdGrad);
REGISTER_OP_EXPR_GRAD_FUNCTION("maxpool_3d", MaxpoolNdGrad);

} // namespace one
} // namespace oneflow
23 changes: 23 additions & 0 deletions oneflow/core/functional/functional_api.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -403,6 +403,29 @@
Int32List strides, Bool ceil_mode)"
bind_python: False

- name: "maxpool_2d"
signature:
"TensorTuple Maxpool2D(Tensor x, *, String data_format=\"channels_first\", String padding,
Int32List padding_before, Int32List padding_after,
Int32List kernel_size, Int32List stride, Int32List dilation,
Bool return_indices=True, Bool ceil_mode=False)"
bind_python: True

- name: "maxpool_3d"
signature:
"TensorTuple Maxpool3D(Tensor x, *, String data_format=\"channels_first\", String padding,
Int32List padding_before, Int32List padding_after,
Int32List kernel_size, Int32List stride, Int32List dilation,
Bool return_indices=True, Bool ceil_mode=False)"
bind_python: True

- name: "pooling_grad"
signature:
"Tensor PoolingNdGrad(Tensor x, Tensor y, Tensor indice, Tensor dy, *, String mode, Int32 ndims, String data_format,
String padding, Int32List padding_before, Int32List padding_after, Int32List kernel_size,
Int32List stride, Int32List dilation, Bool return_indices, Bool ceil_mode)"
bind_python: False

- name: "prelu"
signature: "Tensor PRelu(Tensor x, Tensor alpha)"
bind_python: True
Expand Down
45 changes: 45 additions & 0 deletions oneflow/core/functional/impl/nn_functor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,35 @@ class PoolNDFunctor {
std::shared_ptr<OpExpr> op_;
};

class PoolingNDFunctor {
public:
PoolingNDFunctor() = default;
virtual ~PoolingNDFunctor() = default;
Maybe<TensorTuple> operator()(const std::shared_ptr<one::Tensor>& x,
const std::string& data_format, const std::string& padding,
const std::vector<int32_t>& padding_before,
const std::vector<int32_t>& padding_after,
const std::vector<int32_t>& kernel_size,
const std::vector<int32_t>& stride,
const std::vector<int32_t>& dilation, const bool& return_indices,
const bool& ceil_mode) const {
MutableAttrMap attrs;
JUST(attrs.SetAttr<std::string>("padding", padding));
JUST(attrs.SetAttr<std::vector<int32_t>>("padding_before", padding_before));
JUST(attrs.SetAttr<std::vector<int32_t>>("padding_after", padding_after));
JUST(attrs.SetAttr<std::string>("data_format", data_format));
JUST(attrs.SetAttr<std::vector<int32_t>>("kernel_size", kernel_size));
JUST(attrs.SetAttr<std::vector<int32_t>>("stride", stride));
JUST(attrs.SetAttr<std::vector<int32_t>>("dilation", dilation));
JUST(attrs.SetAttr<bool>("return_indices", return_indices));
JUST(attrs.SetAttr<bool>("ceil_mode", ceil_mode));
return OpInterpUtil::Dispatch<TensorTuple>(*op_, {x}, attrs);
}

protected:
std::shared_ptr<OpExpr> op_;
};

class AvgPool2DFunctor : public PoolNDFunctor {
public:
AvgPool2DFunctor() {
Expand All @@ -241,6 +270,20 @@ class MaxPool2DFunctor : public PoolNDFunctor {
}
};

class Maxpool2DFunctor : public PoolingNDFunctor {
public:
Maxpool2DFunctor() {
op_ = CHECK_JUST(one::OpBuilder("maxpool_2d").Input("x").Output("y").Output("indice").Build());
}
};

class Maxpool3DFunctor : public PoolingNDFunctor {
public:
Maxpool3DFunctor() {
op_ = CHECK_JUST(one::OpBuilder("maxpool_3d").Input("x").Output("y").Output("indice").Build());
}
};

class SparseSoftmaxCrossEntropyFunctor {
public:
SparseSoftmaxCrossEntropyFunctor() {
Expand Down Expand Up @@ -420,6 +463,8 @@ ONEFLOW_FUNCTION_LIBRARY(m) {
m.add_functor<impl::LayerNormFunctor>("LayerNorm");
m.add_functor<impl::LayerNormAffineFunctor>("LayerNormAffine");
m.add_functor<impl::AvgPool2DFunctor>("AvgPool2D");
m.add_functor<impl::Maxpool2DFunctor>("Maxpool2D");
m.add_functor<impl::Maxpool3DFunctor>("Maxpool3D");
m.add_functor<impl::MaxPool2DFunctor>("MaxPool2D");
m.add_functor<impl::SparseSoftmaxCrossEntropyFunctor>("SparseSoftmaxCrossEntropy");
m.add_functor<impl::SmoothL1LossFunctor>("SmoothL1Loss");
Expand Down
52 changes: 52 additions & 0 deletions oneflow/core/functional/impl/nn_grad_functor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,57 @@ class ConvDataGradFunctor {
std::shared_ptr<OpExpr> op_;
};

class PoolingNdGradFunctor {
public:
PoolingNdGradFunctor() {
for (const auto& mode : {"max"}) {
for (int ndims = 2; ndims <= 3; ++ndims) {
const auto& op_type_name = GetOpTypeName(mode, ndims);
op_expr_map_[op_type_name] = CHECK_JUST(one::OpBuilder(op_type_name)
.Input("x")
.Input("y")
.Input("indice")
.Input("dy")
.Output("dx")
.Build());
}
}
}
static std::string GetOpTypeName(const std::string& mode, const int32_t& ndims) {
return mode + "pool_" + std::to_string(ndims) + "d_grad";
}
Maybe<Tensor> operator()(const std::shared_ptr<one::Tensor>& x,
const std::shared_ptr<one::Tensor>& y,
const std::shared_ptr<one::Tensor>& indice,
const std::shared_ptr<one::Tensor>& dy, const std::string& mode,
const int32_t& ndims, const std::string& data_format,
const std::string& padding, const std::vector<int32_t>& padding_before,
const std::vector<int32_t>& padding_after,
const std::vector<int32_t>& kernel_size,
const std::vector<int32_t>& stride, const std::vector<int32_t>& dilation,
const bool& return_indices, const bool& ceil_mode) const {
MutableAttrMap attrs;
JUST(attrs.SetAttr<std::string>("padding", padding));
JUST(attrs.SetAttr<std::vector<int32_t>>("padding_before", padding_before));
JUST(attrs.SetAttr<std::vector<int32_t>>("padding_after", padding_after));
JUST(attrs.SetAttr<std::string>("data_format", data_format));
JUST(attrs.SetAttr<std::vector<int32_t>>("kernel_size", kernel_size));
JUST(attrs.SetAttr<std::vector<int32_t>>("stride", stride));
JUST(attrs.SetAttr<std::vector<int32_t>>("dilation", dilation));
JUST(attrs.SetAttr<bool>("return_indices", return_indices));
JUST(attrs.SetAttr<bool>("ceil_mode", ceil_mode));
const auto& op_type_name = GetOpTypeName(mode, ndims);
const auto& it = op_expr_map_.find(op_type_name);
CHECK_OR_RETURN(it != op_expr_map_.end())
<< "Encounter unsupported op " << op_type_name << " in PoolingNdGradFunctor.";
CHECK_NOTNULL_OR_RETURN(it->second);
return OpInterpUtil::Dispatch<Tensor>(*it->second, {x, y, indice, dy}, attrs);
}

protected:
std::unordered_map<std::string, std::shared_ptr<OpExpr>> op_expr_map_;
};

class PoolNdGradFunctor {
public:
PoolNdGradFunctor() {
Expand Down Expand Up @@ -225,6 +276,7 @@ ONEFLOW_FUNCTION_LIBRARY(m) {
m.add_functor<impl::ConvDataGradFunctor>("ConvDataGrad");
m.add_functor<impl::PoolNdGradFunctor>("PoolNdGrad");
m.add_functor<impl::SmoothL1LossGradFunctor>("SmoothL1LossGrad");
m.add_functor<impl::PoolingNdGradFunctor>("PoolingNdGrad");
m.add_functor<impl::PadGradFunctor>("PadGrad");
};

Expand Down
Loading