Skip to content

Change the dependency of absl #72546

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

Merged
merged 1 commit into from
May 6, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
29 changes: 3 additions & 26 deletions cmake/cinn/external/absl.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -38,37 +38,14 @@ ExternalProject_Add(
-DCMAKE_INSTALL_PREFIX:PATH=${ABSL_INSTALL_DIR}
-DCMAKE_INSTALL_LIBDIR:PATH=${ABSL_INSTALL_DIR}/lib
-DCMAKE_POSITION_INDEPENDENT_CODE:BOOL=ON
-DCMAKE_BUILD_TYPE:STRING=${THIRD_PARTY_BUILD_TYPE}
BUILD_BYPRODUCTS ${ABSL_INSTALL_DIR}/lib/libabsl_base.a
BUILD_BYPRODUCTS ${ABSL_INSTALL_DIR}/lib/libabsl_hash.a
BUILD_BYPRODUCTS ${ABSL_INSTALL_DIR}/lib/libabsl_string_view.a
BUILD_BYPRODUCTS ${ABSL_INSTALL_DIR}/lib/libabsl_low_level_hash.a
BUILD_BYPRODUCTS ${ABSL_INSTALL_DIR}/lib/libabsl_demangle_internal.a
BUILD_BYPRODUCTS ${ABSL_INSTALL_DIR}/lib/libabsl_raw_logging_internal.a
BUILD_BYPRODUCTS ${ABSL_INSTALL_DIR}/lib/libabsl_city.a
BUILD_BYPRODUCTS ${ABSL_INSTALL_DIR}/lib/libabsl_strings.a
BUILD_BYPRODUCTS ${ABSL_INSTALL_DIR}/lib/libabsl_throw_delegate.a
BUILD_BYPRODUCTS ${ABSL_INSTALL_DIR}/lib/libabsl_bad_any_cast_impl.a
BUILD_BYPRODUCTS ${ABSL_INSTALL_DIR}/lib/libabsl_bad_optional_access.a
BUILD_BYPRODUCTS ${ABSL_INSTALL_DIR}/lib/libabsl_bad_variant_access.a)
-DCMAKE_BUILD_TYPE:STRING=${THIRD_PARTY_BUILD_TYPE})

# It may be more convenient if we just include all absl libs
set(ABSL_LIB_NAMES
hash
string_view
low_level_hash
demangle_internal
raw_logging_internal
city
strings
throw_delegate
bad_any_cast_impl
bad_optional_access
bad_variant_access)
set(ABSL_LIB_NAMES "")
set(ABSL_LIBS "")

if(WITH_ROCM)
list(APPEND ABSL_LIB_NAMES strings_internal raw_logging_internal)
list(APPEND ABSL_LIB_NAMES strings_internal)
endif()

