forked from pytorch/pytorch
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1f53d03
commit 0384780
Showing
34 changed files
with
3,888 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
load("@fbsource//tools/build_defs:fb_xplat_cxx_test.bzl", "fb_xplat_cxx_test") | ||
load("@fbsource//xplat/caffe2:pt_defs.bzl", "get_build_from_deps_query", "pt_operator_registry") | ||
|
||
DEFAULT_PT_OP_DEPS = [ | ||
"fbsource//xplat/caffe2:torch_mobile_ops_full_dev", | ||
] | ||
|
||
def pt_xplat_cxx_test(name, deps = [], pt_op_deps = DEFAULT_PT_OP_DEPS, **kwargs): | ||
code_gen_lib = [] | ||
if get_build_from_deps_query(): | ||
lib_name = name + "_lib" | ||
pt_operator_registry(lib_name, preferred_linkage = "static", template_select = False, deps = pt_op_deps) | ||
code_gen_lib = [":" + lib_name] | ||
deps = deps + code_gen_lib | ||
fb_xplat_cxx_test( | ||
name = name, | ||
deps = deps, | ||
**kwargs | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
load("@fbsource//tools/build_defs:expect.bzl", "expect") | ||
load( | ||
"@fbsource//tools/build_defs/apple:build_mode_defs.bzl", | ||
"is_production_build", | ||
) | ||
|
||
############################################################################### | ||
# Check if we need to strip glog. | ||
def _get_strip_glog_config(): | ||
c2_strip_glog = native.read_config("caffe2", "strip_glog", "1") | ||
expect( | ||
c2_strip_glog in ("0", "1"), | ||
c2_strip_glog, | ||
) | ||
return bool(int(c2_strip_glog)) | ||
|
||
# For iOS production builds (and all Android builds), strip GLOG logging to | ||
# save size. We can disable by setting caffe2.strip_glog=0 in .buckconfig.local. | ||
def get_fbobjc_strip_glog_flags(): | ||
if is_production_build() or _get_strip_glog_config(): | ||
return ["-UGOOGLE_STRIP_LOG", "-DGOOGLE_STRIP_LOG=3"] | ||
else: | ||
return ["-UGOOGLE_STRIP_LOG"] | ||
|
||
def get_fbandroid_strip_glog_flags(): | ||
if _get_strip_glog_config(): | ||
return ["-UGOOGLE_STRIP_LOG", "-DGOOGLE_STRIP_LOG=1"] | ||
else: | ||
return [] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,126 @@ | ||
load("@bazel_skylib//lib:paths.bzl", "paths") | ||
load("//caffe2:defs_hip.bzl", "get_hip_file_path") | ||
|
||
gpu_file_extensions = [".cu", ".c", ".cc", ".cpp"] | ||
gpu_header_extensions = [".cuh", ".h", ".hpp"] | ||
|
||
def is_test_files(filepath): | ||
if filepath.startswith("test"): | ||
return True | ||
else: | ||
return False | ||
|
||
def get_c10_hip_srcs(): | ||
gpu_file_pattern = [ | ||
base + suffix | ||
for base in c10_includes | ||
for suffix in gpu_file_extensions | ||
] | ||
native_gpu_files = native.glob(gpu_file_pattern) | ||
|
||
gpu_files = [] | ||
hip_files = [] | ||
for name in native_gpu_files: | ||
# exclude the test folder | ||
if is_test_files(name): | ||
continue | ||
|
||
gpu_files.append(name) | ||
hip_file_name = get_hip_file_path(paths.join("cuda/", name)) | ||
hip_files.append(hip_file_name) | ||
|
||
# there will be some native hip files that needs suffix changed | ||
native_hip_pattern = [ | ||
"hip/**/*.hip", | ||
] | ||
native_hip_files = native.glob(native_hip_pattern) | ||
|
||
gpu_files += native_hip_files | ||
hip_files += native_hip_files | ||
|
||
# we run hipify script under the caffe2 folder; therefore we need to | ||
# prepend c10 to the path so that buck can find the hipified file | ||
real_hip_files = [] | ||
for filename in hip_files: | ||
real_hip_files.append(paths.join("c10", filename)) | ||
|
||
# return the src and output_gen files | ||
return gpu_files, real_hip_files | ||
|
||
def get_c10_hip_headers(): | ||
gpu_file_pattern = [ | ||
base + suffix | ||
for base in c10_includes | ||
for suffix in gpu_header_extensions | ||
] | ||
native_gpu_files = native.glob(gpu_file_pattern) | ||
|
||
# store the original | ||
gpu_files = [] | ||
hip_files = [] | ||
for name in native_gpu_files: | ||
if is_test_files(name): | ||
continue | ||
|
||
gpu_files.append(name) | ||
hip_file_name = get_hip_file_path(paths.join("cuda/", name)) | ||
hip_files.append(hip_file_name) | ||
|
||
# there will be some native hip files that needs suffix changed | ||
native_hip_pattern = [ | ||
"hip/**/*" + suffix | ||
for suffix in gpu_header_extensions | ||
] | ||
native_hip_files = native.glob(native_hip_pattern) | ||
|
||
gpu_files += native_hip_files | ||
hip_files += native_hip_files | ||
|
||
# we run hipify script under the caffe2 folder; therefore we need to | ||
# prepend c10 to the path so that buck can find the hipified file | ||
real_hip_files = [] | ||
for filename in hip_files: | ||
real_hip_files.append(paths.join("c10", filename)) | ||
|
||
# return the src and output_gen files | ||
return gpu_files, real_hip_files | ||
|
||
def get_c10_hip_test_files(): | ||
gpu_file_pattern = [ | ||
base + suffix | ||
for base in c10_includes | ||
for suffix in gpu_file_extensions | ||
] | ||
native_gpu_files = native.glob(gpu_file_pattern) | ||
|
||
# store the original | ||
gpu_files = [] | ||
hip_files = [] | ||
for name in native_gpu_files: | ||
if not is_test_files(name): | ||
continue | ||
|
||
gpu_files.append(name) | ||
hip_file_name = get_hip_file_path(paths.join("cuda/", name)) | ||
hip_files.append(hip_file_name) | ||
|
||
# there will be some native hip files that needs suffix changed | ||
native_hip_pattern = [ | ||
"hip/test/**/*" + suffix | ||
for suffix in gpu_header_extensions | ||
] | ||
native_hip_files = native.glob(native_hip_pattern) | ||
|
||
gpu_files += native_hip_files | ||
hip_files += native_hip_files | ||
|
||
# we run hipify script under the caffe2 folder; therefore we need to | ||
# prepend c10 to the path so that buck can find the hipified file | ||
real_hip_files = [] | ||
for filename in hip_files: | ||
real_hip_files.append(paths.join("c10", filename)) | ||
|
||
# return the src and output_gen files | ||
return gpu_files, real_hip_files | ||
|
||
c10_includes = ["**/*"] |
Oops, something went wrong.