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

Implement all User Ops with Op Schema #7032

Merged
merged 188 commits into from
Dec 24, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
188 commits
Select commit Hold shift + click to select a range
5df7f6f
add oneflow-tblgen: generate op schema (OpInterpCtx) from ods
PragmaTwice Dec 6, 2021
5b05e33
Merge branch 'master' of github.com:Oneflow-Inc/oneflow into oneflow-…
PragmaTwice Dec 6, 2021
11805cd
cmake: add inja
PragmaTwice Dec 7, 2021
301ba1f
tblgen: add oneflow_datatype
PragmaTwice Dec 7, 2021
38baa2a
tblgen: use option cat
PragmaTwice Dec 7, 2021
486806a
tblgen: fix error
PragmaTwice Dec 7, 2021
3a633be
Merge branch 'master' of https://github.com/Oneflow-Inc/oneflow into …
hjchen2 Dec 8, 2021
f9b780f
tblgen: put impl in .cpp
PragmaTwice Dec 8, 2021
df8ebd4
tblgen: fix null attrs
PragmaTwice Dec 8, 2021
7139787
Merge branch 'oneflow-tblgen' of https://github.com/PragmaTwice/onefl…
hjchen2 Dec 8, 2021
827109f
tblgen: fix null ops
PragmaTwice Dec 8, 2021
f59e4f1
refine
jackalcooper Dec 9, 2021
7830831
refine
jackalcooper Dec 9, 2021
c8eadb2
reifne
jackalcooper Dec 10, 2021
7bc9b45
Refine op schema template and compilation
hjchen2 Dec 10, 2021
ee80289
Merge remote-tracking branch 'origin/dev_refine_oneflow-tblgen' into …
PragmaTwice Dec 10, 2021
a23f18a
add base OpInterpCtx to finish compilation
hjchen2 Dec 10, 2021
fbda837
Merge remote-tracking branch 'origin/dev_refine_oneflow-tblgen' into …
PragmaTwice Dec 10, 2021
45cc3b7
fix
jackalcooper Dec 13, 2021
0c1ad3b
refine
jackalcooper Dec 13, 2021
fc927c5
fix
jackalcooper Dec 13, 2021
87c5bf2
add custom infer code
hjchen2 Dec 13, 2021
a0df94b
Merge branch 'oneflow-tblgen' of https://github.com/PragmaTwice/onefl…
hjchen2 Dec 13, 2021
e5ee652
generate op registrants automatically
hjchen2 Dec 14, 2021
94a16eb
merge install-oneflow-tblgen
hjchen2 Dec 14, 2021
072b6fd
refine
jackalcooper Dec 14, 2021
720148a
Merge branch 'master' of https://github.com/Oneflow-Inc/oneflow into …
hjchen2 Dec 14, 2021
ee74f56
fix
hjchen2 Dec 14, 2021
cca24f3
Merge branch 'dev_refine_oneflow-tblgen' of https://github.com/Oneflo…
hjchen2 Dec 14, 2021
0f13030
update user op ods and fix shape attr
hjchen2 Dec 14, 2021
7fcb0d8
refine
jackalcooper Dec 14, 2021
83cc197
refine
jackalcooper Dec 15, 2021
eeee47e
add custom code in op base
hjchen2 Dec 15, 2021
274173a
Merge branch 'dev_refine_oneflow-tblgen' of https://github.com/Oneflo…
hjchen2 Dec 15, 2021
656f393
refine comments
jackalcooper Dec 15, 2021
248225e
add same_output_regst_num and infer
jackalcooper Dec 15, 2021
4f5f3d5
support declare hasxx
jackalcooper Dec 15, 2021
4bb8183
update op schema emitter
hjchen2 Dec 15, 2021
cd5ddb5
Merge branch 'dev_refine_oneflow-tblgen' of https://github.com/Oneflo…
hjchen2 Dec 15, 2021
1c05fe6
refine
hjchen2 Dec 15, 2021
2e905c4
emit output regist num
hjchen2 Dec 15, 2021
fb1f180
refine
jackalcooper Dec 15, 2021
f5586f6
refine
jackalcooper Dec 15, 2021
41e2f52
migrate acc op
hjchen2 Dec 16, 2021
22f7ad5
migrate onerec_reader, ones_like, send, pack and padding ops
hjchen2 Dec 16, 2021
5936f1d
add has_sbp_signature_infer_fn
jackalcooper Dec 16, 2021
bc7af62
Merge branch 'snapshot-before-migrating-to-op-registry' of https://gi…
hjchen2 Dec 16, 2021
0eea5d5
refine
jackalcooper Dec 16, 2021
a1ebc0a
migrate pad, parallel_cast, partial_fc and pooling ops
hjchen2 Dec 16, 2021
d0eb642
rm redundant has_device_infer_fn
jackalcooper Dec 16, 2021
cee3448
Merge branch 'snapshot-before-migrating-to-op-registry' of https://gi…
hjchen2 Dec 16, 2021
eea07dd
migrate prelu, quantization, randperm, reduce and repeat ops
hjchen2 Dec 16, 2021
96feed9
migrate reshape, reshape_like, roi_align, same_pad, selu and scalar r…
hjchen2 Dec 16, 2021
c589138
back port
jackalcooper Dec 16, 2021
6f625b7
backport
jackalcooper Dec 16, 2021
da707ff
migrate ops
hjchen2 Dec 16, 2021
a59e793
Merge branch 'dev_refine_oneflow-tblgen' of https://github.com/Oneflo…
jackalcooper Dec 16, 2021
9004621
Merge branch 'master' of https://github.com/Oneflow-Inc/oneflow into …
jackalcooper Dec 17, 2021
703577f
refine
jackalcooper Dec 17, 2021
b9f6b41
refine
jackalcooper Dec 17, 2021
8da680f
Merge branch 'snapshot-before-migrating-to-op-registry' of https://gi…
jackalcooper Dec 17, 2021
bdf9ccb
refine
jackalcooper Dec 17, 2021
a0b4368
refine
jackalcooper Dec 17, 2021
7795614
add new op
jackalcooper Dec 17, 2021
2feecb0
Merge branch 'snapshot-before-migrating-to-op-registry' of https://gi…
jackalcooper Dec 17, 2021
5803039
fix llvm not found
jackalcooper Dec 17, 2021
e39c8cf
fix mlir headers
jackalcooper Dec 17, 2021
e6d49d2
fix mlir headers
jackalcooper Dec 17, 2021
febe1c1
fix llvm not found
jackalcooper Dec 17, 2021
03c8ebe
irefine
jackalcooper Dec 17, 2021
87d281c
Merge branch 'snapshot-before-migrating-to-op-registry' of https://gi…
jackalcooper Dec 17, 2021
eaaa7cb
Merge branch 'master' of https://github.com/Oneflow-Inc/oneflow into …
jackalcooper Dec 17, 2021
db9918d
Merge branch 'snapshot-before-migrating-to-op-registry' of https://gi…
jackalcooper Dec 17, 2021
11b0474
mark override
hjchen2 Dec 17, 2021
632fe63
Merge branch 'dev_refine_oneflow-tblgen' of https://github.com/Oneflo…
hjchen2 Dec 17, 2021
8139e6d
fix merge
hjchen2 Dec 17, 2021
828bd2a
fix
hjchen2 Dec 17, 2021
2982c60
fix
hjchen2 Dec 17, 2021
5aa7fd7
set op schema as obj lib to speed up
jackalcooper Dec 17, 2021
5710809
rewrite ops
PragmaTwice Dec 18, 2021
fb5e0b9
add addn
jackalcooper Dec 18, 2021
bc7405f
add grdi
jackalcooper Dec 18, 2021
3b5d842
refien
jackalcooper Dec 18, 2021
72df539
add more def (#7051)
jackalcooper Dec 19, 2021
6e84a31
move more ops
PragmaTwice Dec 20, 2021
9fc07d0
fix math_binary_broadcast/elementwise_ops
PragmaTwice Dec 20, 2021
b0b401d
fix hardtanh
PragmaTwice Dec 20, 2021
39bf11e
add norm
PragmaTwice Dec 20, 2021
e4f784b
rename file and add CpuOnly no_grad
jackalcooper Dec 20, 2021
d4afeec
fix ir & fix norm op
PragmaTwice Dec 20, 2021
176de6b
fix oneflow-tblgen
PragmaTwice Dec 20, 2021
438b73d
Merge branch 'snapshot-before-migrating-to-op-registry' into dev_refi…
PragmaTwice Dec 20, 2021
f481961
fix math_unary_elementwise_op
PragmaTwice Dec 20, 2021
1759c4e
fix norm
PragmaTwice Dec 20, 2021
f0cba8a
fix bn
jackalcooper Dec 20, 2021
1b0b5d5
fix op schema
PragmaTwice Dec 20, 2021
f85e730
refine
jackalcooper Dec 20, 2021
0b18042
fix
jackalcooper Dec 20, 2021
566d13a
refine physical_tensor_desc_infer_fn
jackalcooper Dec 20, 2021
aeaa7eb
Merge branch 'snapshot-before-migrating-to-op-registry' of https://gi…
jackalcooper Dec 20, 2021
7f2756b
refine
jackalcooper Dec 20, 2021
3043bc0
add ScalarLogicalNotEqualOp & RecvOp
PragmaTwice Dec 20, 2021
8078eff
Merge branch 'master' of https://github.com/Oneflow-Inc/oneflow into …
jackalcooper Dec 21, 2021
250f2d3
Merge branch 'snapshot-before-migrating-to-op-registry' of https://gi…
jackalcooper Dec 21, 2021
6b27070
refine
jackalcooper Dec 21, 2021
d3484fc
auto format by CI
oneflow-ci-bot Dec 21, 2021
e5e81a7
fix fmt
jackalcooper Dec 21, 2021
359f7d7
add cuda only trait
jackalcooper Dec 21, 2021
6c0a9f1
delete unused inja
jackalcooper Dec 21, 2021
0d4adb0
del inja_copy_headers_to_destination
jackalcooper Dec 21, 2021
5f165e7
delete unused inja
jackalcooper Dec 21, 2021
8e5c577
del inja_copy_headers_to_destination
jackalcooper Dec 21, 2021
ffe546f
add cuda only to tblgen
PragmaTwice Dec 21, 2021
3b2e174
Merge branch 'snapshot-before-migrating-to-op-registry' of github.com…
PragmaTwice Dec 21, 2021
fce4766
fix json inja url and md5 not used
jackalcooper Dec 21, 2021
5664086
fix json inja url and md5 not used
jackalcooper Dec 21, 2021
884ad47
Merge branch 'snapshot-before-migrating-to-op-registry' into dev_refi…
PragmaTwice Dec 21, 2021
b035d24
refine
jackalcooper Dec 21, 2021
b589bf9
revert
jackalcooper Dec 21, 2021
8e96814
Merge branch 'snapshot-before-migrating-to-op-registry' of https://gi…
jackalcooper Dec 21, 2021
78de138
Merge branch 'snapshot-before-migrating-to-op-registry' of https://gi…
jackalcooper Dec 21, 2021
0a171f1
add with cuda
jackalcooper Dec 21, 2021
399c055
Merge branch 'dev_refine_oneflow-tblgen' of github.com:oneflow-inc/on…
PragmaTwice Dec 21, 2021
b003ddf
refine
jackalcooper Dec 21, 2021
34bc136
Merge branch 'dev_refine_oneflow-tblgen' of https://github.com/Oneflo…
jackalcooper Dec 21, 2021
cfe189b
Merge branch 'master' into dev_refine_oneflow-tblgen
jackalcooper Dec 21, 2021
a6356ef
delete GenUserOpODS
jackalcooper Dec 21, 2021
9c5cc8b
Merge branch 'dev_refine_oneflow-tblgen' of https://github.com/Oneflo…
jackalcooper Dec 21, 2021
f991846
remove cuda only
PragmaTwice Dec 21, 2021
b022e6a
revert cuda only after meeting
jackalcooper Dec 21, 2021
684968b
Merge branch 'master' of https://github.com/Oneflow-Inc/oneflow into …
jackalcooper Dec 21, 2021
0931842
Merge branch 'snapshot-before-migrating-to-op-registry' of https://gi…
jackalcooper Dec 21, 2021
1e03548
fix
jackalcooper Dec 21, 2021
a097c67
Merge branch 'dev_refine_oneflow-tblgen' of https://github.com/Oneflo…
jackalcooper Dec 21, 2021
49d819b
gen checks for ops with variadic args
jackalcooper Dec 21, 2021
66dc0b2
Merge branch 'snapshot-before-migrating-to-op-registry' of https://gi…
jackalcooper Dec 21, 2021
ecd4c73
fix github actions test.yml
PragmaTwice Dec 22, 2021
0ad8e1c
add check for Variadic inputs outpus
jackalcooper Dec 22, 2021
1a750cc
refine
jackalcooper Dec 22, 2021
af21a21
refine
jackalcooper Dec 22, 2021
7ef61ca
refine
jackalcooper Dec 22, 2021
2e6dccb
Merge branch 'dev_refine_oneflow-tblgen' of https://github.com/Oneflo…
jackalcooper Dec 22, 2021
5b655a9
fix GetInputArgModifier & GetOutputArgModifier
PragmaTwice Dec 22, 2021
1e99196
Merge branch 'dev_refine_oneflow-tblgen' of github.com:oneflow-inc/on…
PragmaTwice Dec 22, 2021
1616571
fix relu bn
jackalcooper Dec 22, 2021
df4bb1f
fix hash
PragmaTwice Dec 22, 2021
387d597
Merge branch 'dev_refine_oneflow-tblgen' of https://github.com/Oneflo…
jackalcooper Dec 22, 2021
cc42b58
fix
jackalcooper Dec 22, 2021
7e39413
fix in/out/attr order
PragmaTwice Dec 22, 2021
4749d84
fix load and save case
jackalcooper Dec 22, 2021
6b675a0
fix static check error
PragmaTwice Dec 22, 2021
c631cf0
Merge branch 'dev_refine_oneflow-tblgen' of github.com:oneflow-inc/on…
PragmaTwice Dec 22, 2021
c1945d5
fix static check error (2)
PragmaTwice Dec 22, 2021
e095aef
fix
jackalcooper Dec 22, 2021
f4c7fae
Merge branch 'dev_refine_oneflow-tblgen' of https://github.com/Oneflo…
jackalcooper Dec 22, 2021
f3f5b16
fix testrelu
jackalcooper Dec 22, 2021
41b7f92
Merge branch 'master' into dev_refine_oneflow-tblgen
jackalcooper Dec 22, 2021
ceb6483
Merge branch 'master' into dev_refine_oneflow-tblgen
jackalcooper Dec 22, 2021
26a932a
fix
jackalcooper Dec 23, 2021
0211028
Merge branch 'master' into dev_refine_oneflow-tblgen
jackalcooper Dec 23, 2021
3b4cce9
add ctest
jackalcooper Dec 23, 2021
863042f
refine
jackalcooper Dec 23, 2021
b490742
refine
jackalcooper Dec 23, 2021
b720c1e
refine
jackalcooper Dec 23, 2021
3567e2d
refine
jackalcooper Dec 23, 2021
4ec7e03
refine
jackalcooper Dec 23, 2021
8ab8bac
support resouce
jackalcooper Dec 23, 2021
affe99e
refine
jackalcooper Dec 23, 2021
95ba129
refine
jackalcooper Dec 23, 2021
429f037
fix
jackalcooper Dec 23, 2021
d10fece
fix
jackalcooper Dec 23, 2021
a31f4a2
refine
jackalcooper Dec 23, 2021
d80d4cb
Merge branch 'master' of https://github.com/Oneflow-Inc/oneflow into …
jackalcooper Dec 23, 2021
35cbc54
Merge branch 'master' of https://github.com/Oneflow-Inc/oneflow into …
jackalcooper Dec 23, 2021
fbb40d3
refine
jackalcooper Dec 23, 2021
1d5c0a6
fix
jackalcooper Dec 23, 2021
2d71b9d
refine
jackalcooper Dec 23, 2021
e865ad2
fix NormalizationAddReluFunctor
jackalcooper Dec 23, 2021
8bf413c
refine
jackalcooper Dec 23, 2021
01bcec2
Merge branch 'master' into dev_refine_oneflow-tblgen
jackalcooper Dec 23, 2021
6c1e60f
fix
jackalcooper Dec 23, 2021
e9e1c21
Merge branch 'master' into dev_refine_oneflow-tblgen
jackalcooper Dec 24, 2021
a7c8b4b
Merge branch 'master' into dev_refine_oneflow-tblgen
oneflow-ci-bot Dec 24, 2021
bb4397a
Merge branch 'master' into dev_refine_oneflow-tblgen
oneflow-ci-bot Dec 24, 2021
0225280
remove unused
jackalcooper Dec 24, 2021
57347dd
rm
jackalcooper Dec 24, 2021
529b79b
Merge branch 'dev_refine_oneflow-tblgen' of https://github.com/Oneflo…
jackalcooper Dec 24, 2021
42c1bed
Merge branch 'master' into dev_refine_oneflow-tblgen
jackalcooper Dec 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
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -806,7 +806,7 @@ jobs:
-DBUILD_TESTING=ON \
-DCMAKE_C_COMPILER_LAUNCHER=ccache \
-DCMAKE_CXX_COMPILER_LAUNCHER=ccache
cmake --build . -j$(nproc) --target oneflow_deps of_cfgobj of_protoobj of_functional_obj of_functional_tensor_obj
cmake --build . -j$(nproc) --target oneflow_deps of_cfgobj of_protoobj of_functional_obj of_functional_tensor_obj of_op_schema
- name: Fetch upstream
if: ${{ !fromJSON(steps.save-cache.outputs.cache-hit) && github.event.pull_request.head.repo.full_name != github.event.pull_request.base.repo.full_name }}
run: |
Expand Down
10 changes: 10 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ option(WITH_OPENVINO "Option to build with OpenVINO" OFF)
option(WITH_MLIR "" OFF)
option(WITH_MLIR_CUDA_CODEGEN "" OFF)
set(LLVM_PROVIDER "in-tree" CACHE STRING "in-tree, install")
if (NOT WITH_MLIR)
set(LLVM_PROVIDER "install" CACHE STRING "in-tree will build LLVM's ALL, not what we want when not building MLIR" FORCE)
endif(NOT WITH_MLIR)
option(WITH_COCOAPI "Option to build with COCO API" ON)
option(WITH_ZLIB "" ON)
option(BUILD_GIT_VERSION "" ON)
Expand Down Expand Up @@ -223,6 +226,12 @@ if(BUILD_CPP_API)
endif(BUILD_SHARED_LIBS)
endif(BUILD_CPP_API)

set(INJA_URL https://github.com/pantor/inja/archive/refs/tags/v3.3.0.zip CACHE STRING "")
use_mirror(VARIABLE INJA_URL URL ${INJA_URL})
set(INJA_MD5 611e6b7206d0fb89728a3879f78b4775 CACHE STRING "")
set(JSON_URL https://github.com/nlohmann/json/releases/download/v3.7.3/include.zip CACHE STRING "")
use_mirror(VARIABLE JSON_URL URL ${JSON_URL})
set(JSON_MD5 fb96f95cdf609143e998db401ca4f324 CACHE STRING "")
include(third_party)

if (BUILD_CUDA)
Expand Down Expand Up @@ -275,3 +284,4 @@ add_custom_target(oneflow_deps ALL DEPENDS prepare_oneflow_third_party)
if (ONEFLOW)
include(oneflow)
endif()
add_subdirectory(ci)
1 change: 1 addition & 0 deletions ci/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
add_subdirectory(test)
25 changes: 25 additions & 0 deletions ci/test/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
set(PYTHON_EXECUTABLE python3 CACHE STRING "python3 exe to run test, usually is the python3 installation oneflow is linked to")
set(ONEFLOW_SRC_DIR ${CMAKE_SOURCE_DIR} CACHE STRING "source dir of oneflow")
set(IS_DEV ON CACHE BOOL "")
set(CTEST_RESOURCE_SPEC_FILE "${CMAKE_CURRENT_SOURCE_DIR}/resource-spec/2x-rtx-2080.json" CACHE STRING "")

# CTEST_OUTPUT_ON_FAILURE=1 CTEST_PARALLEL_LEVEL=20 ninja test

file(GLOB_RECURSE PYTHON_TEST_FILES LIST_DIRECTORIES false RELATIVE ${ONEFLOW_SRC_DIR} "${ONEFLOW_SRC_DIR}/python/oneflow/test_*.py")
foreach(PYTHON_TEST_FILE ${PYTHON_TEST_FILES})
set(TEST_NAME ${PYTHON_TEST_FILE})
add_test(NAME ${TEST_NAME}
COMMAND ${PYTHON_EXECUTABLE} ${ONEFLOW_SRC_DIR}/${PYTHON_TEST_FILE} --failfast --verbose
)
set_tests_properties(${TEST_NAME}
PROPERTIES
ENVIRONMENT "$<$<NOT:$<BOOL:${BUILD_CUDA}>>:ONEFLOW_TEST_CPU_ONLY=1>;$<$<BOOL:${IS_DEV}>:PYTHONPATH=${ONEFLOW_SRC_DIR}/python:$ENV{PYTHONPATH}>"
RESOURCE_GROUPS
"vram:2000"
)
endforeach()
set_tests_properties(python/oneflow/test/modules/test_rnn.py
PROPERTIES
RESOURCE_GROUPS
"vram:4000"
)
16 changes: 16 additions & 0 deletions ci/test/resource-spec/1x-gtx-1080.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"version": {
"major": 1,
"minor": 0
},
"local": [
{
"vram": [
{
"id": "0",
"slots": 8117
}
]
}
]
}
20 changes: 20 additions & 0 deletions ci/test/resource-spec/2x-rtx-2080.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"version": {
"major": 1,
"minor": 0
},
"local": [
{
"vram": [
{
"id": "0",
"slots": 7982
},
{
"id": "1",
"slots": 7982
}
]
}
]
}
28 changes: 28 additions & 0 deletions ci/test/resource-spec/4x-rtx-2080ti.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
"version": {
"major": 1,
"minor": 0
},
"local": [
{
"vram": [
{
"id": "0",
"slots": 11019
},
{
"id": "1",
"slots": 11019
},
{
"id": "2",
"slots": 11019
},
{
"id": "3",
"slots": 11019
}
]
}
]
}
30 changes: 16 additions & 14 deletions cmake/oneflow.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@ add_custom_target(of_format
COMMAND ${Python_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/ci/check/run_license_format.py -i ${ONEFLOW_PYTHON_DIR} --fix --exclude="oneflow/include" --exclude="oneflow/core"
COMMAND ${Python_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/ci/check/run_clang_format.py --source_dir ${CMAKE_CURRENT_SOURCE_DIR}/oneflow --fix --quiet
COMMAND ${Python_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/ci/check/run_py_format.py --source_dir ${CMAKE_CURRENT_SOURCE_DIR} --fix
COMMAND ${Python_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/ci/check/run_clang_format.py --source_dir ${CMAKE_CURRENT_SOURCE_DIR}/tools/oneflow-tblgen --fix --quiet
)
# clang tidy
add_custom_target(of_tidy
Expand Down Expand Up @@ -244,6 +245,7 @@ oneflow_add_library(oneflow ${of_all_obj_cc})
add_dependencies(oneflow of_protoobj)
add_dependencies(oneflow of_cfgobj)
add_dependencies(oneflow of_functional_obj)
add_dependencies(oneflow of_op_schema)
add_dependencies(oneflow of_git_version)

if (USE_CLANG_FORMAT)
Expand All @@ -255,38 +257,33 @@ endif()

target_compile_definitions(oneflow PRIVATE GOOGLE_LOGGING)

set(ONEFLOW_TOOLS_DIR "${PROJECT_BINARY_DIR}/tools")
oneflow_add_executable(oneflow-gen-ods EXCLUDE_FROM_ALL ${PROJECT_SOURCE_DIR}/oneflow/ir/oneflow-gen-ods/oneflow-gen-ods.cpp)
set_target_properties(oneflow-gen-ods PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${ONEFLOW_TOOLS_DIR}")
set(ONEFLOW_TOOLS_DIR "${PROJECT_BINARY_DIR}/tools" CACHE STRING "dir to put binary for debugging and development")

set(LLVM_MONO_REPO_URL "https://github.com/llvm/llvm-project/archive/649d95371680cbf7f740c990c0357372c2bd4058.zip" CACHE STRING "")
use_mirror(VARIABLE LLVM_MONO_REPO_URL URL ${LLVM_MONO_REPO_URL})
set(LLVM_MONO_REPO_MD5 "9bda804e5cc61899085fb0f0dce1089f" CACHE STRING "")
set(ONEFLOW_BUILD_ROOT_DIR "${PROJECT_BINARY_DIR}")
add_subdirectory(${PROJECT_SOURCE_DIR}/oneflow/ir)
if (WITH_MLIR)
add_subdirectory(${PROJECT_SOURCE_DIR}/oneflow/ir)
set(ONEFLOW_MLIR_LIBS -Wl,--no-as-needed MLIROneFlowExtension -Wl,--as-needed)
endif()

include(op_schema)

if(APPLE)
set(of_libs -Wl,-force_load oneflow of_protoobj of_cfgobj of_functional_obj)
set(of_libs -Wl,-force_load oneflow of_protoobj of_cfgobj of_functional_obj of_op_schema)
target_link_libraries(oneflow of_protoobj of_cfgobj of_functional_obj glog_imported gflags_imported ${oneflow_third_party_libs})
elseif(UNIX)
set(of_libs -Wl,--whole-archive oneflow of_protoobj of_cfgobj of_functional_obj -Wl,--no-whole-archive -ldl -lrt)
set(of_libs -Wl,--whole-archive oneflow of_protoobj of_cfgobj of_functional_obj of_op_schema -Wl,--no-whole-archive -ldl -lrt)
target_link_libraries(oneflow of_protoobj of_cfgobj of_functional_obj glog_imported gflags_imported ${oneflow_third_party_libs} -Wl,--no-whole-archive -ldl -lrt)
if(BUILD_CUDA)
target_link_libraries(oneflow CUDA::cudart_static)
endif()
elseif(WIN32)
set(of_libs oneflow of_protoobj of_cfgobj of_functional_obj)
set(of_libs oneflow of_protoobj of_cfgobj of_functional_obj of_op_schema)
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /WHOLEARCHIVE:oneflow")
endif()

target_link_libraries(oneflow-gen-ods ${of_libs} ${oneflow_third_party_libs} ${oneflow_exe_third_party_libs})
if (BUILD_CUDA)
target_link_libraries(oneflow-gen-ods CUDA::cudart_static)
endif()

if(BUILD_PYTHON)

# py ext lib
Expand All @@ -301,7 +298,7 @@ if(BUILD_PYTHON)
pybind11_add_module(oneflow_internal ${PYBIND11_SRCS} ${of_pybind_obj_cc} ${PYBIND_REGISTRY_CC})
set_compile_options_to_oneflow_target(oneflow_internal)
set_property(TARGET oneflow_internal PROPERTY CXX_VISIBILITY_PRESET "default")
add_dependencies(oneflow_internal of_cfgobj of_functional_obj of_functional_tensor_obj)
add_dependencies(oneflow_internal of_cfgobj of_functional_obj of_functional_tensor_obj of_op_schema)
set_target_properties(oneflow_internal PROPERTIES PREFIX "_")
set_target_properties(oneflow_internal PROPERTIES LIBRARY_OUTPUT_DIRECTORY "${ONEFLOW_PYTHON_DIR}/oneflow")
target_link_libraries(oneflow_internal PRIVATE
Expand Down Expand Up @@ -340,7 +337,7 @@ if(BUILD_PYTHON)
endif(BUILD_PYTHON)

if (BUILD_CPP_API)
file(GLOB_RECURSE of_cpp_api_files
file(GLOB_RECURSE of_cpp_api_files
${PROJECT_SOURCE_DIR}/oneflow/api/cpp/*.cpp
${PROJECT_SOURCE_DIR}/oneflow/api/cpp/*.h)
if(BUILD_MONOLITHIC_LIBONEFLOW_CPP_SO)
Expand All @@ -362,6 +359,11 @@ function(oneflow_add_test target_name)
endif()
set_target_properties(${target_name} PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/bin")
add_test(NAME ${arg_TEST_NAME} COMMAND ${target_name})
set_tests_properties(
${arg_TEST_NAME}
PROPERTIES
ENVIRONMENT "HTTP_PROXY='';HTTPS_PROXY='';http_proxy='';https_proxy='';"
)
endfunction()

# build test
Expand Down
90 changes: 90 additions & 0 deletions cmake/op_schema.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
get_property(LLVM_INSTALL_DIR GLOBAL PROPERTY LLVM_INSTALL_DIR)
set(LLVM_INSTALL_DIR ${THIRD_PARTY_DIR}/llvm)
set(LLVM_DIR ${LLVM_INSTALL_DIR}/lib/cmake/llvm)
set(ONEFLOW_OP_GROUPS
"ASSIGN"
"BINARY"
"BROADCAST"
"CONV"
"CROSS_ENTROPY"
"CUDA"
"DATASET"
"DETECTION"
"EAGER"
"FUSED"
"IDEMPOTENT"
"IDENTITY"
"IMAGE"
"INDICES"
"INVOLUTION"
"LOSS"
"MATH"
"MATMUL"
"MISC"
"NCCL"
"NORMALIZATION"
"OPTIMIZER"
"PADDING"
"PARALLEL_CAST"
"POOL"
"QUANTIZATION"
"REDUCE"
"RESHAPE"
"SCALAR"
"SOFTMAX"
"SUMMARY"
"TENSOR_BUFFER"
"TEST"
"TRIGONOMETRIC"
"UNARY"
"UPSAMPLE"
)
foreach (OP_GROUP_NAME IN LISTS ONEFLOW_OP_GROUPS)
list(APPEND ONEFLOW_SCHEMA_TABLEGEN_FLAGS "-DGET_ONEFLOW_${OP_GROUP_NAME}_OP_DEFINITIONS")
endforeach()
list(APPEND ONEFLOW_SCHEMA_TABLEGEN_FLAGS "-DREMOVE_ONEFLOW_MLIR_ONLY_OP_DEFINITIONS")

set(GENERATED_OP_SCHEMA_DIR oneflow/core/framework)
set(GENERATED_IR_INCLUDE_DIR oneflow/ir/include)
set(SOURCE_IR_INCLUDE_DIR ${PROJECT_SOURCE_DIR}/oneflow/ir/include)
set(ONEFLOW_ODS ${SOURCE_IR_INCLUDE_DIR}/OneFlow/OneFlowOps.td)

list(APPEND ONEFLOW_SCHEMA_TABLEGEN_FLAGS "-I${GENERATED_IR_INCLUDE_DIR}")
list(APPEND ONEFLOW_SCHEMA_TABLEGEN_FLAGS "-I${SOURCE_IR_INCLUDE_DIR}")
list(APPEND ONEFLOW_SCHEMA_TABLEGEN_FLAGS "-I${LLVM_INSTALL_DIR}/include")

set(GENERATED_OP_SCHEMA_H "${GENERATED_OP_SCHEMA_DIR}/op_generated.h")
set(GENERATED_OP_SCHEMA_CPP "${GENERATED_OP_SCHEMA_DIR}/op_generated.cpp")


set(ONEFLOW_TABLE_GEN_EXE ${LLVM_INSTALL_DIR}/bin/oneflow_tblgen)
if(LLVM_PROVIDER STREQUAL "in-tree")
set(ONEFLOW_TABLE_GEN_TARGET oneflow_tblgen install-oneflow-tblgen install-mlir-headers)
elseif(LLVM_PROVIDER STREQUAL "install")
set(ONEFLOW_TABLE_GEN_TARGET ${ONEFLOW_TABLE_GEN_EXE})
endif()

file(GLOB_RECURSE ODS_FILES LIST_DIRECTORIES false "${SOURCE_IR_INCLUDE_DIR}/*.td")
if(NOT ODS_FILES)
message(FATAL_ERROR "ODS_FILES not found: ${ODS_FILES}")
endif()
add_custom_command(
OUTPUT ${GENERATED_OP_SCHEMA_H} ${GENERATED_OP_SCHEMA_CPP}
COMMAND ${CMAKE_COMMAND}
ARGS -E make_directory ${GENERATED_OP_SCHEMA_DIR}
COMMAND ${ONEFLOW_TABLE_GEN_EXE}
ARGS --gen-op-schema-h ${ONEFLOW_ODS} ${ONEFLOW_SCHEMA_TABLEGEN_FLAGS} -o ${GENERATED_OP_SCHEMA_H}
COMMAND ${ONEFLOW_TABLE_GEN_EXE}
ARGS --gen-op-schema-cpp ${ONEFLOW_ODS} ${ONEFLOW_SCHEMA_TABLEGEN_FLAGS}
--op-include ${GENERATED_OP_SCHEMA_H} -o ${GENERATED_OP_SCHEMA_CPP}
DEPENDS ${ONEFLOW_TABLE_GEN_TARGET}
${ODS_FILES}
VERBATIM
)
set_source_files_properties(
${GENERATED_OP_SCHEMA_H} ${GENERATED_OP_SCHEMA_CPP} PROPERTIES GENERATED TRUE
)

oneflow_add_library(of_op_schema OBJECT ${GENERATED_OP_SCHEMA_H} ${GENERATED_OP_SCHEMA_CPP})
add_dependencies(of_op_schema of_cfgobj)
add_dependencies(of_op_schema prepare_oneflow_third_party)
1 change: 1 addition & 0 deletions cmake/third_party.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,7 @@ list(APPEND ONEFLOW_THIRD_PARTY_INCLUDE_DIRS
${COCOAPI_INCLUDE_DIR}
${HALF_INCLUDE_DIR}
${JSON_INCLUDE_DIR}
${INJA_INCLUDE_DIR}
${ABSL_INCLUDE_DIR}
${OPENSSL_INCLUDE_DIR}
${FLATBUFFERS_INCLUDE_DIR}
Expand Down
2 changes: 2 additions & 0 deletions cmake/third_party/json.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ if(THIRD_PARTY)
)
add_custom_target(json_create_header_dir
COMMAND ${CMAKE_COMMAND} -E make_directory ${JSON_INCLUDE_DIR}
COMMAND ${CMAKE_COMMAND} -E make_directory ${JSON_INCLUDE_DIR}/nlohmann
DEPENDS json
)
add_custom_target(json_copy_headers_to_destination
Expand All @@ -31,6 +32,7 @@ if(THIRD_PARTY)
foreach(header_file ${JSON_HEADERS})
add_custom_command(TARGET json_copy_headers_to_destination PRE_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_if_different ${header_file} ${JSON_INCLUDE_DIR}
COMMAND ${CMAKE_COMMAND} -E copy_if_different ${header_file} ${JSON_INCLUDE_DIR}/nlohmann
)
endforeach()
endif(THIRD_PARTY)
Loading