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

[one::OpBuilder] op interpreter core #4407

Merged
Merged
Show file tree
Hide file tree
Changes from 250 commits
Commits
Show all changes
276 commits
Select commit Hold shift + click to select a range
4769608
del object_storage.cpp
clackhan Feb 2, 2021
38c5011
Merge branch 'master' into mig_mig_instruction_build_api_about_op_conf
clackhan Feb 2, 2021
9a5da7c
Merge branch 'master' into mig_mig_instruction_build_api_about_op_conf
clackhan Feb 2, 2021
0377ecd
use name GLOBAL_PARA_SYM2SHARED_OPKENEL_OBJ_MUTEX
clackhan Feb 2, 2021
891f06e
mig CheckRefInBlobObjectParallelDesc and OperandBlobObjects rel api
clackhan Feb 3, 2021
5f76aa7
Merge branch 'master' into mig_mig_instruction_build_api_about_op_conf
clackhan Feb 3, 2021
9187a46
mig _StatelessCall
clackhan Feb 3, 2021
e070510
mig _StatelessCall
clackhan Feb 3, 2021
b8cfc23
[one::OpBuilder] Refactor Operation.
Feb 3, 2021
04be537
Merge branch 'master' into mig_mig_instruction_build_api_about_op_conf
clackhan Feb 3, 2021
cc9ef11
mig StatelessCall api
clackhan Feb 4, 2021
0ea1efb
Merge branch 'mig_mig_instruction_build_api_about_op_conf' of https:/…
clackhan Feb 4, 2021
528b19b
mig StatefulCall
clackhan Feb 4, 2021
54c1cd3
mig callback api
clackhan Feb 4, 2021
6ff4cb5
mig MakeLazyRefBlobObject
clackhan Feb 4, 2021
02134fe
refactor CudaHostPinBlob
clackhan Feb 4, 2021
5c8ca5b
sort out InstructionsBuilder api
clackhan Feb 4, 2021
14cc649
[one::OpBuilder] Refine
Feb 4, 2021
4f657b0
Merge branch 'master' into dev_hjchen2_op_builder
hjchen2 Feb 4, 2021
a820296
Merge branch 'master' into mig_mig_instruction_build_api_about_op_conf
clackhan Feb 4, 2021
7125e30
Merge branch 'master' into mig_instruction_build_api_about_op_atttribute
clackhan Feb 4, 2021
a309307
Merge branch 'master' into mig_instruction_build_api_other
clackhan Feb 4, 2021
f85be4d
mig PhysicalRun and LogicalRun
clackhan Feb 5, 2021
e2fdcac
Merge branch 'master' of https://github.com/Oneflow-Inc/oneflow into …
clackhan Feb 5, 2021
6382014
use oneflow_api.deprecated.LogicalRun & PhysicalRun
clackhan Feb 5, 2021
751a2ba
Merge branch 'master' into mig_mig_instruction_build_api_about_op_conf
clackhan Feb 5, 2021
e73c92f
Merge branch 'master' into mig_instruction_build_api_about_op_atttribute
clackhan Feb 5, 2021
1253183
Merge branch 'master' into mig_instruction_build_api_other
clackhan Feb 5, 2021
adff7f7
delete vm_util.py
clackhan Feb 5, 2021
09b59ed
change FindOrCreateDelegateBlobObject args
clackhan Feb 5, 2021
426655b
Merge branch 'master' of https://github.com/Oneflow-Inc/oneflow into …
clackhan Feb 5, 2021
105d541
add SetShuttingDown
clackhan Feb 5, 2021
c19cc39
Merge branch 'master' of https://github.com/Oneflow-Inc/oneflow into …
clackhan Feb 5, 2021
9e54f1f
Merge branch 'master' into mig_mig_instruction_build_api_about_op_conf
clackhan Feb 5, 2021
f8772ae
Merge branch 'master' into mig_instruction_build_api_about_op_atttribute
clackhan Feb 5, 2021
b1cbc92
Merge branch 'master' into mig_instruction_build_api_other
clackhan Feb 5, 2021
e796351
rm python_interpreter_util.py
clackhan Feb 7, 2021
77d1cea
add blank line
clackhan Feb 7, 2021
ca0fbd3
mig BlobCache
clackhan Feb 7, 2021
6c0119b
use FindOrCreateDelegateBlobObject in c++
clackhan Feb 7, 2021
c970433
refactor session_util.cpp
clackhan Feb 7, 2021
55ac9f3
Merge branch 'master' of https://github.com/Oneflow-Inc/oneflow into …
clackhan Feb 7, 2021
f63f279
Merge branch 'master' into mig_mig_instruction_build_api_about_op_conf
clackhan Feb 7, 2021
e4fd7a5
Merge branch 'master' into mig_instruction_build_api_about_op_atttribute
clackhan Feb 7, 2021
36b44d2
Merge branch 'master' into mig_instruction_build_api_other
clackhan Feb 7, 2021
5eda1d1
use IsShutDown
clackhan Feb 7, 2021
516ddfa
Merge branch 'master' of https://github.com/Oneflow-Inc/oneflow into …
clackhan Feb 7, 2021
ad62b60
refactor BlobRegister
clackhan Feb 7, 2021
d7c0358
Merge branch 'master' into mig_instruction_build_api_other
clackhan Feb 8, 2021
62e1d05
[one::OpBuilder] Refactor OpExpr and OpExprInterpreter.
Feb 7, 2021
171b105
[one::OpBuilder] Remove member function evaluate.
Feb 8, 2021
c9daeb0
[one::OpBuilder] Remove OpInterpreter to facilitate CR.
Feb 8, 2021
c3995b4
[one::OpBuilder] Refine
Feb 8, 2021
1ae35e2
fix distribute test exit bug
clackhan Feb 8, 2021
8718a2b
Merge branch 'mig_logical_and_pyhsical_run' of https://github.com/One…
clackhan Feb 8, 2021
f3d11d1
Merge branch 'master' of https://github.com/Oneflow-Inc/oneflow into …
clackhan Feb 8, 2021
e54326a
Merge branch 'master' into mig_mig_instruction_build_api_about_op_conf
clackhan Feb 8, 2021
d103478
Merge branch 'master' into mig_instruction_build_api_about_op_atttribute
clackhan Feb 8, 2021
6c67d03
Merge branch 'master' of https://github.com/Oneflow-Inc/oneflow into …
clackhan Feb 8, 2021
fe9adeb
Merge branch 'master' of https://github.com/Oneflow-Inc/oneflow into …
clackhan Feb 8, 2021
c71b2f3
del comment
clackhan Feb 8, 2021
2c89bdd
Merge branch 'master' into mig_op_conf_sym
clackhan Feb 8, 2021
f7ec4f9
[one::OpBuilder] Add more op exprs.
Feb 8, 2021
abdf302
Merge branch 'mig_op_conf_sym' of https://github.com/Oneflow-Inc/onef…
clackhan Feb 8, 2021
e4054c1
Merge branch 'master' of https://github.com/Oneflow-Inc/oneflow into …
clackhan Feb 8, 2021
13ce9d4
Merge branch 'master' of https://github.com/Oneflow-Inc/oneflow into …
clackhan Feb 8, 2021
51a801d
mig id_util and scope_util
clackhan Feb 8, 2021
ea8f60e
Merge branch 'master' of https://github.com/Oneflow-Inc/oneflow into …
clackhan Feb 8, 2021
ac443b8
Merge branch 'master' of https://github.com/Oneflow-Inc/oneflow into …
clackhan Feb 8, 2021
427fa07
Merge branch 'master' into mig_opkernel_obj_and_op_conf_sym
clackhan Feb 8, 2021
401812e
Merge branch 'master' into mig_opkernel_obj_and_op_conf_sym
clackhan Feb 9, 2021
8541630
use cfg_op_conf and Object*
clackhan Feb 9, 2021
87078b0
Merge branch 'mig_opkernel_obj_and_op_conf_sym' of https://github.com…
clackhan Feb 9, 2021
cd73d18
Merge branch 'mig_opkernel_obj_and_op_conf_sym' of https://github.com…
clackhan Feb 9, 2021
34335c0
use Object*
clackhan Feb 9, 2021
9825360
Merge branch 'mig_opkernel_obj_and_op_conf_sym' of https://github.com…
clackhan Feb 9, 2021
8644b7e
del _
clackhan Feb 9, 2021
8aef27c
Merge branch 'master' of https://github.com/Oneflow-Inc/oneflow into …
clackhan Feb 9, 2021
3cc6f83
Merge branch 'mig_mig_instruction_build_api_about_op_conf' of https:/…
clackhan Feb 9, 2021
63adc9c
fix func name error
clackhan Feb 9, 2021
89d4de3
Merge branch 'mig_mig_instruction_build_api_about_op_conf' of https:/…
clackhan Feb 9, 2021
5a17883
Merge branch 'mig_mig_instruction_build_api_about_op_conf' of https:/…
clackhan Feb 9, 2021
96cca83
Merge branch 'master' of https://github.com/Oneflow-Inc/oneflow into …
clackhan Feb 19, 2021
2fa4a89
[one::OpBuilder] Refine
hjchen2 Feb 18, 2021
0f1a633
[one::OpBuilder] Modify op input names by InOutBnAccessor.
Feb 19, 2021
9a3b817
[one::OpBuilder] Fix op expr python api.
Feb 19, 2021
bad2530
Merge branch 'master' into mig__StatelessCall
clackhan Feb 19, 2021
fdfd5be
Merge branch 'mig_blob_cache' of https://github.com/Oneflow-Inc/onefl…
Feb 20, 2021
a745fe6
Merge branch 'master' into mig__StatelessCall
clackhan Feb 20, 2021
98e763c
use MapAt and shared_ptr
clackhan Feb 20, 2021
b443a35
[one::OpBuilder] Using indexed ibns and obns instead of tensor names.
Feb 20, 2021
ba7f861
[one::OpBuilder] Update
Feb 20, 2021
51aadc9
[one::OpBuilder] Complete op interpreter in the main.
Feb 22, 2021
ec5357e
use shared_ptr or const ref
clackhan Feb 22, 2021
c4d1111
Merge branch 'master' of https://github.com/Oneflow-Inc/oneflow into …
clackhan Feb 22, 2021
9d7639d
minor fix
clackhan Feb 22, 2021
b24e73a
add todo
clackhan Feb 22, 2021
b533052
[one::OpBuilder] Export and extend BoxingUtil in python.
Feb 22, 2021
5f5bff4
[one::OpBuilder] Support variable op interpretation.
Feb 23, 2021
c2c9271
[one::OpBuilder] Refine
Feb 24, 2021
51ef86e
[one::OpBuilder] Refine placeholder prefix.
Feb 24, 2021
f3d98ba
Merge branch 'master' into mig__StatelessCall
clackhan Feb 24, 2021
25bc805
Merge branch 'master' into mig__StatelessCall
clackhan Feb 24, 2021
1c26e22
Merge branch 'master' into mig__StatelessCall
clackhan Feb 24, 2021
96ad134
minor fix
clackhan Feb 24, 2021
af8e83c
Merge branch 'mig__StatelessCall' of https://github.com/Oneflow-Inc/o…
clackhan Feb 24, 2021
3606a7c
minor djustment
clackhan Feb 24, 2021
0ef2855
minor fix
clackhan Feb 24, 2021
604c9c5
[one::OpBuilder] Migrate snapshot manager.
Feb 24, 2021
d26ac1e
Merge branch 'master' into mig_id_util_and_scope_util
clackhan Feb 25, 2021
35aab68
Merge branch 'mig_id_util_and_scope_util' of https://github.com/Onefl…
clackhan Feb 25, 2021
436d8db
minor optimize
clackhan Feb 25, 2021
fcb528c
minor fix
clackhan Feb 25, 2021
e48d9e9
Merge branch 'mig_id_util_and_scope_util' of https://github.com/Onefl…
clackhan Feb 25, 2021
6d9a9dd
Merge branch 'mig_id_util_and_scope_util' of https://github.com/Onefl…
clackhan Feb 25, 2021
0f26905
Merge branch 'mig_Instruction_build_StatelessCall_rel_api' of https:/…
clackhan Feb 25, 2021
1fbbc6b
minor optimize
clackhan Feb 25, 2021
7afdaa9
[one::OpBuilder] Migrate Session.
Feb 25, 2021
0922812
[one::OpBuilder] Fix return type.
Feb 25, 2021
1c7e6b1
[one::OpBuilder] Refine variable interpretation.
Feb 25, 2021
5656142
Merge branch 'master' into mig_instruction_build_api_about_op_atttribute
clackhan Feb 25, 2021
3754fab
Merge branch 'mig_instruction_build_api_about_op_atttribute' of https…
clackhan Feb 26, 2021
96d10ca
Merge branch 'master' of https://github.com/Oneflow-Inc/oneflow into …
clackhan Feb 26, 2021
3069dd3
Merge branch 'mig_instruction_build_api_about_op_atttribute' of https…
clackhan Feb 26, 2021
9add581
minor optimize
clackhan Feb 26, 2021
7d190f1
Merge branch 'mig_instruction_build_api_about_op_atttribute' of https…
clackhan Feb 26, 2021
f531faa
fix bug
clackhan Feb 26, 2021
e956998
Merge branch 'mig_instruction_build_api_other' of https://github.com/…
clackhan Feb 26, 2021
6d939f6
Merge branch 'master' of https://github.com/Oneflow-Inc/oneflow into …
clackhan Feb 26, 2021
6eb76d2
[one::OpBuilder] Call python FeePath.
Feb 28, 2021
07602e4
[one::OpBuilder] Fix typo.
Feb 28, 2021
fb29fa1
Merge branch 'master' into mig_logical_and_pyhsical_run
clackhan Feb 28, 2021
bd27dc7
Merge branch 'dev_hjchen2_op_interpreter' into dev_hjchen2_op_interpr…
Feb 28, 2021
4510f09
Merge branch 'mig_logical_and_pyhsical_run' of https://github.com/One…
clackhan Feb 28, 2021
c2a918a
Merge branch 'mig_logical_and_pyhsical_run' of https://github.com/One…
clackhan Feb 28, 2021
2e7b8e2
Merge branch 'master' into mig_blob_cache
clackhan Feb 28, 2021
9a6ee0b
minor fix
clackhan Feb 28, 2021
6f72bcf
Merge branch 'master' of https://github.com/Oneflow-Inc/oneflow into …
clackhan Feb 28, 2021
cc9c7e7
Merge branch 'mig_logical_and_pyhsical_run' of https://github.com/One…
clackhan Feb 28, 2021
c3180af
Merge branch 'mig_blob_cache' of https://github.com/Oneflow-Inc/onefl…
clackhan Feb 28, 2021
3ba0919
[one::OpBuilder] Fix merge bugs.
Feb 28, 2021
79bc9b9
Merge branch 'mig_blob_cache' of https://github.com/Oneflow-Inc/onefl…
Mar 1, 2021
021fc1d
[one::OpBuilder] Bugfix.
Mar 1, 2021
e675358
[one::OpBuilder] Refine
Mar 1, 2021
f448893
[one::OpBuilder] Bugfix
Mar 1, 2021
4789efd
[one::OpBuilder] Refine
Mar 1, 2021
fa9e105
[one::OpBuilder] Fix typo.
Mar 1, 2021
8ba3f80
[one::OpBuilder] Fix placeholder prefix of op builer.
Mar 1, 2021
7db5d39
[one::OpBuilder] Set output blob object after running the instruction.
Mar 1, 2021
d2bf8a3
[one::OpBuilder] Remove TensorNameScope temporarily.
Mar 1, 2021
531cf08
[one::OpBuilder] Fix api.
Mar 1, 2021
db8da4f
[one::OpBuilder] Add TensorNameScope.
Mar 1, 2021
1ce75ad
[one::OpBuilder] Modify the op builder apis to return Maybe type.
Mar 2, 2021
3506ea4
[one::OpBuilder] Remove unused header.
Mar 2, 2021
b78574c
[one::OpBuilder] Fix
Mar 2, 2021
38a0e93
[one::OpBuilder] Fix typo
Mar 2, 2021
a5198bf
[one::OpBuilder] Fix bugs.
Mar 2, 2021
16a66b1
[one::OpBuilder] Create tensor from blob object.
Mar 3, 2021
5b67af3
[one::OpBuilder] Return Maybe in op interpreter.
Mar 3, 2021
669ec08
Merge branch 'master' of https://github.com/Oneflow-Inc/oneflow into …
Mar 3, 2021
545d674
[one::OpBuilder] Fix merge conflicts and reformat.
Mar 3, 2021
96453df
[one::OpBuilder] Remove unused code.
Mar 3, 2021
d36e4d2
[one::OpBuilder] Go through eager mode.
Mar 4, 2021
4c2e825
[one::OpBuilder] Fix typo
Mar 8, 2021
a1773ca
[one::OpBuilder] Refine
Mar 8, 2021
352f473
[one::OpBuilder] Remove redundant file system and refine code style.
Mar 9, 2021
87f17d9
Merge branch 'master' of https://github.com/Oneflow-Inc/oneflow into …
Mar 9, 2021
1d4774a
[one::OpBuilder] Use TensorTuple instead of TensorList and provide me…
Mar 10, 2021
f27e80b
[one::OpBuilder] Fix bug
Mar 10, 2021
0e0dd6f
Merge branch 'master' of https://github.com/Oneflow-Inc/oneflow into …
Mar 10, 2021
9d9ef17
[one::OpBuilder] Remove state input.
Mar 11, 2021
edf5098
[one::OpBuilder] Create output tensors for lazy mode.
Mar 11, 2021
c14085a
[one::OpBuilder] Change pybind hold type to shared_ptr for Callback, …
Mar 11, 2021
570c420
[one::OpBuilder] Move to deprecated.
Mar 12, 2021
da1c07b
[one::OpBuilder] Remove unused code.
Mar 12, 2021
e41fce1
[one::OpBuilder] Fix typo.
Mar 12, 2021
227a3cd
[one::OpBuilder] Support TensorTuple input and fix typo.
Mar 12, 2021
d8fd175
[one::OpBuilder] Fix bugs.
Mar 12, 2021
a91c9ea
Merge branch 'master' of https://github.com/Oneflow-Inc/oneflow into …
Mar 14, 2021
c7047eb
[one::OpBuilder] Change pybind hold type to shared_ptr for Callback, …
Mar 11, 2021
853768e
[one::OpBuilder] Fix bugs.
Mar 12, 2021
2961f54
[one::OpBuilder] Migrate snapshot manager.
Feb 24, 2021
2be2c31
[one::OpBuilder] Remove redundant file system and refine code style.
Mar 9, 2021
82aec20
[one::OpBuilder] Migrate Session.
Feb 25, 2021
191f70c
Merge branch 'dev_hjchen2_mig_snapshot_path' into dev_hjchen2_mig_ses…
Mar 15, 2021
cfe21c0
[one::OpBuilder] Refine
Mar 15, 2021
75347a5
[one::OpBuilder] Refine
Mar 15, 2021
79a32fd
[one::OpBuilder] Call python FeePath.
Feb 28, 2021
0164431
[one::OpBuilder] Export and extend BoxingUtil in python.
Feb 22, 2021
b6b42db
[one::OpBuilder] Deprecate boxing util python api.
Mar 15, 2021
68191bd
[one::OpBuilder] Reformat
Mar 15, 2021
66a548d
Merge branch 'dev_hjchen2_mig_boxing_util' into dev_hjchen2_op_interp…
Mar 15, 2021
d6e6aa0
Merge
Mar 15, 2021
d8cde65
Merge branch 'dev_hjchen2_mig_snapshot_path' into dev_hjchen2_op_inte…
Mar 15, 2021
49af870
Merge branch 'dev_hjchen2_mig_session_util' into dev_hjchen2_op_inter…
Mar 15, 2021
4a71f31
Merge branch 'dev_hjchen2_merge_job_build_and_infer_ctx' into dev_hjc…
Mar 15, 2021
7f6c028
Merge branch 'dev_hjchen2_pybind_held_type' into dev_hjchen2_op_inter…
Mar 15, 2021
ae56244
Refine
Mar 15, 2021
6669f26
Merge branch 'master' into dev_hjchen2_op_interpreter
hjchen2 Mar 15, 2021
a28fe08
Use reference op expr.
Mar 15, 2021
bfd7fc9
Merge branch 'dev_hjchen2_op_interpreter' of https://github.com/Onefl…
Mar 15, 2021
76e2861
Fix default value
Mar 16, 2021
1cc4121
Fix LocalFS use bug
Mar 16, 2021
c093ee7
Fix and refine
Mar 16, 2021
f758330
Return Maybe
Mar 16, 2021
65fe47a
Reformat
Mar 16, 2021
01c8865
Refine
Mar 16, 2021
dc655a4
Remove initialization to simplify variable op interpretation.
Mar 17, 2021
d76f57f
Revert SnapshotManager and Session
Mar 18, 2021
609f126
Merge branch 'master' of https://github.com/Oneflow-Inc/oneflow into …
Mar 18, 2021
8f3e628
Fix register BoxingUtil
Mar 18, 2021
3888434
Remove unused header
Mar 18, 2021
744219e
Revert foreign callback
Mar 18, 2021
8636c7d
Refine code style
Mar 18, 2021
a7b68ea
Fix register BoxingUtil
Mar 18, 2021
ae8c9fd
Get device from parallel desc to make a new tensor.
Mar 18, 2021
920531e
Boxing call instructions and refine.
Mar 19, 2021
1f2a6d8
Merge branch 'master' into dev_hjchen2_op_interpreter_core
hjchen2 Mar 19, 2021
f4979e8
Fix ci error
Mar 19, 2021
1579a4a
Swap the op conf since the move constructor was not provided by proto…
Mar 19, 2021
46f43a2
Refine
Mar 19, 2021
d994ea2
Refine code style
Mar 19, 2021
7599473
Reformat
Mar 19, 2021
1f4346a
Fix error merge
Mar 19, 2021
b9bc0c1
Make interpreter stateless and remove OpExprInterpContext.
Mar 20, 2021
ef761a2
Refine
Mar 20, 2021
39ded84
reformat
Mar 20, 2021
a4f4479
Merge branch 'master' into dev_hjchen2_op_interpreter_core
hjchen2 Mar 20, 2021
4bac099
Fix typo
Mar 22, 2021
b361040
Revert interpreter interface
Mar 22, 2021
8ec8f2b
Use move assignment since protobuf has been upgrade.
Mar 22, 2021
3e81e61
Refine
Mar 22, 2021
45cce0f
Merge branch 'dev_hjchen2_op_interpreter_core' of https://github.com/…
Mar 22, 2021
3e8e0db
Merge branch 'master' into dev_hjchen2_op_interpreter_core
hjchen2 Mar 22, 2021
680c22b
Merge branch 'master' into dev_hjchen2_op_interpreter_core
oneflow-ci-bot Mar 22, 2021
c52d7b8
Merge branch 'master' into dev_hjchen2_op_interpreter_core
oneflow-ci-bot Mar 22, 2021
34690ea
Merge branch 'master' into dev_hjchen2_op_interpreter_core
oneflow-ci-bot Mar 22, 2021
906d62e
Merge branch 'master' into dev_hjchen2_op_interpreter_core
oneflow-ci-bot Mar 22, 2021
5783c4b
Merge branch 'master' into dev_hjchen2_op_interpreter_core
oneflow-ci-bot Mar 23, 2021
b6e37c2
Merge branch 'master' into dev_hjchen2_op_interpreter_core
oneflow-ci-bot Mar 23, 2021
4a88cb8
Merge branch 'master' into dev_hjchen2_op_interpreter_core
oneflow-ci-bot Mar 23, 2021
3e3b636
Merge branch 'master' into dev_hjchen2_op_interpreter_core
oneflow-ci-bot Mar 23, 2021
50be2bb
Refine
Mar 23, 2021
dd3581d
Merge branch 'dev_hjchen2_op_interpreter_core' of https://github.com/…
Mar 23, 2021
f08ac8f
Merge branch 'master' into dev_hjchen2_op_interpreter_core
oneflow-ci-bot Mar 23, 2021
31f3fce
Merge branch 'master' into dev_hjchen2_op_interpreter_core
oneflow-ci-bot Mar 23, 2021
720343a
Merge branch 'master' into dev_hjchen2_op_interpreter_core
oneflow-ci-bot Mar 23, 2021
2511533
Merge branch 'master' into dev_hjchen2_op_interpreter_core
oneflow-ci-bot Mar 23, 2021
87578f0
Merge branch 'master' into dev_hjchen2_op_interpreter_core
oneflow-ci-bot Mar 23, 2021
25935c9
Merge branch 'master' into dev_hjchen2_op_interpreter_core
hjchen2 Mar 24, 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
5 changes: 4 additions & 1 deletion oneflow/api/python/framework/foreign_boxing_util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,10 @@ class PyForeignBoxingUtil : public ForeignBoxingUtil {
Maybe<void> RegisterBoxingUtilOnlyOnce(const std::shared_ptr<ForeignBoxingUtil>& boxing_util) {
CHECK_ISNULL_OR_RETURN(Global<std::shared_ptr<ForeignBoxingUtil>>::Get())
<< "Foreign Boxing util has been registered.";
Global<std::shared_ptr<ForeignBoxingUtil>>::New(boxing_util);
// Global<T>::SetAllocated is preferred since Global<T>::New will output logs but
// glog is not constructed yet.
Global<std::shared_ptr<ForeignBoxingUtil>>::SetAllocated(
new std::shared_ptr<ForeignBoxingUtil>(boxing_util));
return Maybe<void>::Ok();
}

Expand Down
37 changes: 28 additions & 9 deletions oneflow/api/python/framework/op_expr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,33 +18,52 @@ limitations under the License.
#include "oneflow/api/python/of_api_registry.h"
#include "oneflow/core/common/protobuf.h"
#include "oneflow/core/framework/op_expr.h"
#include "oneflow/core/framework/op_interpreter.h"
#include "oneflow/core/framework/op_interpreter_util.h"
#include "oneflow/core/framework/tensor.h"
#include "oneflow/core/framework/tensor_tuple.h"

namespace py = pybind11;

namespace oneflow {

namespace {

Maybe<one::TensorTuple> Interpret(const one::OpExpr& op, const one::TensorTuple& inputs) {
CHECK_EQ_OR_RETURN(op.input_num(), inputs.size())
<< "The operation requires " << op.input_num() << " inputs, but " << inputs.size()
<< " is given.";
auto outputs = std::make_shared<one::TensorTuple>(op.output_num());
auto interperter = JUST(one::OpInterpUtil::GetInterpreter());
JUST(interperter->Apply(op, inputs, outputs.get()));
return outputs;
}

Maybe<std::vector<std::shared_ptr<one::Tensor>>> Interpret(
const std::shared_ptr<one::OpExpr>& op,
const std::vector<std::shared_ptr<one::Tensor>>& inputs) {
// TODO(): Execute the op by Autograd.
UNIMPLEMENTED();
return std::make_shared<std::vector<std::shared_ptr<one::Tensor>>>();
const one::OpExpr& op, const std::vector<std::shared_ptr<one::Tensor>>& inputs) {
one::TensorTuple input_list(inputs.size());
for (int i = 0; i < inputs.size(); ++i) { input_list[i] = inputs[i]; }
const auto& outputs = JUST(Interpret(op, input_list));
return static_cast<std::shared_ptr<std::vector<std::shared_ptr<one::Tensor>>>>(outputs);
}

} // namespace

ONEFLOW_API_PYBIND11_MODULE("one", m) {
py::class_<one::OpExpr, std::shared_ptr<one::OpExpr>>(m, "OpExpr")
.def("apply", [](const std::shared_ptr<one::OpExpr>& op_expr,
const std::vector<std::shared_ptr<one::Tensor>>& inputs) {
return Interpret(op_expr, inputs).GetOrThrow();
.def("apply",
[](const one::OpExpr& op_expr, const std::vector<std::shared_ptr<one::Tensor>>& inputs) {
return Interpret(op_expr, inputs).GetOrThrow();
})
.def("apply", [](const one::OpExpr& op_expr, const one::TensorTuple& inputs) {
return Interpret(op_expr, inputs).GetPtrOrThrow();
});

py::class_<one::BuiltinOpExpr, one::OpExpr, std::shared_ptr<one::BuiltinOpExpr>>(m,
"BuiltinOpExpr")
.def_property_readonly("name", &one::BuiltinOpExpr::op_name);

py::class_<one::UserOpExpr, one::BuiltinOpExpr, std::shared_ptr<one::UserOpExpr>>(m, "UserOpExpr")
.def(py::init<>())
.def_property_readonly("type", &one::UserOpExpr::type)
.def_property_readonly(
"proto", [](const one::UserOpExpr& op) { return PbMessage2TxtString(op.proto()); })
Expand Down
14 changes: 13 additions & 1 deletion oneflow/api/python/framework/session_util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,19 @@ namespace oneflow {

ONEFLOW_API_PYBIND11_MODULE("", m) {
py::class_<Session, std::shared_ptr<Session>>(m, "Session")
.def_property_readonly("id", &Session::id);
.def_property_readonly("id", &Session::id)
.def("push_mirrored_strategy_enabled",
[](Session* sess, const bool& val) {
sess->PushMirroredStrategyEnabled(val).GetOrThrow();
})
.def("pop_mirrored_strategy_enabled",
[](Session* sess) { sess->PopMirroredStrategyEnabled().GetOrThrow(); })
.def("is_mirrored_strategy_enabled",
[](const Session* sess) { return sess->IsMirroredStrategyEnabled().GetOrThrow(); })
.def("is_consistent_strategy_enabled",
[](const Session* sess) { return sess->IsConsistentStrategyEnabled().GetOrThrow(); })
.def("is_mirrored_strategy_enabled_stack_size",
[](const Session* sess) { return sess->is_mirrored_strategy_enabled_stack()->size(); });

m.def("GetDefaultSessionId", []() { return GetDefaultSessionId().GetOrThrow(); });
m.def("RegsiterSession", [](int64_t id) { return RegsiterSession(id).GetPtrOrThrow(); });
Expand Down
8 changes: 4 additions & 4 deletions oneflow/core/framework/op_builder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,10 @@ Maybe<OpBuilder&> OpBuilder::MaybeInput(const std::string& input_name, const int
CHECK_GT_OR_RETURN(count, 0);
CHECK_EQ_OR_RETURN(proto_.input().count(input_name), 0)
<< "The Input " << input_name << " has been specified more than once.";
auto& input_list = (*(proto_.mutable_input()))[input_name];
auto* input_list = &((*(proto_.mutable_input()))[input_name]);
for (int i = 0; i < count; ++i) {
const std::string& tensor_name = _PositionalPlaceholderPrefix + std::to_string(input_pos_++);
input_list.mutable_s()->Add()->assign(tensor_name);
input_list->mutable_s()->Add()->assign(tensor_name);
indexed_ibns_.push_back(input_name + "_" + std::to_string(i));
}
return *this;
Expand All @@ -58,10 +58,10 @@ Maybe<OpBuilder&> OpBuilder::MaybeOutput(const std::string& output_name, const i
CHECK_GT_OR_RETURN(count, 0);
CHECK_EQ_OR_RETURN(proto_.output().count(output_name), 0)
<< "The output " << output_name << " has been specified more than once.";
auto& output_list = (*(proto_.mutable_output()))[output_name];
auto* output_list = &((*(proto_.mutable_output()))[output_name]);
for (int i = 0; i < count; ++i) {
const std::string& tensor_name = op_name_ + "/" + output_name + "_" + std::to_string(i);
output_list.mutable_s()->Add()->assign(tensor_name);
output_list->mutable_s()->Add()->assign(tensor_name);
indexed_obns_.push_back(output_name + "_" + std::to_string(i));
}
return *this;
Expand Down
77 changes: 0 additions & 77 deletions oneflow/core/framework/op_expr.cpp

This file was deleted.

88 changes: 44 additions & 44 deletions oneflow/core/framework/op_expr.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,37 +16,40 @@ limitations under the License.
#ifndef ONEFLOW_CORE_FRAMEWORK_OP_EXPR_H_
#define ONEFLOW_CORE_FRAMEWORK_OP_EXPR_H_

#include "oneflow/core/common/util.h"
#include "oneflow/core/framework/user_op_conf.pb.h"
#include "oneflow/core/operator/op_conf.pb.h"

namespace oneflow {
namespace one {

#define DEFINE_DEFAULT_CONSTRUCTOR(class_type) \
class_type() = default; \
virtual ~class_type() = default;

class OpExpr {
public:
DEFINE_DEFAULT_CONSTRUCTOR(OpExpr);
explicit OpExpr(const std::string& type) : type_(type) {}
virtual ~OpExpr() = default;

const std::string& type() const { return type_; }

virtual std::shared_ptr<OpExpr> GetBackwardOpExpr() const = 0;
virtual std::string type() const = 0;
virtual int input_num() const = 0;
virtual int output_num() const = 0;

private:
std::string type_;
};

class BuiltinOpExpr : public OpExpr {
public:
DEFINE_DEFAULT_CONSTRUCTOR(BuiltinOpExpr);
explicit BuiltinOpExpr(const std::string& type, const std::string& op_name,
const std::vector<std::string>& indexed_ibns,
const std::vector<std::string>& indexed_obns)
: OpExpr(type), op_name_(op_name), indexed_ibns_(indexed_ibns), indexed_obns_(indexed_obns) {}

explicit BuiltinOpExpr(const std::string& op_name) : op_name_(op_name) {}
BuiltinOpExpr(const std::string& op_name, const std::vector<std::string>& indexed_ibns,
const std::vector<std::string>& indexed_obns)
: op_name_(op_name), indexed_ibns_(indexed_ibns), indexed_obns_(indexed_obns) {}
virtual ~BuiltinOpExpr() = default;

const std::string& op_name() const { return op_name_; }

int input_num() const { return indexed_ibns_.size(); }
int output_num() const { return indexed_obns_.size(); }
int input_num() const override { return indexed_ibns_.size(); }
int output_num() const override { return indexed_obns_.size(); }

const std::vector<std::string>& indexed_ibns() const { return indexed_ibns_; }
const std::vector<std::string>& indexed_obns() const { return indexed_obns_; }
Expand All @@ -61,30 +64,27 @@ class BuiltinOpExpr : public OpExpr {
std::vector<std::string> indexed_obns_;
};

#define DEFINE_BUILTIN_OPEXPR_CLASS(_op_name, _op_conf) \
class _op_name##Expr : public BuiltinOpExpr { \
public: \
_op_name##Expr() = default; \
virtual ~_op_name##Expr() = default; \
explicit _op_name##Expr(const std::string& op_name, _op_name##Conf&& proto, \
const std::vector<std::string>& indexed_ibns, \
const std::vector<std::string>& indexed_obns) \
: BuiltinOpExpr(op_name, indexed_ibns, indexed_obns), proto_(proto) {} \
\
std::shared_ptr<OpExpr> GetBackwardOpExpr() const override; \
\
std::string type() const override { return std::string(#_op_name); } \
\
const _op_name##Conf& proto() const { return proto_; } \
_op_name##Conf* mutable_proto() { return &proto_; } \
\
void BuildOpConf(OperatorConf* op_conf) const { \
*(op_conf->mutable_name()) = this->op_name_; \
*(op_conf->mutable_##_op_conf##_conf()) = proto_; \
} \
\
private: \
_op_name##Conf proto_; \
#define DEFINE_BUILTIN_OPEXPR_CLASS(_op_name, _op_conf) \
class _op_name##Expr : public BuiltinOpExpr { \
public: \
_op_name##Expr() = default; \
virtual ~_op_name##Expr() = default; \
explicit _op_name##Expr(const std::string& op_name, _op_name##Conf&& proto, \
const std::vector<std::string>& indexed_ibns, \
const std::vector<std::string>& indexed_obns) \
: BuiltinOpExpr(OF_PP_STRINGIZE(_op_name), op_name, indexed_ibns, indexed_obns), \
proto_(std::move(proto)) {} \
\
const _op_name##Conf& proto() const { return proto_; } \
_op_name##Conf* mutable_proto() { return &proto_; } \
\
void BuildOpConf(OperatorConf* op_conf) const { \
*(op_conf->mutable_name()) = this->op_name_; \
*(op_conf->mutable_##_op_conf##_conf()) = proto_; \
} \
\
private: \
_op_name##Conf proto_; \
};

DEFINE_BUILTIN_OPEXPR_CLASS(UserOp, user);
Expand All @@ -101,16 +101,16 @@ DEFINE_BUILTIN_OPEXPR_CLASS(DistributeAddOp, distribute_add);
// TODO(): Finish the class definition of `FunctionOpExpr`.
class FunctionOpExpr : public OpExpr {
public:
DEFINE_DEFAULT_CONSTRUCTOR(FunctionOpExpr);

std::shared_ptr<OpExpr> GetBackwardOpExpr() const override;
FunctionOpExpr() : OpExpr("FunctionOp") {}
virtual ~FunctionOpExpr() = default;

std::string type() const override { return "FunctionOp"; }
int input_num() const override { UNIMPLEMENTED(); }
int output_num() const override { UNIMPLEMENTED(); }
};

#undef DEFINE_DEFAULT_CONSTRUCTOR

} // namespace one
} // namespace oneflow

#undef DEFINE_DEFAULT_CONSTRUCTOR

#endif // ONEFLOW_CORE_FRAMEWORK_OP_EXPR_H_
Loading