diff --git a/include/tvm/runtime/container/string.h b/include/tvm/runtime/container/string.h index 28b0358014e4..5ecd89e9f56d 100644 --- a/include/tvm/runtime/container/string.h +++ b/include/tvm/runtime/container/string.h @@ -36,36 +36,9 @@ #include #include #include -#include -#include -// We use c++14 std::experimental::string_view for optimizing hash computation -// only right now, its usage is limited in this file. Any broader usage of -// std::experiment in our core codebase is discouraged and needs community -// discussion for each use case. Reference for feature test macros of -// string_view: -// https://isocpp.org/std/standing-documents/sd-6-sg10-feature-test-recommendations -// https://en.cppreference.com/w/User:D41D8CD98F/feature_testing_macros -#if defined(__cpp_lib_experimental_string_view) && __cpp_lib_experimental_string_view >= 201411 -#define TVM_USE_CXX14_STRING_VIEW_HASH 1 -#else -#define TVM_USE_CXX14_STRING_VIEW_HASH 0 -#endif - -// Tested with clang version 9.0.1 and c++17. It will detect string_view support -// correctly. -#if defined(__cpp_lib_string_view) && __cpp_lib_string_view >= 201606 -#define TVM_USE_CXX17_STRING_VIEW_HASH 1 -#else -#define TVM_USE_CXX17_STRING_VIEW_HASH 0 -#endif - -#if TVM_USE_CXX17_STRING_VIEW_HASH #include -#elif TVM_USE_CXX14_STRING_VIEW_HASH -#include -#endif - #include +#include #include #include @@ -277,13 +250,7 @@ class String : public ObjectRef { static size_t HashBytes(const char* data, size_t size) { // This function falls back to string copy with c++11 compiler and is // recommended to be compiled with c++14 -#if TVM_USE_CXX17_STRING_VIEW_HASH return std::hash()(std::string_view(data, size)); -#elif TVM_USE_CXX14_STRING_VIEW_HASH - return std::hash()(std::experimental::string_view(data, size)); -#else - return std::hash()(std::string(data, size)); -#endif } TVM_DEFINE_NOTNULLABLE_OBJECT_REF_METHODS(String, ObjectRef, StringObj); diff --git a/python/setup.py b/python/setup.py index a75888c83614..f63d52bd3806 100644 --- a/python/setup.py +++ b/python/setup.py @@ -122,7 +122,10 @@ def config_cython(): if os.name == "nt": library_dirs = ["tvm", "../build/Release", "../build"] libraries = ["tvm"] - extra_compile_args = None + extra_compile_args = [ + "/std:c++17", + "/D DMLC_USE_LOGGING_LIBRARY=", + ] # library is available via conda env. if CONDA_BUILD: library_dirs = [os.environ["LIBRARY_LIB"]] diff --git a/python/tvm/contrib/cutlass/build.py b/python/tvm/contrib/cutlass/build.py index 0c8c2ad0b2b9..838c0bde4e5e 100644 --- a/python/tvm/contrib/cutlass/build.py +++ b/python/tvm/contrib/cutlass/build.py @@ -62,7 +62,7 @@ def _get_cutlass_compile_options(sm, threads, use_fast_math=False): "-Xcompiler=-Wconversion", "-Xcompiler=-fno-strict-aliasing", "-O3", - "-std=c++14", + "-std=c++17", "-I" + cutlass_include, "-I" + cutlass_util_include, ] diff --git a/python/tvm/contrib/emcc.py b/python/tvm/contrib/emcc.py index 89431dc2a4f6..671e573b1c39 100644 --- a/python/tvm/contrib/emcc.py +++ b/python/tvm/contrib/emcc.py @@ -41,7 +41,7 @@ def create_tvmjs_wasm(output, objects, options=None, cc="emcc"): cmd = [cc] cmd += ["-O3"] - cmd += ["-std=c++14"] + cmd += ["-std=c++17"] cmd += ["--no-entry"] cmd += ["-s", "ERROR_ON_UNDEFINED_SYMBOLS=0"] cmd += ["-s", "STANDALONE_WASM=1"] diff --git a/python/tvm/rpc/minrpc.py b/python/tvm/rpc/minrpc.py index eb4561f39525..c86e77b4012e 100644 --- a/python/tvm/rpc/minrpc.py +++ b/python/tvm/rpc/minrpc.py @@ -67,7 +67,7 @@ def with_minrpc(compile_func, server="posix_popen_server", runtime="libtvm"): runtime_path = libinfo.find_lib_path([runtime, runtime + ".so", runtime + ".dylib"])[0] runtime_dir = os.path.abspath(os.path.dirname(runtime_path)) - options = ["-std=c++14"] + options = ["-std=c++17"] # Make sure the rpath to the libtvm is set so we can do local tests. # Note that however, this approach won't work on remote. # Always recommend to to link statically. diff --git a/tests/python/relay/test_pass_annotate_target.py b/tests/python/relay/test_pass_annotate_target.py index 23ef9d11eb77..908a06ffc8b2 100644 --- a/tests/python/relay/test_pass_annotate_target.py +++ b/tests/python/relay/test_pass_annotate_target.py @@ -41,7 +41,7 @@ def update_lib(lib): contrib_path = os.path.join(source_dir, "src", "runtime", "contrib") kwargs = {} - kwargs["options"] = ["-O2", "-std=c++14", "-I" + contrib_path] + kwargs["options"] = ["-O2", "-std=c++17", "-I" + contrib_path] tmp_path = utils.tempdir() lib_name = "lib.so" lib_path = tmp_path.relpath(lib_name) diff --git a/tests/python/relay/test_pass_partition_graph.py b/tests/python/relay/test_pass_partition_graph.py index f073a00c1910..ce09a939cefc 100644 --- a/tests/python/relay/test_pass_partition_graph.py +++ b/tests/python/relay/test_pass_partition_graph.py @@ -142,7 +142,7 @@ def update_lib(lib): contrib_path = os.path.join(source_dir, "src", "runtime", "contrib") kwargs = {} - kwargs["options"] = ["-O2", "-std=c++14", "-I" + contrib_path] + kwargs["options"] = ["-O2", "-std=c++17", "-I" + contrib_path] tmp_path = utils.tempdir() lib_name = "lib.so" lib_path = tmp_path.relpath(lib_name) diff --git a/tests/python/relay/utils/external_codegen.py b/tests/python/relay/utils/external_codegen.py index 8e5ab803de7a..bb06d3bb86aa 100644 --- a/tests/python/relay/utils/external_codegen.py +++ b/tests/python/relay/utils/external_codegen.py @@ -62,7 +62,7 @@ def update_lib(lib): contrib_path = os.path.join(source_dir, "src", "runtime", "contrib") kwargs = {} - kwargs["options"] = ["-O2", "-std=c++14", "-I" + contrib_path] + kwargs["options"] = ["-O2", "-std=c++17", "-I" + contrib_path] tmp_path = utils.tempdir() lib_name = "lib.so" lib_path = tmp_path.relpath(lib_name) diff --git a/tests/python/unittest/test_runtime_module_export.py b/tests/python/unittest/test_runtime_module_export.py index 57fcaea03d80..72608fe36fb9 100644 --- a/tests/python/unittest/test_runtime_module_export.py +++ b/tests/python/unittest/test_runtime_module_export.py @@ -202,7 +202,7 @@ def verify_multi_c_mod_export(): path_lib = temp.relpath(file_name) synthetic_cpu_lib.import_module(f) synthetic_cpu_lib.import_module(engine_module) - kwargs = {"options": ["-O2", "-std=c++14", "-I" + header_file_dir_path.relpath("")]} + kwargs = {"options": ["-O2", "-std=c++17", "-I" + header_file_dir_path.relpath("")]} synthetic_cpu_lib.export_library(path_lib, fcompile=False, **kwargs) loaded_lib = tvm.runtime.load_module(path_lib) assert loaded_lib.type_key == "library"