add_library(absl STATIC IMPORTED GLOBAL)
Expand Down
2 changes: 1 addition & 1 deletion paddle/cinn/adt/op_equation_context.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ class OpEquationContext {

template <typename T>
const T& Attr(const std::string& name) const {
return absl::get<T>(GetAttribute(name));
return std::get<T>(GetAttribute(name));
}

protected:
Expand Down
2 changes: 1 addition & 1 deletion paddle/cinn/backends/compiler.cc
Original file line number Diff line number Diff line change
Expand Up @@ -564,7 +564,7 @@ void Compiler::ExportObject(const std::string& path) {
engine_->ExportObject(path);
}

void* Compiler::Lookup(absl::string_view fn_name) {
void* Compiler::Lookup(std::string_view fn_name) {
PADDLE_ENFORCE_NOT_NULL(
engine_, ::common::errors::InvalidArgument("Sorry, engine_ is nullptr"));
if (engine_->Lookup(fn_name) != nullptr) {
Expand Down
4 changes: 2 additions & 2 deletions paddle/cinn/backends/compiler.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

#pragma once

#include <absl/strings/string_view.h>
#include <string_view>

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

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

Expand Down
6 changes: 2 additions & 4 deletions paddle/cinn/backends/extern_func_emitter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,7 @@

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

#include <absl/hash/hash.h>
#include <glog/raw_logging.h>

#include <functional>
#include <iostream>
#include <string>
Expand Down Expand Up @@ -85,8 +83,8 @@ namespace std {

size_t hash<cinn::backends::ExternFuncID>::operator()(
const cinn::backends::ExternFuncID& x) const {
return absl::Hash<absl::string_view>{}(x.name) ^
absl::Hash<absl::string_view>{}(x.backend_id);
return std::hash<std::string_view>{}(x.name) ^
std::hash<std::string_view>{}(x.backend_id);
}

} // namespace std
2 changes: 1 addition & 1 deletion paddle/cinn/backends/function_prototype.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

#pragma once

#include <absl/strings/string_view.h>
#include <string_view>

#include <memory>
#include <string>
Expand Down
2 changes: 1 addition & 1 deletion paddle/cinn/backends/llvm/codegen_llvm.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1511,7 +1511,7 @@ void CodeGenLLVM::InitTarget(const Target &target) {
}

void CodeGenLLVM::AddTbaaMetadata(llvm::Instruction *inst,
absl::string_view buffer,
std::string_view buffer,
Expr index) {
// If the index is constant, generate some TBAA info that helps LLVM
// understand our loads/stores aren't aliased.
Expand Down
4 changes: 2 additions & 2 deletions paddle/cinn/backends/llvm/codegen_llvm.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@

#pragma once

#include <absl/strings/string_view.h>
#include <llvm/IR/Constants.h>
#include <llvm/IR/Function.h>
#include <llvm/IR/IRBuilder.h>
Expand All @@ -24,6 +23,7 @@
#include <memory>
#include <stdexcept>
#include <string>
#include <string_view>
#include <unordered_set>
#include <utility>
#include <vector>
Expand Down Expand Up @@ -254,7 +254,7 @@ class CodeGenLLVM : public LLVMIRVisitor, public IrBuilderMixin<CodeGenLLVM> {
* can optimize by reordering loads and stores across different buffers.
*/
void AddTbaaMetadata(llvm::Instruction *inst,
absl::string_view buffer,
std::string_view buffer,
Expr index);

void InitTarget(const Target &target);
Expand Down
4 changes: 2 additions & 2 deletions paddle/cinn/backends/llvm/execution_engine.cc
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@

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

#include <absl/strings/string_view.h>
#include <llvm/ADT/Triple.h>
#include <llvm/AsmParser/Parser.h>
#include <llvm/Config/llvm-config.h>
Expand Down Expand Up @@ -52,6 +51,7 @@
#include <memory>
#include <mutex> // NOLINT
#include <string>
#include <string_view>
#include <utility>

#include "paddle/cinn/backends/codegen_cuda_host.h"
Expand Down Expand Up @@ -265,7 +265,7 @@ void ExecutionEngine::ExportObject(const std::string &path) {
fclose(of);
}

void *ExecutionEngine::Lookup(absl::string_view name) {
void *ExecutionEngine::Lookup(std::string_view name) {
utils::RecordEvent("ExecutionEngine Lookup", utils::EventType::kOrdinary);
std::lock_guard<std::mutex> lock(mu_);
if (auto symbol = jit_->lookup(AsStringRef(name))) {
Expand Down
2 changes: 1 addition & 1 deletion paddle/cinn/backends/llvm/execution_engine.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ class ExecutionEngine {
static std::unique_ptr<ExecutionEngine> Create(
const ExecutionOptions &config);

void *Lookup(absl::string_view name);
void *Lookup(std::string_view name);

template <typename CodeGenT = CodeGenLLVM>
void Link(const ir::Module &module);
Expand Down
4 changes: 2 additions & 2 deletions paddle/cinn/backends/llvm/generate_runtime_llvm_ir.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@ def main():
llvm_config = sys.argv[3]

srcs = []
srcs.append('#include <absl/strings/string_view.h>')
srcs.append('#include <string_view>')
# srcs.append('#include "paddle/cinn/backends/llvm/cinn_runtime_llvm_ir.h"\n')
srcs.append('namespace cinn::backends {')
srcs.append("static const absl::string_view kRuntimeLlvmIr(")
srcs.append("static const std::string_view kRuntimeLlvmIr(")
srcs.append('R"ROC(')
with open(path, 'r') as fr:
srcs.append(fr.read())
Expand Down
4 changes: 2 additions & 2 deletions paddle/cinn/backends/llvm/llvm_util.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@

#pragma once

#include <absl/strings/string_view.h>
#include <llvm/ADT/StringRef.h>
#include <llvm/ExecutionEngine/MCJIT.h>
#include <llvm/IR/Argument.h>
Expand All @@ -26,6 +25,7 @@
#include <llvm/IR/Value.h>

#include <string>
#include <string_view>
#include <type_traits>
#include <utility>

Expand All @@ -45,7 +45,7 @@ std::string DumpToString(const T &entity) {
// return "\033[33m" + buffer + "\033[0m"; // Green
}

inline llvm::StringRef AsStringRef(absl::string_view str) {
inline llvm::StringRef AsStringRef(std::string_view str) {
return llvm::StringRef(str.data(), str.size());
}

Expand Down
4 changes: 2 additions & 2 deletions paddle/cinn/backends/llvm/runtime_symbol_registry.cc
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@

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

#include <absl/strings/string_view.h>
#include <glog/raw_logging.h>

#include <iostream>
#include <string_view>

#include "paddle/cinn/runtime/flags.h"
#include "paddle/common/enforce.h"
Expand All @@ -32,7 +32,7 @@ RuntimeSymbols &GlobalSymbolRegistry::Global() {
return symbols;
}

void *RuntimeSymbols::Lookup(absl::string_view name) const {
void *RuntimeSymbols::Lookup(std::string_view name) const {
std::lock_guard<std::mutex> lock(mu_);
auto it = symbols_.find(std::string(name));
if (it != symbols_.end()) {
Expand Down
8 changes: 4 additions & 4 deletions paddle/cinn/backends/llvm/runtime_symbol_registry.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@

#pragma once

#include <absl/strings/string_view.h>
#include <absl/types/any.h>
#include <absl/types/variant.h>
#include <glog/logging.h>
#include <any>
#include <string_view>

#include <map>
#include <mutex> // NOLINT
#include <string>
#include <variant>
#include <vector>

#include "paddle/cinn/common/macros.h"
Expand Down Expand Up @@ -81,7 +81,7 @@ class RuntimeSymbols {
* @param name Name of the symbol.
* @return The address if exists, or nullptr will return.
*/
void *Lookup(absl::string_view name) const;
void *Lookup(std::string_view name) const;

/**
* Get all the symbols.
Expand Down
4 changes: 2 additions & 2 deletions paddle/cinn/backends/llvm/simple_jit.h
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@

#pragma once

#include <absl/strings/string_view.h>
#include <llvm/AsmParser/Parser.h>
#include <llvm/ExecutionEngine/ExecutionEngine.h>
#include <llvm/ExecutionEngine/JITSymbol.h>
Expand All @@ -36,6 +35,7 @@

#include <functional>
#include <memory>
#include <string_view>
#include <utility>
#include <vector>

Expand Down Expand Up @@ -67,7 +67,7 @@ class SimpleJIT {
llvm::cantFail(jit_->addIRModule(std::move(m)));
}

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

Expand Down
12 changes: 6 additions & 6 deletions paddle/cinn/common/cinn_value.cc
Original file line number Diff line number Diff line change
Expand Up @@ -116,41 +116,41 @@ bool CINNValue::is_var() const { return type_code_ == TypeCode<ir::Var>(); }

bool CINNValue::is_expr() const {
return type_code_ == TypeCode<ir::Expr>() &&
!absl::any_cast<Expr>(shared_).as_tensor();
!std::any_cast<Expr>(shared_).as_tensor();
}

bool CINNValue::is_tensor() const {
return type_code_ == TypeCode<ir::Expr>() &&
absl::any_cast<Expr>(shared_).as_tensor();
std::any_cast<Expr>(shared_).as_tensor();
}

CINNValue::operator std::string() const {
PADDLE_ENFORCE_EQ(
type_code_,
TypeCode<std::string>(),
::common::errors::InvalidArgument("The type_code is not std::string."));
return absl::any_cast<std::string>(shared_);
return std::any_cast<std::string>(shared_);
}
CINNValue::operator ir::Var() const {
PADDLE_ENFORCE_EQ(
type_code_,
TypeCode<ir::Var>(),
::common::errors::InvalidArgument("The type_code is not ir::Var."));
return absl::any_cast<ir::Var>(shared_);
return std::any_cast<ir::Var>(shared_);
}
CINNValue::operator ir::Expr() const {
PADDLE_ENFORCE_EQ(
type_code_,
TypeCode<ir::Expr>(),
::common::errors::InvalidArgument("The type_code is not ir::Expr."));
return absl::any_cast<Expr>(shared_);
return std::any_cast<Expr>(shared_);
}
CINNValue::operator CINNValuePack() const {
PADDLE_ENFORCE_EQ(
type_code_,
TypeCode<CINNValuePack>(),
::common::errors::InvalidArgument("The type_code is not CINNValuePack."));
return absl::any_cast<CINNValuePack>(shared_);
return std::any_cast<CINNValuePack>(shared_);
}

CINNValue::CINNValue(char *value)
Expand Down
6 changes: 3 additions & 3 deletions paddle/cinn/common/cinn_value.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@
// limitations under the License.

#pragma once
#include <absl/types/any.h>
#include <glog/logging.h>

#include <glog/logging.h>
#include <any>
#include <vector>

#include "paddle/cinn/common/common.h"
Expand Down Expand Up @@ -234,7 +234,7 @@ class CINNValue : public cinn_pod_value_t {
static int TypeCode();

protected:
absl::any shared_;
std::any shared_;
};

} // namespace common
Expand Down
4 changes: 2 additions & 2 deletions paddle/cinn/common/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

#pragma once

#include <absl/strings/string_view.h>
#include <string_view>

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

static void CheckVarNameValid(const absl::string_view name) {
static void CheckVarNameValid(const std::string_view name) {
PADDLE_ENFORCE_EQ(name.empty(),
false,
::common::errors::InvalidArgument(
Expand Down
4 changes: 2 additions & 2 deletions paddle/cinn/common/context.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@
// limitations under the License.

#pragma once
#include <absl/types/any.h>
#include <isl/cpp.h>

#include <isl/cpp.h>
#include <any>
#include <mutex>
#include <set>
#include <string>
Expand Down
Loading
Loading