mirror of
https://github.com/zebrajr/pytorch.git
synced 2025-12-06 12:20:52 +01:00
add fmt, take 7 (#37356)
Summary: fmt is a formatting library for C++. It has several properties that make it nice for inclusion in PyTorch: - Widely used - Basically copies how Python does it - Support for all the compilers and platforms we care about - Standards track (C++20) - Small code size - Header only This PR includes it as a submodule and sets up the build. Pull Request resolved: https://github.com/pytorch/pytorch/pull/37356 Differential Revision: D21262619 Pulled By: suo fbshipit-source-id: 1d9a1a5ed08a634213748e7b02fc718ef8dac4c9
This commit is contained in:
parent
d37a4861b8
commit
68895eda9d
4
.gitmodules
vendored
4
.gitmodules
vendored
|
|
@ -122,3 +122,7 @@
|
|||
ignore = dirty
|
||||
path = third_party/XNNPACK
|
||||
url = https://github.com/google/XNNPACK.git
|
||||
[submodule "third_party/fmt"]
|
||||
ignore = dirty
|
||||
path = third_party/fmt
|
||||
url = https://github.com/fmtlib/fmt.git
|
||||
|
|
|
|||
|
|
@ -1739,6 +1739,7 @@ cc_library(
|
|||
"@foxi",
|
||||
"@gloo",
|
||||
"@onnx",
|
||||
"@fmt",
|
||||
] + if_cuda(
|
||||
[
|
||||
":caffe2_cpp_cuda",
|
||||
|
|
|
|||
|
|
@ -113,6 +113,12 @@ new_local_repository(
|
|||
path = "third_party/sleef",
|
||||
)
|
||||
|
||||
new_local_repository(
|
||||
name = "fmt",
|
||||
build_file = "//third_party:fmt.BUILD",
|
||||
path = "third_party/fmt",
|
||||
)
|
||||
|
||||
new_patched_local_repository(
|
||||
name = "tbb",
|
||||
patches = [
|
||||
|
|
|
|||
|
|
@ -617,7 +617,7 @@ if(USE_FBGEMM)
|
|||
caffe2_update_option(USE_FBGEMM ON)
|
||||
else()
|
||||
caffe2_update_option(USE_FBGEMM OFF)
|
||||
message(WARNING
|
||||
message(WARNING
|
||||
"Turning USE_FAKELOWP off as it depends on USE_FBGEMM.")
|
||||
caffe2_update_option(USE_FAKELOWP OFF)
|
||||
endif()
|
||||
|
|
@ -1590,3 +1590,16 @@ endif()
|
|||
#
|
||||
# End ATen checks
|
||||
#
|
||||
|
||||
add_subdirectory(${CMAKE_SOURCE_DIR}/third_party/fmt)
|
||||
|
||||
# Disable compiler feature checks for `fmt`.
|
||||
#
|
||||
# CMake compiles a little program to check compiler features. Some of our build
|
||||
# configurations (notably the mobile build analyzer) will populate
|
||||
# CMAKE_CXX_FLAGS in ways that break feature checks. Since we already know
|
||||
# `fmt` is compatible with a superset of the compilers that PyTorch is, it
|
||||
# shouldn't be too bad to just disable the checks.
|
||||
set_target_properties(fmt-header-only PROPERTIES INTERFACE_COMPILE_FEATURES "")
|
||||
|
||||
list(APPEND Caffe2_DEPENDENCY_LIBS fmt::fmt-header-only)
|
||||
|
|
|
|||
1
third_party/fmt
vendored
Submodule
1
third_party/fmt
vendored
Submodule
|
|
@ -0,0 +1 @@
|
|||
Subproject commit 9bdd1596cef1b57b9556f8bef32dc4a32322ef3e
|
||||
9
third_party/fmt.BUILD
vendored
Normal file
9
third_party/fmt.BUILD
vendored
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
load("@rules_cc//cc:defs.bzl", "cc_library")
|
||||
|
||||
cc_library(
|
||||
name = "fmt",
|
||||
hdrs = glob(["include/fmt/*.h",]),
|
||||
defines = ["FMT_HEADER_ONLY=1"],
|
||||
includes = ["include"],
|
||||
visibility = ["//visibility:public"],
|
||||
)
|
||||
|
|
@ -17,6 +17,7 @@
|
|||
#include <caffe2/serialize/istream_adapter.h>
|
||||
|
||||
#include <ATen/ATen.h>
|
||||
#include <fmt/format.h>
|
||||
|
||||
#include <fstream>
|
||||
#include <string>
|
||||
|
|
@ -44,12 +45,11 @@ void postSetStateValidate(const IValue& v) {
|
|||
if (attrType->kind() != TypeKind::OptionalType) {
|
||||
TORCH_CHECK(
|
||||
!slot.isNone(),
|
||||
"The field '",
|
||||
attrName,
|
||||
"' was left unitialized after __setstate__, but expected a ",
|
||||
"value of type '",
|
||||
attrType->python_str(),
|
||||
"'");
|
||||
fmt::format(
|
||||
"The field '{}' was left uninitialized after '__setstate__', "
|
||||
"but expected a value of type '{}'",
|
||||
attrName,
|
||||
attrType->python_str()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user