Skip to content

Commit 466ce03

Browse files
authored
Rename tcmpt to pten (#23)
* rename tcmpt to pten * update omitted files for rename to pten * update omitted file for rename to pten
1 parent b77d1ee commit 466ce03

File tree

131 files changed

+820
-813
lines changed

Some content is hidden

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

131 files changed

+820
-813
lines changed

cmake/generic.cmake

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -116,19 +116,19 @@ function(find_fluid_modules TARGET_NAME)
116116
endif()
117117
endfunction(find_fluid_modules)
118118

119-
set_property(GLOBAL PROPERTY TCMPT_MODULES "")
120-
# find all tcmpt modules is used for paddle static library
119+
set_property(GLOBAL PROPERTY PTEN_MODULES "")
120+
# find all pten modules is used for paddle static library
121121
# for building inference libs
122-
function(find_tcmpt_modules TARGET_NAME)
122+
function(find_pten_modules TARGET_NAME)
123123
get_filename_component(__target_path ${TARGET_NAME} ABSOLUTE)
124124
string(REGEX REPLACE "^${PADDLE_SOURCE_DIR}/" "" __target_path ${__target_path})
125-
string(FIND "${__target_path}" "tcmpt" pos)
125+
string(FIND "${__target_path}" "pten" pos)
126126
if(pos GREATER 1)
127-
get_property(tcmpt_modules GLOBAL PROPERTY TCMPT_MODULES)
128-
set(tcmpt_modules ${tcmpt_modules} ${TARGET_NAME})
129-
set_property(GLOBAL PROPERTY TCMPT_MODULES "${tcmpt_modules}")
127+
get_property(pten_modules GLOBAL PROPERTY PTEN_MODULES)
128+
set(pten_modules ${pten_modules} ${TARGET_NAME})
129+
set_property(GLOBAL PROPERTY PTEN_MODULES "${pten_modules}")
130130
endif()
131-
endfunction(find_tcmpt_modules)
131+
endfunction(find_pten_modules)
132132

133133
function(common_link TARGET_NAME)
134134
if (WITH_PROFILER)
@@ -324,7 +324,7 @@ function(cc_library TARGET_NAME)
324324
else()
325325
add_library(${TARGET_NAME} STATIC ${cc_library_SRCS})
326326
find_fluid_modules(${TARGET_NAME})
327-
find_tcmpt_modules(${TARGET_NAME})
327+
find_pten_modules(${TARGET_NAME})
328328
endif()
329329
if(cc_library_DEPS)
330330
# Don't need link libwarpctc.so
@@ -497,7 +497,7 @@ function(nv_library TARGET_NAME)
497497
else()
498498
add_library(${TARGET_NAME} STATIC ${nv_library_SRCS})
499499
find_fluid_modules(${TARGET_NAME})
500-
find_tcmpt_modules(${TARGET_NAME})
500+
find_pten_modules(${TARGET_NAME})
501501
endif()
502502
if (nv_library_DEPS)
503503
add_dependencies(${TARGET_NAME} ${nv_library_DEPS})
@@ -588,7 +588,7 @@ function(hip_library TARGET_NAME)
588588
else()
589589
hip_add_library(${TARGET_NAME} STATIC ${hip_library_SRCS})
590590
find_fluid_modules(${TARGET_NAME})
591-
find_tcmpt_modules(${TARGET_NAME})
591+
find_pten_modules(${TARGET_NAME})
592592
endif()
593593
if (hip_library_DEPS)
594594
add_dependencies(${TARGET_NAME} ${hip_library_DEPS})

cmake/tcmpt.cmake renamed to cmake/pten.cmake

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,13 @@ function(kernel_instantiate TARGET)
2929
string(REGEX MATCH "[A-Z][A-Za-z0-9]+\\(" func_name ${signature})
3030
string(REPLACE "(" "" func_name ${func_name})
3131
# message(STATUS "FUNC NAME: ${func_name}")
32-
string(REGEX REPLACE "${func_name}" "pt::${func_name}<${dtype}>" inst_signature ${signature})
32+
string(REGEX REPLACE "${func_name}" "pten::${func_name}<${dtype}>" inst_signature ${signature})
3333
# append namespace
34-
string(REPLACE "CPUContext" "pt::CPUContext" inst_signature ${inst_signature})
35-
string(REPLACE "CUDAContext" "pt::CUDAContext" inst_signature ${inst_signature})
36-
string(REPLACE "DenseTensor" "pt::DenseTensor" inst_signature ${inst_signature})
34+
string(REPLACE "CPUContext" "pten::CPUContext" inst_signature ${inst_signature})
35+
string(REPLACE "CUDAContext" "pten::CUDAContext" inst_signature ${inst_signature})
36+
string(REPLACE "DenseTensor" "pten::DenseTensor" inst_signature ${inst_signature})
3737
# TODO(chenweihang): adapt SelectedRows after adding it
38-
# string(REPLACE "SelectedRowsTensor" "pt::SelectedRowsTensor" inst_signature ${inst_signature})
38+
# string(REPLACE "SelectedRowsTensor" "pten::SelectedRowsTensor" inst_signature ${inst_signature})
3939
# message(STATUS "INST FUNC: ${inst_signature}")
4040
string(APPEND instantiate_context "template ${inst_signature};\n")
4141
endforeach()

paddle/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
add_subdirectory(scripts)
22
add_subdirectory(testing)
33
set(PYTHON_TESTS_DIR ${PADDLE_BINARY_DIR}/python/paddle/fluid/tests CACHE INTERNAL "python tests directory")
4-
add_subdirectory(tcmpt)
4+
add_subdirectory(pten)
55
add_subdirectory(fluid)

paddle/fluid/framework/CMakeLists.txt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -193,10 +193,10 @@ cc_library(unused_var_check SRCS unused_var_check.cc DEPS glog no_need_buffer_va
193193

194194
IF(WITH_XPU)
195195
cc_library(operator SRCS operator.cc DEPS xpu_op_list op_info device_context tensor scope glog trainer_desc_proto data_feed_proto
196-
shape_inference data_transform lod_tensor profiler transfer_scope_cache op_kernel_type op_call_stack unused_var_check nan_inf_utils tcmpt tcmpt_utils)
196+
shape_inference data_transform lod_tensor profiler transfer_scope_cache op_kernel_type op_call_stack unused_var_check nan_inf_utils pten pten_utils)
197197
ELSE()
198198
cc_library(operator SRCS operator.cc DEPS op_info device_context tensor scope glog trainer_desc_proto data_feed_proto
199-
shape_inference data_transform lod_tensor profiler transfer_scope_cache op_kernel_type op_call_stack unused_var_check nan_inf_utils tcmpt tcmpt_utils)
199+
shape_inference data_transform lod_tensor profiler transfer_scope_cache op_kernel_type op_call_stack unused_var_check nan_inf_utils pten pten_utils)
200200
ENDIF()
201201

