Skip to content

Commit c55587c

Browse files
SigureMoxkkkkkk23
authored andcommitted
[CINN]Change the dependency of absl
1 parent 9ab94fa commit c55587c

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

70 files changed

+715
-476
lines changed

cmake/cinn/external/absl.cmake

+3-26
Original file line numberDiff line numberDiff line change
@@ -38,37 +38,14 @@ ExternalProject_Add(
3838
-DCMAKE_INSTALL_PREFIX:PATH=${ABSL_INSTALL_DIR}
3939
-DCMAKE_INSTALL_LIBDIR:PATH=${ABSL_INSTALL_DIR}/lib
4040
-DCMAKE_POSITION_INDEPENDENT_CODE:BOOL=ON
41-
-DCMAKE_BUILD_TYPE:STRING=${THIRD_PARTY_BUILD_TYPE}
42-
BUILD_BYPRODUCTS ${ABSL_INSTALL_DIR}/lib/libabsl_base.a
43-
BUILD_BYPRODUCTS ${ABSL_INSTALL_DIR}/lib/libabsl_hash.a
44-
BUILD_BYPRODUCTS ${ABSL_INSTALL_DIR}/lib/libabsl_string_view.a
45-
BUILD_BYPRODUCTS ${ABSL_INSTALL_DIR}/lib/libabsl_low_level_hash.a
46-
BUILD_BYPRODUCTS ${ABSL_INSTALL_DIR}/lib/libabsl_demangle_internal.a
47-
BUILD_BYPRODUCTS ${ABSL_INSTALL_DIR}/lib/libabsl_raw_logging_internal.a
48-
BUILD_BYPRODUCTS ${ABSL_INSTALL_DIR}/lib/libabsl_city.a
49-
BUILD_BYPRODUCTS ${ABSL_INSTALL_DIR}/lib/libabsl_strings.a
50-
BUILD_BYPRODUCTS ${ABSL_INSTALL_DIR}/lib/libabsl_throw_delegate.a
51-
BUILD_BYPRODUCTS ${ABSL_INSTALL_DIR}/lib/libabsl_bad_any_cast_impl.a
52-
BUILD_BYPRODUCTS ${ABSL_INSTALL_DIR}/lib/libabsl_bad_optional_access.a
53-
BUILD_BYPRODUCTS ${ABSL_INSTALL_DIR}/lib/libabsl_bad_variant_access.a)
41+
-DCMAKE_BUILD_TYPE:STRING=${THIRD_PARTY_BUILD_TYPE})
5442

5543
# It may be more convenient if we just include all absl libs
56-
set(ABSL_LIB_NAMES
57-
hash
58-
string_view
59-
low_level_hash
60-
demangle_internal
61-
raw_logging_internal
62-
city
63-
strings
64-
throw_delegate
65-
bad_any_cast_impl
66-
bad_optional_access
67-
bad_variant_access)
44+
set(ABSL_LIB_NAMES "")
6845
set(ABSL_LIBS "")
6946

7047
if(WITH_ROCM)
71-
list(APPEND ABSL_LIB_NAMES strings_internal raw_logging_internal)
48+
list(APPEND ABSL_LIB_NAMES strings_internal)
7249
endif()
7350

7451
add_library(absl STATIC IMPORTED GLOBAL)

