diff --git a/paddle/fluid/operators/jit/gen/act.h b/paddle/fluid/operators/jit/gen/act.h index 68e66f9298c4eafabb55c20195d46fed800f4ec4..13d98577e21db9041686822f57cb4992e5ad71ec 100644 --- a/paddle/fluid/operators/jit/gen/act.h +++ b/paddle/fluid/operators/jit/gen/act.h @@ -63,7 +63,6 @@ class VActFunc : public JitCode { public: explicit VActFunc(size_t code_size, void* code_ptr) : JitCode(code_size, code_ptr) {} - virtual const char* name() const = 0; virtual void genCode() = 0; protected: @@ -269,7 +268,7 @@ class VActJitCode : public VActFunc { this->genCode(); } - const char* name() const override { + std::string name() const override { std::string base = "VActJitCode"; switch (type_) { case operand_type::RELU: @@ -293,7 +292,7 @@ class VActJitCode : public VActFunc { default: break; } - return base.c_str(); + return base; } void genCode() override; diff --git a/paddle/fluid/operators/jit/gen/blas.h b/paddle/fluid/operators/jit/gen/blas.h index 66a97c1be503b0fa983f9a7ec3b61c986774f16b..70312bbe5e97fcf465ce13ef71e5acc9bab4874e 100644 --- a/paddle/fluid/operators/jit/gen/blas.h +++ b/paddle/fluid/operators/jit/gen/blas.h @@ -41,7 +41,7 @@ class VXXJitCode : public JitCode { this->genCode(); } - virtual const char* name() const { + std::string name() const override { std::string base = "VXXJitCode"; if (scalar_index_ == 1) { base += "_Scalar"; @@ -62,7 +62,7 @@ class VXXJitCode : public JitCode { } base += (with_relu_ ? "_Relu" : ""); base += "_D" + std::to_string(num_); - return base.c_str(); + return base; } void genCode() override; diff --git a/paddle/fluid/operators/jit/gen/gru.h b/paddle/fluid/operators/jit/gen/gru.h index a4d7222a3459d175fc5eaf5cdf0e7a1a610f8b0c..d91f828e6aa7673265a460524dfcad119758aa77 100644 --- a/paddle/fluid/operators/jit/gen/gru.h +++ b/paddle/fluid/operators/jit/gen/gru.h @@ -49,7 +49,7 @@ class GRUJitCode : public VActFunc { this->genCode(); } - const char* name() const override { + std::string name() const override { std::string base = "GRUJitCode"; if (id_ == 0) { base += "_H1"; @@ -81,7 +81,7 @@ class GRUJitCode : public VActFunc { }; AddTypeStr(act_gate_); AddTypeStr(act_cand_); - return base.c_str(); + return base; } void genCode() override; diff --git a/paddle/fluid/operators/jit/gen/hopv.h b/paddle/fluid/operators/jit/gen/hopv.h index d3bc94b63d3f962cd655367a2afe1a08582b06fa..28d213e5e48749f84405454a2708d9289b9d290c 100644 --- a/paddle/fluid/operators/jit/gen/hopv.h +++ b/paddle/fluid/operators/jit/gen/hopv.h @@ -35,14 +35,14 @@ class HOPVJitCode : public JitCode { this->genCode(); } - virtual const char* name() const { + std::string name() const override { std::string base = "VXXJitCode"; if (type_ == operand_type::MAX) { base += "_MAX"; } else { base += "_SUM"; } - return base.c_str(); + return base; } void genCode() override; diff --git a/paddle/fluid/operators/jit/gen/jitcode.h b/paddle/fluid/operators/jit/gen/jitcode.h index c388109604bc57e8475e79a6c57eecb5bfebfb52..689df8b1cbb7a928c9f9175d28a8231b56e2e82e 100644 --- a/paddle/fluid/operators/jit/gen/jitcode.h +++ b/paddle/fluid/operators/jit/gen/jitcode.h @@ -14,6 +14,7 @@ #pragma once +#include #include #include "paddle/fluid/operators/jit/gen_base.h" #include "paddle/fluid/platform/cpu_info.h" @@ -59,7 +60,7 @@ typedef enum { } operand_type; #define DECLARE_JIT_CODE(codename) \ - const char* name() const override { return #codename; } + std::string name() const override { return #codename; } class JitCode : public GenBase, public Xbyak::CodeGenerator { public: @@ -68,7 +69,6 @@ class JitCode : public GenBase, public Xbyak::CodeGenerator { (code_size % 4096 != 0 ? (code_size / 4096 + 1) * 4096 : code_size), code_ptr) {} - virtual const char* name() const = 0; virtual void genCode() = 0; size_t getSize() const override { return CodeGenerator::getSize(); } diff --git a/paddle/fluid/operators/jit/gen/lstm.h b/paddle/fluid/operators/jit/gen/lstm.h index d4753bca23de91c74415d41c372cde1610712ef7..fa560b6230d7164be907f0172fb1d91860c05db2 100644 --- a/paddle/fluid/operators/jit/gen/lstm.h +++ b/paddle/fluid/operators/jit/gen/lstm.h @@ -53,7 +53,7 @@ class LSTMJitCode : public VActFunc { this->genCode(); } - const char* name() const override { + std::string name() const override { std::string base = "LSTMJitCode"; if (use_peephole_) { base += "_Peephole"; @@ -85,7 +85,7 @@ class LSTMJitCode : public VActFunc { AddTypeStr(act_gate_); AddTypeStr(act_cand_); AddTypeStr(act_cell_); - return base.c_str(); + return base; } void genCode() override; diff --git a/paddle/fluid/operators/jit/gen/matmul.h b/paddle/fluid/operators/jit/gen/matmul.h index 626baa8f738bf0395f3c7f1700610d0a9075879b..881cea581acc27a7aa7d395c041d40a4d3281947 100644 --- a/paddle/fluid/operators/jit/gen/matmul.h +++ b/paddle/fluid/operators/jit/gen/matmul.h @@ -36,11 +36,11 @@ class MatMulJitCode : public JitCode { this->genCode(); } - virtual const char* name() const { + std::string name() const override { std::string base = "MatMulJitCode"; base = base + "_M" + std::to_string(m_) + "_N" + std::to_string(n_) + "_K" + std::to_string(k_); - return base.c_str(); + return base; } void genCode() override; diff --git a/paddle/fluid/operators/jit/gen/seqpool.h b/paddle/fluid/operators/jit/gen/seqpool.h index fcbbb3c84c562e2ba57110134bf07bb218b41edb..4108ee2f46433f6dc846cbdd3a8f8f9b15cc0c67 100644 --- a/paddle/fluid/operators/jit/gen/seqpool.h +++ b/paddle/fluid/operators/jit/gen/seqpool.h @@ -38,7 +38,7 @@ class SeqPoolJitCode : public JitCode { this->genCode(); } - virtual const char* name() const { + std::string name() const override { std::string base = "SeqPoolJitCode"; if (type_ == SeqPoolType::kSum) { base += "_Sum"; @@ -48,7 +48,7 @@ class SeqPoolJitCode : public JitCode { base += "_Sqrt"; } base += ("_W" + std::to_string(w_)); - return base.c_str(); + return base; } void genCode() override; diff --git a/paddle/fluid/operators/jit/gen_base.h b/paddle/fluid/operators/jit/gen_base.h index d808a332472ae86240cb63356cb417123523366a..32a861b209c58649da8299a2718dba9c97e18903 100644 --- a/paddle/fluid/operators/jit/gen_base.h +++ b/paddle/fluid/operators/jit/gen_base.h @@ -16,6 +16,7 @@ #include #include // for unique_ptr +#include #include #include "paddle/fluid/operators/jit/kernel_base.h" @@ -28,7 +29,7 @@ namespace jit { class GenBase : public Kernel { public: virtual ~GenBase() = default; - virtual const char* name() const = 0; + virtual std::string name() const = 0; virtual size_t getSize() const = 0; virtual const unsigned char* getCodeInternal() = 0; template