202202
cc_test(operator_test SRCS operator_test.cc DEPS operator op_registry device_context)
@@ -390,7 +390,7 @@ cc_library(save_load_util SRCS save_load_util.cc DEPS tensor scope layer)
390390
cc_test(save_load_util_test SRCS save_load_util_test.cc DEPS save_load_util tensor scope layer)
391391
cc_library(generator SRCS generator.cc DEPS enforce place)
392392

393-
cc_library(tcmpt_utils SRCS tcmpt_utils.cc DEPS lod_tensor selected_rows place tcmpt var_type_traits)
393+
cc_library(pten_utils SRCS pten_utils.cc DEPS lod_tensor selected_rows place pten var_type_traits)
394394

395395
# Get the current working branch
396396
execute_process(
@@ -454,4 +454,4 @@ if(WITH_TESTING AND TEST selected_rows_test)
454454
endif()
455455

456456
cc_test(scope_guard_test SRCS scope_guard_test.cc)
457-
cc_test(tcmpt_utils_test SRCS tcmpt_utils_test.cc DEPS tcmpt_utils)
457+
cc_test(pten_utils_test SRCS pten_utils_test.cc DEPS pten_utils)

paddle/fluid/framework/operator.cc

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ limitations under the License. */
2323
#include "paddle/fluid/framework/data_type_transform.h"
2424
#include "paddle/fluid/framework/details/nan_inf_utils.h"
2525
#include "paddle/fluid/framework/op_call_stack.h"
26+
#include "paddle/fluid/framework/pten_utils.h"
2627
#include "paddle/fluid/framework/shape_inference.h"
27-
#include "paddle/fluid/framework/tcmpt_utils.h"
2828
#include "paddle/fluid/framework/transfer_scope_cache.h"
2929
#include "paddle/fluid/framework/unused_var_check.h"
3030
#include "paddle/fluid/framework/var_type.h"
@@ -1140,7 +1140,7 @@ void OperatorWithKernel::RunImpl(const Scope& scope,
11401140
// and RCOM backend, the XPU, NPU and MKLDNN will be supported in the second
11411141
// phase
11421142
if (FLAGS_run_pt_kernel &&
1143-
pt::KernelFactory::Instance().ContainsKernel(type_.c_str())) {
1143+
pten::KernelFactory::Instance().ContainsKernel(type_.c_str())) {
11441144
if (pt_kernel_signature_.get() == nullptr || pt_kernel_.get() == nullptr) {
11451145
ChoosePtKernel(exe_ctx);
11461146
}
@@ -1286,10 +1286,11 @@ void OperatorWithKernel::ChoosePtKernel(const ExecutionContext& ctx) const {
12861286

12871287
kernel_type_.reset(new OpKernelType(InnerGetExpectedKernelType(ctx)));
12881288

1289-
auto pt_kernel_name = pt::KernelName(pt_kernel_signature_->first);
1289+
auto pt_kernel_name = pten::KernelName(pt_kernel_signature_->first);
12901290
auto pt_kernel_key = TransOpKernelTypeToPtKernelKey(*kernel_type_.get());
1291-
pt_kernel_.reset(new pt::Kernel(pt::KernelFactory::Instance().SelectKernel(
1292-
pt_kernel_name, pt_kernel_key)));
1291+
pt_kernel_.reset(
1292+
new pten::Kernel(pten::KernelFactory::Instance().SelectKernel(
1293+
pt_kernel_name, pt_kernel_key)));
12931294

12941295
if (pt_kernel_->IsValid()) {
12951296
VLOG(1) << "Static mode ChoosePtKernel - kernel name: " << pt_kernel_name
@@ -1781,7 +1782,7 @@ KernelSignature OperatorWithKernel::GetExpectedPtKernelArgs(
17811782
}
17821783
}
17831784

1784-
pt::KernelContext OperatorWithKernel::BuildPtKernelContext(
1785+
pten::KernelContext OperatorWithKernel::BuildPtKernelContext(
17851786
const RuntimeContext& ctx, const platform::DeviceContext& dev_ctx) const {
17861787
VLOG(1) << RuntimeContextDebugString(ctx);
17871788

@@ -1792,7 +1793,7 @@ pt::KernelContext OperatorWithKernel::BuildPtKernelContext(
17921793
// 3. needless attributes remove
17931794
// 4. use pt Tensor directly
17941795
// 5. kernel input is not DenseTensor
1795-
pt::KernelContext op_kernel_ctx(dev_ctx);
1796+
pten::KernelContext op_kernel_ctx(dev_ctx);
17961797

17971798
auto& input_names = std::get<0>(pt_kernel_signature_->second);
17981799
auto& attr_names = std::get<1>(pt_kernel_signature_->second);
@@ -1826,7 +1827,7 @@ pt::KernelContext OperatorWithKernel::BuildPtKernelContext(
18261827
<< in_def.layout;
18271828

18281829
auto ins_vector = ctx.inputs.at(input_names[i]);
1829-
std::vector<std::shared_ptr<tcmpt::TensorBase>> tmp_inputs;
1830+
std::vector<std::shared_ptr<pten::TensorBase>> tmp_inputs;
18301831

18311832
for (auto var : ins_vector) {
18321833
auto pt_in = framework::InputVariableToPtTensor(*var, in_def);
@@ -1839,7 +1840,7 @@ pt::KernelContext OperatorWithKernel::BuildPtKernelContext(
18391840
auto out_def = output_defs.at(i);
18401841
auto outs_vector = ctx.outputs.at(output_names[i]);
18411842

1842-
std::vector<std::shared_ptr<tcmpt::TensorBase>> tmp_outputs;
1843+
std::vector<std::shared_ptr<pten::TensorBase>> tmp_outputs;
18431844
for (auto var : outs_vector) {
18441845
auto pt_out = framework::OutputVariableToPtTensor(var, out_def);
18451846
tmp_outputs.emplace_back(pt_out);
@@ -1849,12 +1850,13 @@ pt::KernelContext OperatorWithKernel::BuildPtKernelContext(
18491850

18501851
for (size_t i = 0; i < attr_names.size(); ++i) {
18511852
auto& attr = Attrs().at(attr_names[i]);
1852-
if (attr_defs[i].type_index == std::type_index(typeid(pt::Scalar))) {
1853+
if (attr_defs[i].type_index == std::type_index(typeid(pten::Scalar))) {
18531854
// TODO(chenweihang): support other attrs later
18541855
// TODO(zhangyunfei): Scalar should hold scaler type, and we should check
18551856
// attribtue type by attr_defs
18561857
if (std::type_index(attr.type()) == std::type_index(typeid(float))) {
1857-
op_kernel_ctx.EmplaceBackAttr(pt::Scalar(BOOST_GET_CONST(float, attr)));
1858+
op_kernel_ctx.EmplaceBackAttr(
1859+
pten::Scalar(BOOST_GET_CONST(float, attr)));
18581860
} else {
18591861
PADDLE_THROW(platform::errors::Unimplemented(
18601862
"unsupported cast op attribute `%s` to Scalar when construct "

paddle/fluid/framework/operator.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ limitations under the License. */
3939
#include "paddle/fluid/platform/variant.h"
4040
#include "paddle/utils/flat_hash_map.h"
4141

42-
#include "paddle/tcmpt/api/include/core.h"
42+
#include "paddle/pten/api/include/core.h"
4343

4444
namespace paddle {
4545
namespace framework {
@@ -531,7 +531,7 @@ class OperatorWithKernel : public OperatorBase {
531531
return kernel_type_->place_;
532532
}
533533

534-
/* member functions for adapting to tcmpt lib */
534+
/* member functions for adapting to pten lib */
535535
/** In the Tensor calculation library, the new Kernel adopts a clearer and
536536
* more streamlined design. The arguments of the Kernel and the input and
537537
* output arguments registered in the original OpMaker do not match in some
@@ -582,10 +582,10 @@ class OperatorWithKernel : public OperatorBase {
582582
Tensor* GetTensorFormInputSafely(const ExecutionContext& ctx,
583583
const std::string& name) const;
584584

585-
/* member functions for adapting to tcmpt lib */
585+
/* member functions for adapting to pten lib */
586586
void ChoosePtKernel(const ExecutionContext& ctx) const;
587587

588-
pt::KernelContext BuildPtKernelContext(
588+
pten::KernelContext BuildPtKernelContext(
589589
const RuntimeContext& ctx, const platform::DeviceContext& dev_ctx) const;
590590

591591
protected:
@@ -599,11 +599,11 @@ class OperatorWithKernel : public OperatorBase {
599599
mutable std::mutex cache_update_mutex_;
600600
mutable bool enable_cache_transfer_scope_ = false;
601601
// NOTE(chenweihang): Similar op members are used to adapt to
602-
// new tcmpt kernel, if there is a better design in the future,
602+
// new pten kernel, if there is a better design in the future,
603603
// we may polish the implementation here
604604
mutable bool run_pt_kernel_ = false;
605605
mutable std::unique_ptr<KernelSignature> pt_kernel_signature_;
606-
mutable std::unique_ptr<pt::Kernel> pt_kernel_;
606+
mutable std::unique_ptr<pten::Kernel> pt_kernel_;
607607
};
608608

609609
extern bool OpSupportGPU(const std::string& op_type);

0 commit comments

Comments
 (0)