paddle/cinn/adt/op_equation_context.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ class OpEquationContext {
6464

6565
template <typename T>
6666
const T& Attr(const std::string& name) const {
67-
return absl::get<T>(GetAttribute(name));
67+
return std::get<T>(GetAttribute(name));
6868
}
6969

7070
protected:

paddle/cinn/backends/compiler.cc

+1-1
Original file line numberDiff line numberDiff line change
@@ -564,7 +564,7 @@ void Compiler::ExportObject(const std::string& path) {
564564
engine_->ExportObject(path);
565565
}
566566

567-
void* Compiler::Lookup(absl::string_view fn_name) {
567+
void* Compiler::Lookup(std::string_view fn_name) {
568568
PADDLE_ENFORCE_NOT_NULL(
569569
engine_, ::common::errors::InvalidArgument("Sorry, engine_ is nullptr"));
570570
if (engine_->Lookup(fn_name) != nullptr) {

paddle/cinn/backends/compiler.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
#pragma once
1616

17-
#include <absl/strings/string_view.h>
17+
#include <string_view>
1818

1919
#include <fstream>
2020
#include <memory>
@@ -127,7 +127,7 @@ class Compiler final {
127127
* Retrieve a function by \p fn_name.
128128
* @return function address or null if not exists.
129129
*/
130-
void* Lookup(absl::string_view fn_name);
130+
void* Lookup(std::string_view fn_name);
131131

132132
std::vector<void*> GetFnPtr() const { return fn_ptr_; }
133133

paddle/cinn/backends/extern_func_emitter.cc

+3-3
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
#include "paddle/cinn/backends/extern_func_emitter.h"
1616

17-
#include <absl/hash/hash.h>
17+
#include <functional>
1818
#include <glog/raw_logging.h>
1919

2020
#include <functional>
@@ -85,8 +85,8 @@ namespace std {
8585

8686
size_t hash<cinn::backends::ExternFuncID>::operator()(
8787
const cinn::backends::ExternFuncID& x) const {
88-
return absl::Hash<absl::string_view>{}(x.name) ^
89-
absl::Hash<absl::string_view>{}(x.backend_id);
88+
return std::hash<std::string_view>{}(x.name) ^
89+
std::hash<std::string_view>{}(x.backend_id);
9090
}
9191

9292
} // namespace std

paddle/cinn/backends/function_prototype.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
#pragma once
1616

17-
#include <absl/strings/string_view.h>
17+
#include <string_view>
1818

1919
#include <memory>
2020
#include <string>

paddle/cinn/backends/llvm/codegen_llvm.cc

+1-1
Original file line numberDiff line numberDiff line change
@@ -1511,7 +1511,7 @@ void CodeGenLLVM::InitTarget(const Target &target) {
15111511
}
15121512

15131513
void CodeGenLLVM::AddTbaaMetadata(llvm::Instruction *inst,
1514-
absl::string_view buffer,
1514+
std::string_view buffer,
15151515
Expr index) {
15161516
// If the index is constant, generate some TBAA info that helps LLVM
15171517
// understand our loads/stores aren't aliased.

paddle/cinn/backends/llvm/codegen_llvm.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,13 @@
1414

1515
#pragma once
1616

17-
#include <absl/strings/string_view.h>
1817
#include <llvm/IR/Constants.h>
1918
#include <llvm/IR/Function.h>
2019
#include <llvm/IR/IRBuilder.h>
2120
#include <llvm/IR/MDBuilder.h>
2221
#include <llvm/IR/Module.h>
2322

23+
#include <string_view>
2424
#include <memory>
2525
#include <stdexcept>
2626
#include <string>
@@ -254,7 +254,7 @@ class CodeGenLLVM : public LLVMIRVisitor, public IrBuilderMixin<CodeGenLLVM> {
254254
* can optimize by reordering loads and stores across different buffers.
255255
*/
256256
void AddTbaaMetadata(llvm::Instruction *inst,
257-
absl::string_view buffer,
257+
std::string_view buffer,
258258
Expr index);
259259

260260
void InitTarget(const Target &target);

paddle/cinn/backends/llvm/execution_engine.cc

+2-2
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414

1515
#include "paddle/cinn/backends/llvm/execution_engine.h"
1616

17-
#include <absl/strings/string_view.h>
1817
#include <llvm/ADT/Triple.h>
1918
#include <llvm/AsmParser/Parser.h>
2019
#include <llvm/Config/llvm-config.h>
@@ -48,6 +47,7 @@
4847
#include <llvm/Transforms/Scalar/Reassociate.h>
4948
#include <llvm/Transforms/Scalar/SimplifyCFG.h>
5049

50+
#include <string_view>
5151
#include <cmath>
5252
#include <memory>
5353
#include <mutex> // NOLINT
@@ -265,7 +265,7 @@ void ExecutionEngine::ExportObject(const std::string &path) {
265265
fclose(of);
266266
}
267267

268-
void *ExecutionEngine::Lookup(absl::string_view name) {
268+
void *ExecutionEngine::Lookup(std::string_view name) {
269269
utils::RecordEvent("ExecutionEngine Lookup", utils::EventType::kOrdinary);
270270
std::lock_guard<std::mutex> lock(mu_);
271271
if (auto symbol = jit_->lookup(AsStringRef(name))) {

paddle/cinn/backends/llvm/execution_engine.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ class ExecutionEngine {
7373
static std::unique_ptr<ExecutionEngine> Create(
7474
const ExecutionOptions &config);
7575

76-
void *Lookup(absl::string_view name);
76+
void *Lookup(std::string_view name);
7777

7878
template <typename CodeGenT = CodeGenLLVM>
7979
void Link(const ir::Module &module);

paddle/cinn/backends/llvm/generate_runtime_llvm_ir.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,10 @@ def main():
2424
llvm_config = sys.argv[3]
2525

2626
srcs = []
27-
srcs.append('#include <absl/strings/string_view.h>')
27+
srcs.append('#include <string_view>')
2828
# srcs.append('#include "paddle/cinn/backends/llvm/cinn_runtime_llvm_ir.h"\n')
2929
srcs.append('namespace cinn::backends {')
30-
srcs.append("static const absl::string_view kRuntimeLlvmIr(")
30+
srcs.append("static const std::string_view kRuntimeLlvmIr(")
3131
srcs.append('R"ROC(')
3232
with open(path, 'r') as fr:
3333
srcs.append(fr.read())

paddle/cinn/backends/llvm/llvm_util.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414

1515
#pragma once
1616

17-
#include <absl/strings/string_view.h>
1817
#include <llvm/ADT/StringRef.h>
1918
#include <llvm/ExecutionEngine/MCJIT.h>
2019
#include <llvm/IR/Argument.h>
@@ -25,6 +24,7 @@
2524
#include <llvm/IR/Module.h>
2625
#include <llvm/IR/Value.h>
2726

27+
#include <string_view>
2828
#include <string>
2929
#include <type_traits>
3030
#include <utility>
@@ -45,7 +45,7 @@ std::string DumpToString(const T &entity) {
4545
// return "\033[33m" + buffer + "\033[0m"; // Green
4646
}
4747

48-
inline llvm::StringRef AsStringRef(absl::string_view str) {
48+
inline llvm::StringRef AsStringRef(std::string_view str) {
4949
return llvm::StringRef(str.data(), str.size());
5050
}
5151

paddle/cinn/backends/llvm/runtime_symbol_registry.cc

+2-2
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@
1414

1515
#include "paddle/cinn/backends/llvm/runtime_symbol_registry.h"
1616

17-
#include <absl/strings/string_view.h>
1817
#include <glog/raw_logging.h>
1918

19+
#include <string_view>
2020
#include <iostream>
2121

2222
#include "paddle/cinn/runtime/flags.h"
@@ -32,7 +32,7 @@ RuntimeSymbols &GlobalSymbolRegistry::Global() {
3232
return symbols;
3333
}
3434

35-
void *RuntimeSymbols::Lookup(absl::string_view name) const {
35+
void *RuntimeSymbols::Lookup(std::string_view name) const {
3636
std::lock_guard<std::mutex> lock(mu_);
3737
auto it = symbols_.find(std::string(name));
3838
if (it != symbols_.end()) {

paddle/cinn/backends/llvm/runtime_symbol_registry.h

+5-4
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,12 @@
1414

1515
#pragma once
1616

17-
#include <absl/strings/string_view.h>
18-
#include <absl/types/any.h>
19-
#include <absl/types/variant.h>
17+
#include <string_view>
18+
#include <any>
19+
2020
#include <glog/logging.h>
2121

22+
#include <variant>
2223
#include <map>
2324
#include <mutex> // NOLINT
2425
#include <string>
@@ -81,7 +82,7 @@ class RuntimeSymbols {
8182
* @param name Name of the symbol.
8283
* @return The address if exists, or nullptr will return.
8384
*/
84-
void *Lookup(absl::string_view name) const;
85+
void *Lookup(std::string_view name) const;
8586

8687
/**
8788
* Get all the symbols.

paddle/cinn/backends/llvm/simple_jit.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414

1515
#pragma once
1616

17-
#include <absl/strings/string_view.h>
1817
#include <llvm/AsmParser/Parser.h>
1918
#include <llvm/ExecutionEngine/ExecutionEngine.h>
2019
#include <llvm/ExecutionEngine/JITSymbol.h>
@@ -34,6 +33,7 @@
3433
#include <llvm/Support/TargetSelect.h>
3534
#include <llvm/Support/raw_ostream.h>
3635

36+
#include <string_view>
3737
#include <functional>
3838
#include <memory>
3939
#include <utility>
@@ -67,7 +67,7 @@ class SimpleJIT {
6767
llvm::cantFail(jit_->addIRModule(std::move(m)));
6868
}
6969

70-
llvm::JITTargetAddress Lookup(absl::string_view name) {
70+
llvm::JITTargetAddress Lookup(std::string_view name) {
7171
return llvm::cantFail(jit_->lookup(AsStringRef(name))).getAddress();
7272
}
7373

paddle/cinn/common/cinn_value.cc

+6-6
Original file line numberDiff line numberDiff line change
@@ -116,41 +116,41 @@ bool CINNValue::is_var() const { return type_code_ == TypeCode<ir::Var>(); }
116116

117117
bool CINNValue::is_expr() const {
118118
return type_code_ == TypeCode<ir::Expr>() &&
119-
!absl::any_cast<Expr>(shared_).as_tensor();
119+
!std::any_cast<Expr>(shared_).as_tensor();
120120
}
121121

122122
bool CINNValue::is_tensor() const {
123123
return type_code_ == TypeCode<ir::Expr>() &&
124-
absl::any_cast<Expr>(shared_).as_tensor();
124+
std::any_cast<Expr>(shared_).as_tensor();
125125
}
126126

127127
CINNValue::operator std::string() const {
128128
PADDLE_ENFORCE_EQ(
129129
type_code_,
130130
TypeCode<std::string>(),
131131
::common::errors::InvalidArgument("The type_code is not std::string."));
132-
return absl::any_cast<std::string>(shared_);
132+
return std::any_cast<std::string>(shared_);
133133
}
134134
CINNValue::operator ir::Var() const {
135135
PADDLE_ENFORCE_EQ(
136136
type_code_,
137137
TypeCode<ir::Var>(),
138138
::common::errors::InvalidArgument("The type_code is not ir::Var."));
139-
return absl::any_cast<ir::Var>(shared_);
139+
return std::any_cast<ir::Var>(shared_);
140140
}
141141
CINNValue::operator ir::Expr() const {
142142
PADDLE_ENFORCE_EQ(
143143
type_code_,
144144
TypeCode<ir::Expr>(),
145145
::common::errors::InvalidArgument("The type_code is not ir::Expr."));
146-
return absl::any_cast<Expr>(shared_);
146+
return std::any_cast<Expr>(shared_);
147147
}
148148
CINNValue::operator CINNValuePack() const {
149149
PADDLE_ENFORCE_EQ(
150150
type_code_,
151151
TypeCode<CINNValuePack>(),
152152
::common::errors::InvalidArgument("The type_code is not CINNValuePack."));
153-
return absl::any_cast<CINNValuePack>(shared_);
153+
return std::any_cast<CINNValuePack>(shared_);
154154
}
155155

156156
CINNValue::CINNValue(char *value)

paddle/cinn/common/cinn_value.h

+3-2
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@
1313
// limitations under the License.
1414

1515
#pragma once
16-
#include <absl/types/any.h>
16+
#include <any>
17+
1718
#include <glog/logging.h>
1819

1920
#include <vector>
@@ -234,7 +235,7 @@ class CINNValue : public cinn_pod_value_t {
234235
static int TypeCode();
235236

236237
protected:
237-
absl::any shared_;
238+
std::any shared_;
238239
};
239240

240241
} // namespace common

paddle/cinn/common/common.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
#pragma once
1616

17-
#include <absl/strings/string_view.h>
17+
#include <string_view>
1818

1919
#include "paddle/cinn/common/axis.h"
2020
#include "paddle/cinn/common/cinn_value.h"
@@ -55,7 +55,7 @@ T& Reference(const T* x) {
5555
return *const_cast<T*>(x);
5656
}
5757

58-
static void CheckVarNameValid(const absl::string_view name) {
58+
static void CheckVarNameValid(const std::string_view name) {
5959
PADDLE_ENFORCE_EQ(name.empty(),
6060
false,
6161
::common::errors::InvalidArgument(

paddle/cinn/common/context.h

+2-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@
1313
// limitations under the License.
1414

1515
#pragma once
16-
#include <absl/types/any.h>
16+
#include <any>
17+
1718
#include <isl/cpp.h>
1819

1920
#include <mutex>

paddle/cinn/common/debug_manager.cc

+4-4
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@
1717
namespace cinn {
1818
namespace common {
1919

20-
inline std::vector<std::pair<std::string, absl::any>> &GetVec(
21-
absl::any &data) { // NOLINT
22-
return absl::any_cast<std::vector<std::pair<std::string, absl::any>> &>(data);
20+
inline std::vector<std::pair<std::string, std::any>> &GetVec(
21+
std::any &data) { // NOLINT
22+
return std::any_cast<std::vector<std::pair<std::string, std::any>> &>(data);
2323
}
2424

2525
//! AppendTypeSuffix for multiple types.
@@ -56,7 +56,7 @@ inline std::string DebugManager::AppendTypeSuffix<std::string>(
5656
}
5757
// @}
5858

59-
void DebugManager::Append(const std::string &key, absl::any value) {
59+
void DebugManager::Append(const std::string &key, std::any value) {
6060
GetVec(data_).push_back(std::make_pair(key, value));
6161
}
6262
void DebugManager::Append(const std::string &key, int32_t value) {

0 commit comments

Comments
 (0)