diff --git a/lite/api/CMakeLists.txt b/lite/api/CMakeLists.txt index 5980e5ebe0b922e68a06bf84b51c33271d13e360..2c7a31f6636fccbbdb5d5dbb15fdf5691cf72171 100644 --- a/lite/api/CMakeLists.txt +++ b/lite/api/CMakeLists.txt @@ -10,6 +10,7 @@ if (LITE_ON_TINY_PUBLISH) endif() set(light_lib_DEPS light_api paddle_api paddle_api_light) + if ((NOT LITE_ON_TINY_PUBLISH) AND (LITE_WITH_CUDA OR LITE_WITH_X86 OR LITE_WITH_BM OR ARM_TARGET_OS STREQUAL "android" OR ARM_TARGET_OS STREQUAL "armlinux")) #full api dynamic library lite_cc_library(paddle_full_api_shared SHARED SRCS paddle_api.cc light_api.cc cxx_api.cc cxx_api_impl.cc light_api_impl.cc @@ -264,8 +265,6 @@ if (NOT LITE_ON_TINY_PUBLISH) NPU_DEPS ${npu_kernels} CL_DEPS ${opencl_kernels} FPGA_DEPS ${fpga_kernels} - CV_DEPS paddle_cv_arm - NPU_DEPS ${npu_kernels} BM_DEPS ${bm_kernels}) # The final inference library for just MobileConfig. bundle_static_library(paddle_api_full paddle_api_full_bundled bundle_full_api) diff --git a/lite/backends/x86/math/beam_search.cc b/lite/backends/x86/math/beam_search.cc index 8d61fb3bbb97705c697fba934e6cab9424f85bad..9cf3281152840416dc141f98992499c663783b7a 100644 --- a/lite/backends/x86/math/beam_search.cc +++ b/lite/backends/x86/math/beam_search.cc @@ -96,8 +96,8 @@ class BeamSearchFunctor { // : nullptr; // fill in data - std::vector low_level; - size_t low_offset = 0; + std::vector low_level; + uint64_t low_offset = 0; for (auto &items : selected_items) { low_level.push_back(low_offset); for (auto &item : items) { diff --git a/lite/backends/x86/math/beam_search_test.cc b/lite/backends/x86/math/beam_search_test.cc index 904870207b08d462025ecb4b84d6cf57f7b13f26..233fa03fbaa31165dae4453affb148276f8c6584 100644 --- a/lite/backends/x86/math/beam_search_test.cc +++ b/lite/backends/x86/math/beam_search_test.cc @@ -22,8 +22,8 @@ void PrepareCPUTensors(paddle::framework::LoDTensor* ids, paddle::framework::LoDTensor* pre_scores) { // lod paddle::framework::LoD lod; - std::vector level0({0, 2, 4}); - std::vector level1({0, 1, 2, 3, 4}); + std::vector level0({0, 2, 4}); + std::vector level1({0, 1, 2, 3, 4}); lod.push_back(level0); lod.push_back(level1); ids->set_lod(lod); diff --git a/lite/backends/x86/math/blas_impl.h b/lite/backends/x86/math/blas_impl.h index 72d0736268f342187f0be8c6348f5bed75df30ea..34b258892be05625ae88076eff175f56a53d3537 100644 --- a/lite/backends/x86/math/blas_impl.h +++ b/lite/backends/x86/math/blas_impl.h @@ -483,7 +483,7 @@ void Blas::MatMul(const lite::Tensor &mat_a, mat_a.data(), mat_b.data(), beta, - mat_out->mutable_data()); + mat_out->template mutable_data()); } template <> @@ -759,7 +759,7 @@ void Blas::MatMul(const lite::Tensor &mat_a, mat_a.data(), mat_b.data(), beta, - mat_out->mutable_data()); + mat_out->template mutable_data()); } else { PADDLE_ENFORCE(dim_a.batch_size_ == dim_b.batch_size_ || dim_a.batch_size_ == 0 || dim_b.batch_size_ == 0); @@ -773,7 +773,7 @@ void Blas::MatMul(const lite::Tensor &mat_a, mat_a.data(), mat_b.data(), beta, - mat_out->mutable_data(), + mat_out->template mutable_data(), dim_a.batch_size_ == 0 ? dim_b.batch_size_ : dim_a.batch_size_, dim_a.stride_, dim_b.stride_); diff --git a/lite/backends/x86/math/concat_and_split.cc b/lite/backends/x86/math/concat_and_split.cc index bec93dde41fdb654cfbfd20f5d9e59d1d372e3a8..df75654aebaba26b9889d97445bd889cdf2f4eb0 100644 --- a/lite/backends/x86/math/concat_and_split.cc +++ b/lite/backends/x86/math/concat_and_split.cc @@ -51,7 +51,7 @@ class ConcatFunctor { // auto cpu_place = boost::get(context.GetPlace()); // computation - auto output_data = output->mutable_data(); + auto output_data = output->template mutable_data(); int col_idx = 0; for (int j = 0; j < num; ++j) { int col_len = input_cols[j]; @@ -108,7 +108,7 @@ class SplitFunctor { int col_len = output_cols[j]; auto* out_tensor = outputs->at(j); if (out_tensor != nullptr) { - T* dst_ptr = out_tensor->mutable_data() + k * col_len; + T* dst_ptr = out_tensor->template mutable_data() + k * col_len; std::copy_n(src_ptr + col_idx, col_len, dst_ptr); // memory::Copy(cpu_place, dst_ptr, cpu_place, src_ptr + col_idx, // sizeof(T) * col_len); diff --git a/lite/backends/x86/math/cross_entropy.cc b/lite/backends/x86/math/cross_entropy.cc index 366486924a8c4a5eefd6341183b4f1bc1c0277ad..941a34643669f060cdd18f38f92c39e529da7b19 100644 --- a/lite/backends/x86/math/cross_entropy.cc +++ b/lite/backends/x86/math/cross_entropy.cc @@ -50,8 +50,8 @@ class CrossEntropyFunctor { .reshape(batch_axis_remain) .sum(Eigen::DSizes(1))); } else { - const T* prob_data = prob->data(); - T* loss_data = out->mutable_data(); + const T* prob_data = prob->template data(); + T* loss_data = out->template mutable_data(); const int64_t* label_data = labels->data(); for (int i = 0; i < batch_size; ++i) { diff --git a/lite/backends/x86/math/im2col.cc b/lite/backends/x86/math/im2col.cc index 1c4c6a49f5bb804a57344c59368d18255e8a7912..b916c912ffc2a4d62b63b98fdce150b353ba087e 100644 --- a/lite/backends/x86/math/im2col.cc +++ b/lite/backends/x86/math/im2col.cc @@ -99,7 +99,7 @@ class Col2ImFunctormutable_data(); + T* im_data = im->template mutable_data(); const T* col_data = col.data(); for (int c = 0; c < channels_col; ++c) { @@ -161,7 +161,7 @@ class Im2ColFunctordims()[1]; const T* im_data = im.data(); - T* col_data = col->mutable_data(); + T* col_data = col->template mutable_data(); for (int col_row_idx = 0; col_row_idx < col_height; ++col_row_idx) { for (int col_col_idx = 0; col_col_idx < col_width; ++col_col_idx) { @@ -235,7 +235,7 @@ class Col2ImFunctormutable_data(); + T* im_data = im->template mutable_data(); const T* col_data = col.data(); for (int col_row_idx = 0; col_row_idx < col_height; ++col_row_idx) { diff --git a/lite/backends/x86/math/im2col_cfo_cpu.h b/lite/backends/x86/math/im2col_cfo_cpu.h index 4623f045bb1cbe67605b36621efcc3285b989ad5..97579647d4ec3a9a95e033a153417cb0aaadbeb6 100644 --- a/lite/backends/x86/math/im2col_cfo_cpu.h +++ b/lite/backends/x86/math/im2col_cfo_cpu.h @@ -42,7 +42,7 @@ inline void im2col_common(const lite::Tensor& im, int channels_col = im_channels * filter_height * filter_width; const T* im_data = im.data(); - T* col_data = col->mutable_data(); + T* col_data = col->template mutable_data(); for (int c = 0; c < channels_col; ++c) { int w_offset = c % filter_width; int h_offset = (c / filter_width) % filter_height; @@ -77,7 +77,7 @@ inline void im2col_sh1sw1dh1dw1ph0pw0(const lite::Tensor& im, int output_width = col->dims()[4]; const T* im_data = im.data(); - T* col_data = col->mutable_data(); + T* col_data = col->template mutable_data(); int col_matrix_width = output_width * output_height; int im_size = im_height * im_width; size_t copy_size = sizeof(T) * output_width; @@ -123,7 +123,7 @@ inline void im2col_sh1sw1dh1dw1ph1pw1(const lite::Tensor& im, constexpr int prw = 1; const T* im_data = im.data(); - T* col_data = col->mutable_data(); + T* col_data = col->template mutable_data(); int im_size = im_height * im_width; int col_matrix_width = output_width * output_height; int col_block_fh = filter_width * col_matrix_width; // fw*oh*ow diff --git a/lite/backends/x86/math/math_function.cc b/lite/backends/x86/math/math_function.cc index a17807e8a997f0ecf908313a4cb205676e4fa4b8..05a10b5a19fbc8e80ee6dd07e67154d9cf6d1b22 100644 --- a/lite/backends/x86/math/math_function.cc +++ b/lite/backends/x86/math/math_function.cc @@ -65,7 +65,7 @@ struct TensorSetConstantCPU { : tensor_(tensor), value_(value) {} template void apply() const { - auto* begin = tensor_->mutable_data(lite::TargetType::kX86); + auto* begin = tensor_->template mutable_data(lite::TargetType::kX86); std::fill(begin, begin + tensor_->numel(), static_cast(value_)); } lite::Tensor* tensor_; @@ -126,7 +126,7 @@ struct RowwiseAdd { const T* input_data = input.data(); const T* vector_data = vector.data(); - T* output_data = output->mutable_data(); + T* output_data = output->template mutable_data(); for (int64_t i = 0; i < in_dims[0]; ++i) { for (int64_t j = 0; j < size; ++j) { output_data[i * in_dims[0] + j] = diff --git a/lite/backends/x86/math/math_function_impl.h b/lite/backends/x86/math/math_function_impl.h index 3aaca2e59370f8f2b922554ec6f378bb2a3de9b5..acfb76759f6fc9fa4122afd2388bc3adf8f5ea22 100644 --- a/lite/backends/x86/math/math_function_impl.h +++ b/lite/backends/x86/math/math_function_impl.h @@ -83,7 +83,7 @@ class ColwiseSum { auto size = in_dims[1]; PADDLE_ENFORCE_EQ(out->numel(), size); - T* out_buf = out->mutable_data(out->target()); + T* out_buf = out->template mutable_data(out->target()); const T* in_buf = input.data(); for (size_t i = 0; i < static_cast(height); ++i) { @@ -129,7 +129,7 @@ class RowwiseMean { auto size = in_dims[1]; PADDLE_ENFORCE_EQ(out->numel(), height); auto inv_size = 1.0 / size; - T* out_buf = out->mutable_data(out->target()); + T* out_buf = out->template mutable_data(out->target()); const T* in_buf = input.data(); for (size_t i = 0; i < static_cast(height); ++i) { @@ -173,7 +173,7 @@ class RowwiseSum { auto size = in_dims[1]; PADDLE_ENFORCE_EQ(out->numel(), height); - T* out_buf = out->mutable_data(out->target()); + T* out_buf = out->template mutable_data(out->target()); const T* in_buf = input.data(); for (size_t i = 0; i < static_cast(height); ++i) { diff --git a/lite/backends/x86/math/maxouting.cc b/lite/backends/x86/math/maxouting.cc index 20b40fe7c5000cc1d0ee80c18efa5d1defc911f0..f97b16f7fb3326a6d2eb186e2984df3dbd0a0a90 100644 --- a/lite/backends/x86/math/maxouting.cc +++ b/lite/backends/x86/math/maxouting.cc @@ -35,7 +35,7 @@ class MaxOutFunctor { // c_size means the output size of each sample int c_size = fea_size * output_channels; const T* input_data = input.data(); - T* output_data = output->mutable_data(lite::TargetType::kX86); + T* output_data = output->template mutable_data(lite::TargetType::kX86); for (int i = 0; i < batch_size; ++i) { int new_bindex = c_size * i; @@ -72,7 +72,8 @@ class MaxOutGradFunctor { const T* input_data = input.data(); const T* output_data = output.data(); const T* output_grad_data = output_grad.data(); - T* input_grad_data = input_grad->mutable_data(lite::TargetType::kX86); + T* input_grad_data = + input_grad->template mutable_data(lite::TargetType::kX86); for (int i = 0; i < batch_size; ++i) { int blen = fea_size * output_channels * i; diff --git a/lite/backends/x86/math/pooling.cc b/lite/backends/x86/math/pooling.cc index ab6c1edb481f914d5751149aca2595fee550ca51..4393c42157bb7667ec2218e8b76f05a2c60bcc86 100644 --- a/lite/backends/x86/math/pooling.cc +++ b/lite/backends/x86/math/pooling.cc @@ -54,8 +54,8 @@ class Pool2dFunctor { const int input_stride = input_height * input_width; const int output_stride = output_height * output_width; - const T* input_data = input->data(); - T* output_data = output->mutable_data(lite::TargetType::kX86); + const T* input_data = input->template data(); + T* output_data = output->template mutable_data(lite::TargetType::kX86); int hstart, hend; int wstart, wend; @@ -137,7 +137,8 @@ class Pool2dGradFunctor { const T* input_data = input.data(); const T* output_data = output.data(); const T* output_grad_data = output_grad.data(); - T* input_grad_data = input_grad->mutable_data(lite::TargetType::kX86); + T* input_grad_data = + input_grad->template mutable_data(lite::TargetType::kX86); int hstart, hend; int wstart, wend; @@ -220,7 +221,8 @@ class MaxPool2dGradFunctor { const T* input_data = input.data(); const T* output_data = output.data(); const T* output_grad_data = output_grad.data(); - T* input_grad_data = input_grad->mutable_data(lite::TargetType::kX86); + T* input_grad_data = + input_grad->template mutable_data(lite::TargetType::kX86); for (int i = 0; i < batch_size; i++) { for (int c = 0; c < output_channels; ++c) { @@ -322,7 +324,7 @@ class Pool3dFunctor { const int output_stride = output_depth * output_height * output_width; const T* input_data = input.data(); - T* output_data = output->mutable_data(lite::TargetType::kX86); + T* output_data = output->template mutable_data(lite::TargetType::kX86); int dstart, dend; int hstart, hend; @@ -425,7 +427,8 @@ class Pool3dGradFunctor { const T* input_data = input.data(); const T* output_data = output.data(); const T* output_grad_data = output_grad.data(); - T* input_grad_data = input_grad->mutable_data(lite::TargetType::kX86); + T* input_grad_data = + input_grad->template mutable_data(lite::TargetType::kX86); int dstart, dend; int hstart, hend; @@ -530,7 +533,8 @@ class MaxPool3dGradFunctor { const T* input_data = input.data(); const T* output_data = output.data(); const T* output_grad_data = output_grad.data(); - T* input_grad_data = input_grad->mutable_data(lite::TargetType::kX86); + T* input_grad_data = + input_grad->template mutable_data(lite::TargetType::kX86); for (int i = 0; i < batch_size; i++) { for (int c = 0; c < output_channels; ++c) { diff --git a/lite/backends/x86/math/sample_prob.h b/lite/backends/x86/math/sample_prob.h index 5312b3df10a41444c073f0cf61d69bce6fc3859a..4351df68a2630c2b8c6f7285f3955a9b06165f67 100644 --- a/lite/backends/x86/math/sample_prob.h +++ b/lite/backends/x86/math/sample_prob.h @@ -58,11 +58,11 @@ class SampleWithProb { const int64_t* label_data = L->data(); // int64_t* samples_data = // S->mutable_data(ret_dim, Target); - // T* probabilities_data = P->mutable_data(ret_dim, Target); + // T* probabilities_data = P->template mutable_data(ret_dim, Target); S->Resize({batch_size, num_sampled_classes}); auto* samples_data = S->mutable_data(Target); P->Resize({batch_size, num_sampled_classes}); - auto* probabilities_data = P->mutable_data(Target); + auto* probabilities_data = P->template mutable_data(Target); // temp sets for unique sampling std::unordered_set tmp_samples; diff --git a/lite/backends/x86/math/search_fc.cc b/lite/backends/x86/math/search_fc.cc index 56fc363cb48ec5c58f4a7ee3e62a2e6bd7355021..014b213d4f10f7161dc1881d582cca93f2be58e5 100644 --- a/lite/backends/x86/math/search_fc.cc +++ b/lite/backends/x86/math/search_fc.cc @@ -42,7 +42,7 @@ class SearchFcFunctor { lite::DDim dims(std::vector({bottom.dims()[0], out_size})); const auto bottom_data = bottom.data(); - auto top_data = top->mutable_data(lite::TargetType::kX86); + auto top_data = top->template mutable_data(lite::TargetType::kX86); const auto weights = w.data(); auto blas = math::GetBlas(context); call_gemm(blas, diff --git a/lite/backends/x86/math/selected_rows_functor.cc b/lite/backends/x86/math/selected_rows_functor.cc index f8f1b42361832771ba04d1bdc8b3e2e05f954e29..acb377e31ccac96547fc4f0644332cfad36d66bc 100644 --- a/lite/backends/x86/math/selected_rows_functor.cc +++ b/lite/backends/x86/math/selected_rows_functor.cc @@ -52,7 +52,7 @@ struct SelectedRowsAdd { PADDLE_ENFORCE_EQ(in1_row_numel, in2_value.numel() / in2_rows.size()); PADDLE_ENFORCE_EQ(in1_row_numel, out_value->numel() / out_rows.size()); - auto* out_data = out_value->mutable_data(); + auto* out_data = out_value->template mutable_data(); auto* in1_data = in1_value.data(); std::copy_n(in1_data, in1_value.numel(), out_data); @@ -87,7 +87,7 @@ struct SelectedRowsAddTensor { functor(context, output, 0.0); auto* in1_data = in1_value.data(); - auto* out_data = output->mutable_data(); + auto* out_data = output->template mutable_data(); for (size_t i = 0; i < in1_rows.size(); i++) { for (int64_t j = 0; j < in1_row_numel; j++) { @@ -127,7 +127,7 @@ struct SelectedRowsAddTo { in2_rows.insert(in2_rows.end(), in1_rows.begin(), in1_rows.end()); auto* in1_data = in1_value.data(); - auto* in2_data = in2_value->mutable_data(); + auto* in2_data = in2_value->template mutable_data(); std::copy_n(in1_data, in1_value.numel(), in2_data + input2_offset); } }; @@ -161,7 +161,7 @@ struct SelectedRowsSumTo { input2->set_rows(in2_rows); auto* in2_value = input2->mutable_value(); - T* in2_data = in2_value->mutable_data(); + T* in2_data = in2_value->template mutable_data(); auto blas = math::GetBlas(context); size_t offset = 0u; for (size_t i = 0u; i != input1.size(); ++i) { @@ -194,7 +194,7 @@ struct SelectedRowsAddToTensor { PADDLE_ENFORCE_EQ(in1_row_numel, input2->numel() / in1_height); auto* in1_data = in1_value.data(); - auto* input2_data = input2->mutable_data(); + auto* input2_data = input2->template mutable_data(); for (size_t i = 0; i < in1_rows.size(); i++) { for (int64_t j = 0; j < in1_row_numel; j++) { @@ -305,7 +305,7 @@ struct MergeAdd { lite::DDim dims(std::vector( {static_cast(merged_row_set.size()), input_width})); out.mutable_value()->Resize(dims); - auto* out_data = out.mutable_value()->mutable_data(); + auto* out_data = out.mutable_value()->template mutable_data(); if (merged_row_set.size() == row_num && !sorted_result) { // no duplicated ids, just concat the result together @@ -385,7 +385,7 @@ struct UpdateToTensor { PADDLE_ENFORCE_EQ(in1_row_numel, input2->numel() / in1_height); auto* in1_data = in1_value.data(); - auto* input2_data = input2->data(); + auto* input2_data = input2->template data(); // FIXME(typhoonzero): use macro fix the below messy code. switch (op) { diff --git a/lite/backends/x86/math/sequence2batch.cc b/lite/backends/x86/math/sequence2batch.cc index c12c05414d717dce706590a491ccae2384f3bfe5..aa7aeac532e2fa1f90d452924b364be1896ee862 100644 --- a/lite/backends/x86/math/sequence2batch.cc +++ b/lite/backends/x86/math/sequence2batch.cc @@ -24,10 +24,10 @@ class CopyMatrixRowsFunctor { public: void operator()(const lite::Context& context, const lite::Tensor& src, - const std::vector& index_lod, + const std::vector& index_lod, lite::Tensor* dst, bool is_src_index) { - const size_t* index = index_lod.data(); + const uint64_t* index = index_lod.data(); const auto& src_dims = src.dims(); const auto& dst_dims = dst->dims(); PADDLE_ENFORCE_EQ( @@ -39,7 +39,7 @@ class CopyMatrixRowsFunctor { auto height = dst_dims[0]; auto width = dst_dims[1]; auto* src_data = src.data(); - auto* dst_data = dst->mutable_data(); + auto* dst_data = dst->template mutable_data(); const int sz = width * sizeof(T); if (is_src_index) { for (int i = 0; i < height; ++i) { diff --git a/lite/backends/x86/math/sequence2batch.h b/lite/backends/x86/math/sequence2batch.h index a70cc5bf73522f97ab312fc48553b5316dbf8376..63df008b6dfca936265019a71ac0a553c525dc73 100644 --- a/lite/backends/x86/math/sequence2batch.h +++ b/lite/backends/x86/math/sequence2batch.h @@ -36,7 +36,7 @@ class CopyMatrixRowsFunctor { // The indexed rows are based on the input index. void operator()(const lite::Context& context, const lite::Tensor& src, - const std::vector& index_lod, + const std::vector& index_lod, lite::Tensor* dst, bool is_src_index); }; @@ -130,8 +130,8 @@ class LoDTensor2BatchFunctor { // batch_lods[2] is the sort order for the input LoDTensor. batch_lods->at(2).resize(seq_info.size()); - size_t* batch_starts = batch_lods->at(0).data(); - size_t* seq2batch_idx = batch_lods->at(1).data(); + auto* batch_starts = batch_lods->at(0).data(); + auto* seq2batch_idx = batch_lods->at(1).data(); batch_starts[0] = 0; for (int n = 0; n < max_seqlen; n++) { auto batch_id = static_cast(batch_starts[n]); @@ -148,7 +148,7 @@ class LoDTensor2BatchFunctor { } batch_starts[n + 1] = static_cast(batch_id); } - size_t* seq_order = batch_lods->at(2).data(); + auto* seq_order = batch_lods->at(2).data(); for (size_t i = 0; i < seq_info.size(); ++i) { seq_order[i] = seq_info[i].seq_idx; } diff --git a/lite/backends/x86/math/sequence_padding.cc b/lite/backends/x86/math/sequence_padding.cc index fbb6c11a5f7a0cbae36d2f8fba0b141dadadf542..eb977dc2d23f4cfaeec7dd5a6e2834ca23345f76 100644 --- a/lite/backends/x86/math/sequence_padding.cc +++ b/lite/backends/x86/math/sequence_padding.cc @@ -22,15 +22,15 @@ namespace math { template void CopyValidData(lite::Tensor* dst_tensor, const lite::Tensor* src_tensor, - const std::vector& seq_offsets, + const std::vector& seq_offsets, int pad_seq_len, int step_width, bool norm_by_len, CopyType type, PadLayout layout) { int seq_num = seq_offsets.size() - 1; - const T* src_data = src_tensor->data(); - T* dst_data = dst_tensor->mutable_data(); + const T* src_data = src_tensor->template data(); + T* dst_data = dst_tensor->template mutable_data(); int seq_cpy_gap = step_width; int pad_cpy_gap = @@ -113,7 +113,7 @@ class PaddingLoDTensorFunctor { "'step_width'."); // fill padding value - T* pad_data = pad_tensor->mutable_data(); + T* pad_data = pad_tensor->template mutable_data(); const T* pad_value_data = pad_value.data(); if (pad_value.numel() == 1) { fast_mem_init( diff --git a/lite/backends/x86/math/sequence_padding.h b/lite/backends/x86/math/sequence_padding.h index a3f4512042de4c7a2fc665f2fd41777d472225f5..43407014dea0ed0c78ab29da7fb8ebb0e0310566 100644 --- a/lite/backends/x86/math/sequence_padding.h +++ b/lite/backends/x86/math/sequence_padding.h @@ -30,10 +30,10 @@ enum PadLayout { kBatchLengthWidth = 0, kLengthBatchWidth }; enum CopyType { kSeqToPad, kPadToSeq }; -inline static size_t MaximumSequenceLength( - const std::vector& seq_offset) { - size_t seq_num = seq_offset.size() - 1; - size_t max_seq_len = 0; +inline static uint64_t MaximumSequenceLength( + const std::vector& seq_offset) { + uint64_t seq_num = seq_offset.size() - 1; + uint64_t max_seq_len = 0; for (size_t i = 0; i < seq_num; ++i) { max_seq_len = std::max(max_seq_len, seq_offset[i + 1] - seq_offset[i]); } @@ -42,7 +42,7 @@ inline static size_t MaximumSequenceLength( inline static void CheckDims(const lite::DDim& seq_tensor_dims, const lite::DDim& pad_tensor_dims, - const std::vector& seq_offset, + const std::vector& seq_offset, int64_t padded_seq_len, int64_t step_width, const PadLayout& layout) { diff --git a/lite/backends/x86/math/sequence_pooling.cc b/lite/backends/x86/math/sequence_pooling.cc index 186b8b5543c7132867093616c83b45ae8ff27d3c..34c55c5714e467954bc1bb79d9b1385ef5cfe497 100644 --- a/lite/backends/x86/math/sequence_pooling.cc +++ b/lite/backends/x86/math/sequence_pooling.cc @@ -55,7 +55,7 @@ class MaxSeqPoolFunctor { auto starts = input.lod()[0]; const T* in_data = input.data(); - T* out_data = output->mutable_data(); + T* out_data = output->template mutable_data(); int* max_index = index->mutable_data(); int64_t num_seq = out_dims[0]; @@ -103,7 +103,7 @@ class MaxSeqPoolFunctor { auto starts = input.lod()[0]; const T* in_data = input.data(); - T* out_data = output->mutable_data(); + T* out_data = output->template mutable_data(); int64_t num_seq = out_dims[0]; int64_t dim = output->numel() / num_seq; @@ -145,7 +145,7 @@ class MaxSeqPoolGradFunctor { const T* og_data = out_grad.data(); const int* max_index = index.data(); - T* ig_data = in_grad->mutable_data(); + T* ig_data = in_grad->template mutable_data(); SetConstant set_zero; set_zero(context, in_grad, static_cast(0.0)); @@ -170,7 +170,7 @@ class LastSeqPoolFunctor { lite::Tensor* output) { // Create pointers to input and output data auto* in_data = input.data(); - auto* out_data = output->mutable_data(); + auto* out_data = output->template mutable_data(); // Calculate the size of each item in sequence int64_t item_size = input.numel() / input.dims()[0]; @@ -203,7 +203,7 @@ class FirstSeqPoolFunctor { lite::Tensor* output) { // Create pointers to input and output data auto* in_data = input.data(); - auto* out_data = output->mutable_data(); + auto* out_data = output->template mutable_data(); // Calculate the size of each item in sequence int64_t item_size = input.numel() / input.dims()[0]; @@ -238,7 +238,7 @@ class SumSeqPoolGradFunctor { int64_t in_w = in_grad->numel() / in_grad->dims()[0]; PADDLE_ENFORCE(in_w == out_w); const T* out_g_data = out_grad.data(); - T* in_g_data = in_grad->mutable_data(TARGET(kX86)); + T* in_g_data = in_grad->template mutable_data(TARGET(kX86)); auto blas = math::GetBlas(context); for (int i = 0; i < static_cast(lod.size()) - 1; ++i) { int64_t h = static_cast(lod[i + 1] - lod[i]); @@ -288,7 +288,7 @@ class SequencePoolFunctor { auto lod = input.lod()[0]; if (pooltype == "SUM") { const T* src = input.data(); - T* dst = output->mutable_data(TARGET(kX86)); + T* dst = output->template mutable_data(TARGET(kX86)); jit::seq_pool_attr_t attr( static_cast(input.numel() / input.dims()[0]), jit::SeqPoolType::kSum); diff --git a/lite/backends/x86/math/sequence_pooling_test.cc b/lite/backends/x86/math/sequence_pooling_test.cc index a73014767345842f09ac2ff0cd5c2e7231c1f90a..b91f43a571994bef95650361a6dc62c0465837a7 100644 --- a/lite/backends/x86/math/sequence_pooling_test.cc +++ b/lite/backends/x86/math/sequence_pooling_test.cc @@ -101,13 +101,13 @@ void TestSequencePoolingSum(const paddle::framework::LoD& lod) { TEST(SequencePoolingGrad, CPU_SUM) { paddle::framework::LoD lod1; - lod1.push_back(std::vector{0, 10}); + lod1.push_back(std::vector{0, 10}); TestSequencePoolingSum(lod1); paddle::framework::LoD lod2; - lod2.push_back(std::vector{0, 2, 7, 10}); + lod2.push_back(std::vector{0, 2, 7, 10}); TestSequencePoolingSum(lod2); @@ -116,13 +116,13 @@ TEST(SequencePoolingGrad, CPU_SUM) { #ifdef PADDLE_WITH_CUDA TEST(SequencePoolingGrad, CUDA_SUM) { paddle::framework::LoD lod1; - lod1.push_back(std::vector{0, 10}); + lod1.push_back(std::vector{0, 10}); TestSequencePoolingSum(lod1); paddle::framework::LoD lod2; - lod2.push_back(std::vector{0, 2, 7, 10}); + lod2.push_back(std::vector{0, 2, 7, 10}); TestSequencePoolingSum(lod2); diff --git a/lite/backends/x86/math/sequence_scale.cc b/lite/backends/x86/math/sequence_scale.cc index fad0628de15379b58847827cc3d48bf6085cbda2..25c7be0d0e2747f4f28c1d82f8855872d57726d1 100644 --- a/lite/backends/x86/math/sequence_scale.cc +++ b/lite/backends/x86/math/sequence_scale.cc @@ -32,7 +32,7 @@ class ScaleLoDTensorFunctor { size_t seq_width = seq->dims()[1]; lite::LoD abs_offset_lod = lite::fluid::ToAbsOffset(lod); - T* seq_data = seq->mutable_data(lite::TargetType::kX86); + T* seq_data = seq->template mutable_data(lite::TargetType::kX86); for (size_t i = 0; i < num_seq; ++i) { for (size_t j = lod[level][i] * seq_width; j < lod[level][i + 1] * seq_width; diff --git a/lite/backends/x86/math/sequence_topk_avg_pooling.cc b/lite/backends/x86/math/sequence_topk_avg_pooling.cc index 035a7923c70f91cf27f1d845f68110f8f33cb73d..97e27fed59f4bc1a4c457ea9cf515da6caca9a1c 100644 --- a/lite/backends/x86/math/sequence_topk_avg_pooling.cc +++ b/lite/backends/x86/math/sequence_topk_avg_pooling.cc @@ -83,7 +83,7 @@ class SequenceTopkAvgPoolingFunctor { auto pos_data = pos->mutable_data(lite::TargetType::kX86); int offset = 0; - std::vector vec_out_lod; + std::vector vec_out_lod; vec_out_lod.reserve(batch_size + 1); for (int i = 0; i <= batch_size; ++i) { offset = row_lod[i]; @@ -95,7 +95,7 @@ class SequenceTopkAvgPoolingFunctor { out->set_lod(lod_temp); auto in_data = in.data(); - auto out_data = out->mutable_data(lite::TargetType::kX86); + auto out_data = out->template mutable_data(lite::TargetType::kX86); T* sum_data = new T[max_k]; for (int i = 0; i < batch_size; ++i) { diff --git a/lite/backends/x86/math/softmax_impl.h b/lite/backends/x86/math/softmax_impl.h index ec45377bc55154a4a36ebc5c3684ab7efeeef88e..1ba84dda42093155b10fa74a49e953d6663b8c88 100644 --- a/lite/backends/x86/math/softmax_impl.h +++ b/lite/backends/x86/math/softmax_impl.h @@ -108,8 +108,8 @@ class SoftmaxFunctor> { const int num_remain = num_classes / axis_dim; if (num_remain == 1 && lite::x86::MayIUse(lite::x86::avx)) { - const T* in_data = X->data(); - auto* out_data = Y->mutable_data(); + const T* in_data = X->template data(); + auto* out_data = Y->template mutable_data(); for (int bs = 0; bs < batch_size; ++bs) { T max_val = *std::max_element(in_data, in_data + num_classes); max_val *= static_cast(-1); @@ -219,9 +219,9 @@ class SoftmaxGradFunctor> { const int num_remain = num_classes / axis_dim; if (num_remain == 1 && lite::x86::MayIUse(lite::x86::avx)) { - const T* out_data = y->data(); - const T* out_grad = y_grad->data(); - T* in_grad = x_grad->mutable_data(); + const T* out_data = y->template data(); + const T* out_grad = y_grad->template data(); + T* in_grad = x_grad->template mutable_data(); for (int bs = 0; bs < batch_size; ++bs) { T scalar; vec_mul_reduce( diff --git a/lite/backends/x86/math/tree2col.cc b/lite/backends/x86/math/tree2col.cc index 20b913331308c8b8c95d190b6b0b3d76ccac354b..bfc7084c9ff018101ca3dfc1d1748083b1449662 100644 --- a/lite/backends/x86/math/tree2col.cc +++ b/lite/backends/x86/math/tree2col.cc @@ -104,12 +104,12 @@ class Tree2ColFunctor { patch_size = processing_list.size(); // T *patch_data = - // patch->mutable_data({static_cast(patch_size), + // patch->template mutable_data({static_cast(patch_size), // static_cast(patch_elem_size)}, // cpu_place); patch->Resize({static_cast(patch_size), static_cast(patch_elem_size)}); - auto *patch_data = patch->mutable_data(lite::TargetType::kX86); + auto *patch_data = patch->template mutable_data(lite::TargetType::kX86); constant(context, patch, 0); const T *features = node_features.data(); @@ -166,12 +166,12 @@ class Col2TreeFunctor { } } // T *grad_data = - // in_grad->mutable_data({static_cast(node_count), + // in_grad->template mutable_data({static_cast(node_count), // static_cast(grad_elem_size)}, // cpu_place); in_grad->Resize({static_cast(node_count), static_cast(grad_elem_size)}); - auto *grad_data = in_grad->mutable_data(lite::TargetType::kX86); + auto *grad_data = in_grad->template mutable_data(lite::TargetType::kX86); constant(context, in_grad, 0); const T *out_g = out_grad.data(); diff --git a/lite/backends/x86/math/unpooling.cc b/lite/backends/x86/math/unpooling.cc index 568f9952cab755c8441695e1a9266a2001d2b9a9..119d7294e9ec21e67f09776ad20d04f15b8b81ce 100644 --- a/lite/backends/x86/math/unpooling.cc +++ b/lite/backends/x86/math/unpooling.cc @@ -36,7 +36,7 @@ class Unpool2dMaxFunctor { int output_feasize = output_height * output_width; const T* input_data = input.data(); const int* indices_data = indices.data(); - T* output_data = output->mutable_data(lite::TargetType::kX86); + T* output_data = output->template mutable_data(lite::TargetType::kX86); for (int b = 0; b < batch_size; ++b) { for (int c = 0; c < output_channels; ++c) { for (int i = 0; i < input_feasize; ++i) { @@ -70,7 +70,8 @@ class Unpool2dMaxGradFunctor { int output_feasize = output_height * output_width; const int* indices_data = indices.data(); const T* output_grad_data = output_grad.data(); - T* input_grad_data = input_grad->mutable_data(lite::TargetType::kX86); + T* input_grad_data = + input_grad->template mutable_data(lite::TargetType::kX86); for (int b = 0; b < batch_size; ++b) { for (int c = 0; c < output_channels; ++c) { diff --git a/lite/backends/x86/math/vol2col.cc b/lite/backends/x86/math/vol2col.cc index 8fd5e8954e2010d5226d56ac4a87a44e6364c8c6..91979bb7fdcfe66d84ded3f9797144ddafc8769e 100644 --- a/lite/backends/x86/math/vol2col.cc +++ b/lite/backends/x86/math/vol2col.cc @@ -75,7 +75,7 @@ class Vol2ColFunctor { "mismatching."); const T* vol_data = vol.data(); - T* col_data = col->mutable_data(); + T* col_data = col->template mutable_data(); for (int c = 0; c < channels_col; ++c) { int w_offset = c % filter_width; @@ -159,7 +159,7 @@ class Col2VolFunctor { output_width, "input_width and output_width are " "mismatching."); - T* vol_data = vol->mutable_data(); + T* vol_data = vol->template mutable_data(); const T* col_data = col.data(); for (int c = 0; c < channels_col; ++c) { diff --git a/lite/fluid/lod.h b/lite/fluid/lod.h index 36386f7eb967f31ec258681fe17222a928aa7b4b..b1f2f14a0a4534e588d18237826858812740db69 100644 --- a/lite/fluid/lod.h +++ b/lite/fluid/lod.h @@ -19,7 +19,7 @@ namespace paddle { namespace lite { namespace fluid { -using LoD = std::vector>; +using LoD = std::vector>; static LoD ToAbsOffset(const LoD &in) { // the lowest level stores relative offsets diff --git a/lite/kernels/x86/activation_compute.h b/lite/kernels/x86/activation_compute.h index 5d8110e67c17f3a0f8d3211179df831dad83cc9b..d41de08d7ceccceb0c0ea77c306459118b0eb309 100644 --- a/lite/kernels/x86/activation_compute.h +++ b/lite/kernels/x86/activation_compute.h @@ -231,8 +231,8 @@ class SoftsignCompute : public KernelLite { // auto& context = ctx_->As(); auto& param = *param_.get_mutable(); - const T* x_data = param.X->data(); - T* out_data = param.Out->mutable_data(); + const T* x_data = param.X->template data(); + T* out_data = param.Out->template mutable_data(); size_t x_size = param.X->numel(); for (size_t i = 0; i < x_size; i++) { out_data[i] = x_data[i] / (static_cast(1) + std::abs(x_data[i])); diff --git a/lite/kernels/x86/attention_padding_mask_compute.h b/lite/kernels/x86/attention_padding_mask_compute.h index b9124e5ad49a0d68c41a21fe55d28102f09d14b9..f6d3d5aa31df1f188c196ac283c734c879f40244 100644 --- a/lite/kernels/x86/attention_padding_mask_compute.h +++ b/lite/kernels/x86/attention_padding_mask_compute.h @@ -45,9 +45,9 @@ class AttentionPaddingMaskCompute auto src_len = static_cast(bottom1->lod()[0][1]); const int att_batch = bottom0->lod()[0].size() - 1; const int src_batch = bottom1->lod()[0].size() - 1; - int* pad_begin = _pad_begin->mutable_data(); + int* pad_begin = _pad_begin->template mutable_data(); for (int i = 0; i < src_batch; ++i) { - const auto* src_data = bottom1->data() + src_len * i; + const auto* src_data = bottom1->template data() + src_len * i; int index = src_len - 1; for (; index >= 0 && _pad_id == static_cast(src_data[index]); --index) { @@ -56,13 +56,14 @@ class AttentionPaddingMaskCompute } const auto att_len = static_cast(bottom0->lod()[0][1]); - auto* top_data = top->mutable_data(); + auto* top_data = top->template mutable_data(); memcpy(top_data, - bottom0->data(), + bottom0->template data(), bottom0->dims()[0] * bottom0->dims()[1] * sizeof(T)); for (int i = 0; i < att_batch; ++i) { for (int j = 0; j < att_len; ++j) { - top_data = top->mutable_data() + src_len * (att_len * i + j); + top_data = + top->template mutable_data() + src_len * (att_len * i + j); int src_idx = i % src_batch; for (int k = pad_begin[src_idx]; k < src_len; ++k) { top_data[k] = _mask; diff --git a/lite/kernels/x86/batch_norm_compute.h b/lite/kernels/x86/batch_norm_compute.h index 092280752cb92e1784eefc09cb26fa3bea8eb939..0f206b8c32aaaf9b3a1b278a69f3a9aa77a11ba6 100644 --- a/lite/kernels/x86/batch_norm_compute.h +++ b/lite/kernels/x86/batch_norm_compute.h @@ -59,26 +59,26 @@ class BatchNormCompute : public KernelLite { const int sample_size = x->dims().production() / N / C; // alloc memory - param.y->mutable_data(); + param.y->template mutable_data(); if (!param.is_test) { - param.mean_out->mutable_data(); - param.variance_out->mutable_data(); - param.saved_mean->mutable_data(); - param.saved_variance->mutable_data(); + param.mean_out->template mutable_data(); + param.variance_out->template mutable_data(); + param.saved_mean->template mutable_data(); + param.saved_variance->template mutable_data(); } if (!global_stats) { // saved_xx is use just in this batch of data - EigenVectorArrayMap saved_mean_e(param.saved_mean->mutable_data(), - C); + EigenVectorArrayMap saved_mean_e( + param.saved_mean->template mutable_data(), C); EigenVectorArrayMap saved_variance_e( - param.saved_variance->mutable_data(), C); + param.saved_variance->template mutable_data(), C); saved_mean_e.setZero(); saved_variance_e.setZero(); - EigenVectorArrayMap running_mean_arr(param.mean_out->mutable_data(), - C); + EigenVectorArrayMap running_mean_arr( + param.mean_out->template mutable_data(), C); EigenVectorArrayMap running_var_arr( - param.variance_out->mutable_data(), C); + param.variance_out->template mutable_data(), C); if ((N * sample_size) == 1) { LOG(WARNING) << "Only 1 element in normalization dimension, " @@ -89,7 +89,8 @@ class BatchNormCompute : public KernelLite { switch (param.data_layout) { case DATALAYOUT(kNCHW): { - ConstEigenArrayMap x_arr(x->data(), sample_size, N * C); + ConstEigenArrayMap x_arr( + x->template data(), sample_size, N * C); for (int nc = 0; nc < N * C; ++nc) { saved_mean_e(nc % C) += x_arr.col(nc).sum(); } @@ -115,33 +116,37 @@ class BatchNormCompute : public KernelLite { // use SavedMean and SavedVariance to do normalize Eigen::Array inv_std(C); if (global_stats) { - ConstEigenVectorArrayMap var_arr(param.variance->data(), C); + ConstEigenVectorArrayMap var_arr(param.variance->template data(), + C); inv_std = (var_arr + param.epsilon).sqrt().inverse(); } else { EigenVectorArrayMap saved_inv_std( - param.saved_variance->mutable_data(), C); + param.saved_variance->template mutable_data(), C); // inverse SavedVariance first, gradient will use it too. saved_inv_std = (saved_inv_std + param.epsilon).inverse().sqrt(); inv_std = saved_inv_std; } ConstEigenVectorArrayMap mean_arr( - global_stats ? param.mean->data() : param.saved_mean->data(), C); + global_stats ? param.mean->template data() + : param.saved_mean->template data(), + C); // ((x - est_mean) * (inv_var) * scale + bias // formula transform ====> // (x * inv_var * scale) + (bias - est_mean * inv_var * scale) - ConstEigenVectorArrayMap scale_arr(param.scale->data(), C); - ConstEigenVectorArrayMap bias_arr(param.bias->data(), C); + ConstEigenVectorArrayMap scale_arr(param.scale->template data(), C); + ConstEigenVectorArrayMap bias_arr(param.bias->template data(), C); Eigen::Array new_scale = inv_std * scale_arr; Eigen::Array new_bias = bias_arr - mean_arr * inv_std * scale_arr; switch (param.data_layout) { case DATALAYOUT(kNCHW): { - EigenArrayMap y_arr(param.y->mutable_data(), sample_size, N * C); - ConstEigenArrayMap x_arr(x->data(), sample_size, N * C); + EigenArrayMap y_arr( + param.y->template mutable_data(), sample_size, N * C); + ConstEigenArrayMap x_arr(x->template data(), sample_size, N * C); for (int nc = 0; nc < N * C; ++nc) { y_arr.col(nc) = x_arr.col(nc) * new_scale(nc % C) + new_bias(nc % C); } diff --git a/lite/kernels/x86/concat_compute.h b/lite/kernels/x86/concat_compute.h index 935f0811d4e7a7cbe2ce5fafa61b6d16a25d4a81..e423cd04f16917f200f45ac93d9a6a09f3fb1c54 100644 --- a/lite/kernels/x86/concat_compute.h +++ b/lite/kernels/x86/concat_compute.h @@ -47,7 +47,7 @@ class ConcatCompute : public KernelLite { int64_t axis = static_cast(param.axis); auto* axis_tensor = param.axis_tensor; if (axis_tensor != nullptr) { - auto* axis_tensor_data = axis_tensor->data(); + auto* axis_tensor_data = axis_tensor->template data(); axis = static_cast(axis_tensor_data[0]); } @@ -60,7 +60,7 @@ class ConcatCompute : public KernelLite { int concat_input_size = count(axis + 1, x_dims.size(), x_dims); const int top_concat_axis = out->dims()[axis]; for (size_t i = 0; i < param.x.size(); ++i) { - const T* bottom_data = param.x[i]->data(); + const T* bottom_data = param.x[i]->template data(); const int64_t bottom_concat_axis = param.x[i]->dims()[axis]; for (int n = 0; n < num_concat; ++n) { std::memcpy( diff --git a/lite/kernels/x86/conv_compute.h b/lite/kernels/x86/conv_compute.h index e9f403059f90cf6635bc22db3e6890b86cbe85f6..29442158c756418327dd3de31fd4dfdbec2cbc1d 100644 --- a/lite/kernels/x86/conv_compute.h +++ b/lite/kernels/x86/conv_compute.h @@ -52,7 +52,7 @@ class Conv2dCompute : public KernelLite { auto& context = ctx_->As(); auto& param = *param_.get_mutable(); lite::Tensor filter = *param.filter; - param.output->mutable_data(); + param.output->template mutable_data(); const int batch_size = static_cast(param.x->dims()[0]); std::vector filter_shape_vec(filter.dims().Vectorize()); @@ -95,9 +95,9 @@ class Conv2dCompute : public KernelLite { auto blas = paddle::lite::x86::math::GetBlas(context); for (int i = 0; i < batch_size; i++) { - lite::Tensor in_batch = param.x->Slice(i, i + 1); + lite::Tensor in_batch = param.x->template Slice(i, i + 1); in_batch.Resize(input_shape); - lite::Tensor out_batch = param.output->Slice(i, i + 1); + lite::Tensor out_batch = param.output->template Slice(i, i + 1); out_batch.Resize(output_matrix_shape); for (int g = 0; g < param.groups; g++) { lite::Tensor in_slice = diff --git a/lite/kernels/x86/dropout_compute.h b/lite/kernels/x86/dropout_compute.h index 2ba383bdbdc99e7643f3bf09350f833665c8548e..4b5f3359501b8b4c801c395dfa7d5990d9d4d7a3 100644 --- a/lite/kernels/x86/dropout_compute.h +++ b/lite/kernels/x86/dropout_compute.h @@ -38,10 +38,10 @@ class DropoutCompute : public KernelLite { using param_t = operators::DropoutParam; void Run() override { auto& param = *param_.get_mutable(); - const auto* x_data = param.x->data(); - auto* out_data = param.output->mutable_data(); + const auto* x_data = param.x->template data(); + auto* out_data = param.output->template mutable_data(); if (!param.is_test) { - auto* mask_data = param.mask->mutable_data(); + auto* mask_data = param.mask->template mutable_data(); std::random_device rnd; std::minstd_rand engine; int seed = param.fix_seed ? param.seed : rnd(); diff --git a/lite/kernels/x86/elementwise_op_function.h b/lite/kernels/x86/elementwise_op_function.h index 40116479f6f4d6dc8658c2d781a48b7a07dd20c9..42ea38d979e39f97a8aef971370c83303c53c48f 100644 --- a/lite/kernels/x86/elementwise_op_function.h +++ b/lite/kernels/x86/elementwise_op_function.h @@ -248,8 +248,8 @@ class TransformFunctor { lite::Tensor *z, const lite::Context &ctx, Functor func) - : x_(x->data()), - y_(y->data()), + : x_(x->template data()), + y_(y->template data()), z_(z->mutable_data()), nx_(x->numel()), ctx_(ctx), @@ -483,9 +483,10 @@ void FusedElemwiseAndActComputeNoBroadcast(const lite::Context &ctx, x.data(), y.data(), compound_functor, - out->mutable_data(), - intermediate_out == nullptr ? nullptr - : intermediate_out->mutable_data()}); + out->template mutable_data(), + intermediate_out == nullptr + ? nullptr + : intermediate_out->template mutable_data()}); } template &ctx, compound_functor, h, w, - out->mutable_data(), - intermediate_out == nullptr ? nullptr - : intermediate_out->mutable_data()); + out->template mutable_data(), + intermediate_out == nullptr + ? nullptr + : intermediate_out->template mutable_data()); } else { FusedElemwiseAndActBroadcast2CPU &ctx, n, post, compound_functor, - out->mutable_data(), - intermediate_out == nullptr ? nullptr - : intermediate_out->mutable_data()); + out->template mutable_data(), + intermediate_out == nullptr + ? nullptr + : intermediate_out->template mutable_data()); } } diff --git a/lite/kernels/x86/fc_compute.h b/lite/kernels/x86/fc_compute.h index e719b8d2216949746f612bca0689c22be0606031..9f25a2584fe8d2579939e144d6799ba79927ae63 100644 --- a/lite/kernels/x86/fc_compute.h +++ b/lite/kernels/x86/fc_compute.h @@ -140,9 +140,9 @@ class FcCompute : public KernelLite { int M = output->dims().production() / w_dims1; - const T* input_data = input->data(); - const T* w_data = w->data(); - T* output_data = output->mutable_data(); + const T* input_data = input->template data(); + const T* w_data = w->template data(); + T* output_data = output->template mutable_data(); auto& context = ctx_->As(); FCFunctor fc; @@ -153,7 +153,7 @@ class FcCompute : public KernelLite { input_data, w_data, output_data, - bias ? bias->data() : NULL, + bias ? bias->template data() : NULL, with_relu, padding_weights); } diff --git a/lite/kernels/x86/fill_constant_batch_size_like_compute.h b/lite/kernels/x86/fill_constant_batch_size_like_compute.h index 8d49b0816d85f30351a4ded81e0f6ef650b6c445..1c54912c21d1479b990c5a56064d9789e8619400 100644 --- a/lite/kernels/x86/fill_constant_batch_size_like_compute.h +++ b/lite/kernels/x86/fill_constant_batch_size_like_compute.h @@ -42,9 +42,9 @@ class FillConstantBatchSizeLikeCompute int output_dim_idx = param.output_dim_idx; odims[output_dim_idx] = static_cast(in->lod().back().size()) - 1; out->Resize(odims); - // out->mutable_data(); + // out->template mutable_data(); } - out->mutable_data(); + out->template mutable_data(); auto value = param.value; paddle::lite::x86::math::SetConstant setter; diff --git a/lite/kernels/x86/gather_compute.h b/lite/kernels/x86/gather_compute.h index 6ee270647f8fb7d7ec540047cd4d546a7eb89ce8..bd01d9da3af1640770838c262dcd848b557d40c3 100644 --- a/lite/kernels/x86/gather_compute.h +++ b/lite/kernels/x86/gather_compute.h @@ -50,9 +50,9 @@ void CPUGather(const lite::Tensor* src, auto src_dims = src->dims(); - const T* p_src = src->data(); + const T* p_src = src->template data(); const IndexT* p_index = index->data(); - T* p_output = output->mutable_data(); + T* p_output = output->template mutable_data(); // slice size int slice_size = 1; @@ -77,7 +77,7 @@ class GatherCompute : public KernelLite { auto index = param.Index; auto out = param.Out; - out->mutable_data(); + out->template mutable_data(); if (x->dims().production() == 0) return; /* * Since there's no type defined for lite::Tensor in Paddle-Lite, then diff --git a/lite/kernels/x86/gru_compute.h b/lite/kernels/x86/gru_compute.h index 89076b51dae1fed4b8f56b280f177caf1f142158..e701ba16a55e9695c6b70f07cc4e1443e6b75698 100644 --- a/lite/kernels/x86/gru_compute.h +++ b/lite/kernels/x86/gru_compute.h @@ -44,7 +44,7 @@ inline void ReorderInitState(const lite::Context& context, bool indexed_src) { lite::x86::math::CopyMatrixRowsFunctor row_shuffle; dst->Resize(src.dims()); - dst->mutable_data(); + dst->template mutable_data(); row_shuffle(context, src, index_lod, dst, indexed_src); } @@ -65,18 +65,19 @@ class GRUCompute : public KernelLite { auto* input = param.input; auto* h0 = param.h0; auto* weight = param.weight; - const T* weight_data = weight->data(); + const T* weight_data = weight->template data(); auto* bias = param.bias; auto* batch_gate = param.batch_gate; auto* batch_reset_hidden_prev = param.batch_reset_hidden_prev; auto* batch_hidden = param.batch_hidden; - T* batch_gate_ptr = batch_gate->mutable_data(); - T* batch_reset_hidden_prev_ptr = batch_reset_hidden_prev->mutable_data(); - T* batch_hidden_ptr = batch_hidden->mutable_data(); + T* batch_gate_ptr = batch_gate->template mutable_data(); + T* batch_reset_hidden_prev_ptr = + batch_reset_hidden_prev->template mutable_data(); + T* batch_hidden_ptr = batch_hidden->template mutable_data(); auto* hidden = param.hidden; - hidden->mutable_data(); + hidden->template mutable_data(); const auto& hidden_dims = hidden->dims(); @@ -99,7 +100,7 @@ class GRUCompute : public KernelLite { // Since the batch computing for GRU reorders the input sequences // according to their length. The initialized cell state also needs // to reorder. - const std::vector& order(batch_gate->lod()[2]); + const std::vector& order(batch_gate->lod()[2]); ReorderInitState(context, *h0, order, &ordered_h0, true); gru_value.prev_out_value = ordered_h0.mutable_data(); } else { diff --git a/lite/kernels/x86/layer_norm_compute.h b/lite/kernels/x86/layer_norm_compute.h index ca2ddf60c5e150ba7d2712ccb2e67e444cd07010..46d151bbc406e19b498b87420029da7f9c1c2f12 100644 --- a/lite/kernels/x86/layer_norm_compute.h +++ b/lite/kernels/x86/layer_norm_compute.h @@ -47,9 +47,9 @@ class LayerNormCompute : public KernelLite { auto x_dims = x->dims(); - y->mutable_data(); - Mean->mutable_data(); - Var->mutable_data(); + y->template mutable_data(); + Mean->template mutable_data(); + Var->template mutable_data(); auto matrix_dim = x_dims.Flatten2D(begin_norm_axis); int left = static_cast(matrix_dim[0]); @@ -73,10 +73,10 @@ class LayerNormCompute : public KernelLite { .At(right); ker(in.mutable_data(), out.mutable_data(), - Mean->mutable_data(), - Var->mutable_data(), - Scale->data(), - Bias->data(), + Mean->template mutable_data(), + Var->template mutable_data(), + Scale->template data(), + Bias->template data(), static_cast(left), epsilon, right); diff --git a/lite/kernels/x86/lookup_table_compute.h b/lite/kernels/x86/lookup_table_compute.h index 1801144f6eeb25a40fa052440b63913bc41a65a3..73cffe4ce8130b18612e42b0243205e74e011005 100644 --- a/lite/kernels/x86/lookup_table_compute.h +++ b/lite/kernels/x86/lookup_table_compute.h @@ -33,15 +33,15 @@ class LookupTableCompute : public KernelLite { auto *ids_t = param.Ids; auto *output_t = param.Out; int64_t padding_idx = param.padding_idx; - const int64_t *ids = ids_t->data(); + const int64_t *ids = ids_t->template data(); int64_t ids_numel = ids_t->dims().production(); auto *table_t = param.W; int64_t row_number = table_t->dims()[0]; int64_t row_width = table_t->dims()[1]; - const T *table = table_t->data(); - T *output = output_t->mutable_data(); + const T *table = table_t->template data(); + T *output = output_t->template mutable_data(); memset(output, 0, output_t->dims().production() * sizeof(T)); for (int64_t i = 0; i < ids_numel; ++i) { if (padding_idx != -1 && ids[i] == padding_idx) { diff --git a/lite/kernels/x86/match_matrix_tensor_compute.cc b/lite/kernels/x86/match_matrix_tensor_compute.cc index feda180d22e59b2ca0e8f0f89f3c7a1ddb8acd4a..171308b1a8b0294241e77366390c4828172bc077 100644 --- a/lite/kernels/x86/match_matrix_tensor_compute.cc +++ b/lite/kernels/x86/match_matrix_tensor_compute.cc @@ -35,7 +35,7 @@ void MatchMatrixTensorCompute::Run() { const auto& offset_l = x->lod()[0]; const auto& offset_r = y->lod()[0]; - std::vector top_offset; + std::vector top_offset; int top_size = 0; top_offset.push_back(top_size); for (size_t b = 0; b < x->lod()[0].size() - 1; b++) { @@ -97,9 +97,9 @@ void MatchMatrixTensorCompute::Run() { int batch_size = x->lod()[0].size() - 1; int lod_lv1_size = batch_size * dim_t; int lod_lv2_size = x->lod()[0].back() * dim_t; - std::vector out_lod0(batch_size + 1, 0); - std::vector out_lod1(lod_lv1_size + 1, 0); - std::vector out_lod2(lod_lv2_size + 1, 0); + std::vector out_lod0(batch_size + 1, 0); + std::vector out_lod1(lod_lv1_size + 1, 0); + std::vector out_lod2(lod_lv2_size + 1, 0); for (int i = 0; i < batch_size; i++) { out_lod0[i + 1] = out_lod0[i] + dim_t; int len_l = offset_l[i + 1] - offset_l[i]; diff --git a/lite/kernels/x86/matmul_compute.h b/lite/kernels/x86/matmul_compute.h index 3d2b3c7482c266d0c8771c9be1dbac540a315528..e17f12b6b6471bfb587fc3866695b808e11122da 100644 --- a/lite/kernels/x86/matmul_compute.h +++ b/lite/kernels/x86/matmul_compute.h @@ -56,7 +56,7 @@ class MatMulCompute : public KernelLite { auto *x = param.X; auto *y = param.Y; auto *out = param.Out; - out->mutable_data(); + out->template mutable_data(); auto blas = lite::x86::math::GetBlas(context); auto mat_dim_a = lite::x86::math::CreateMatrixDescriptor( diff --git a/lite/kernels/x86/mul_compute.h b/lite/kernels/x86/mul_compute.h index be58f24ba2ed37db6661ecaaceb0d9d70fdd75d4..5c3dbe9342c8642470e8997fc2fec6428c2aa832 100644 --- a/lite/kernels/x86/mul_compute.h +++ b/lite/kernels/x86/mul_compute.h @@ -64,7 +64,7 @@ class MulCompute : public KernelLite { y_matrix = *y; } - z->mutable_data(); + z->template mutable_data(); auto z_dim = z->dims(); if (z_dim.size() != 2) { z->Resize({x_matrix.dims()[0], y_matrix.dims()[1]}); diff --git a/lite/kernels/x86/reduce_compute.h b/lite/kernels/x86/reduce_compute.h index f93157c837995792772c86d969312bfa28341ce4..1b7c99eeef9dd80525eb9ed249bdf6ed1e493443 100644 --- a/lite/kernels/x86/reduce_compute.h +++ b/lite/kernels/x86/reduce_compute.h @@ -49,7 +49,7 @@ class ReduceSumCompute : public KernelLite { bool reduce_all = param.reduce_all; auto* input = param.x; auto* output = param.output; - param.output->mutable_data(); + param.output->template mutable_data(); const auto& dims = param.dim; bool keep_dim = param.keep_dim; diff --git a/lite/kernels/x86/scale_compute.h b/lite/kernels/x86/scale_compute.h index c78f385b96dd2bdbf83204f2a80739657350ae7e..978a81fb22f382f9f036e503e3f674d38f1467a6 100644 --- a/lite/kernels/x86/scale_compute.h +++ b/lite/kernels/x86/scale_compute.h @@ -41,8 +41,8 @@ class ScaleCompute : public KernelLite { void Run() override { auto& param = *param_.get_mutable(); - scale_compute(param.x->data(), - param.output->mutable_data(), + scale_compute(param.x->template data(), + param.output->template mutable_data(), param.x->dims().production(), param.scale, param.bias, diff --git a/lite/kernels/x86/search_grnn_compute.cc b/lite/kernels/x86/search_grnn_compute.cc index 95839ba71b9f63fad9d659fd65c0028005d29799..f25c960f19b60056bd9702a31774a378378f24d6 100644 --- a/lite/kernels/x86/search_grnn_compute.cc +++ b/lite/kernels/x86/search_grnn_compute.cc @@ -84,7 +84,7 @@ void SearchGrnnCompute::PrepareLayout(const Tensor* input_blob) { int max_width = width_data[idx_sorted_by_width_data[0]]; // start of reorganizing the input - std::vector new_offset; + std::vector new_offset; new_offset.resize(max_width + 1); new_offset[0] = 0; diff --git a/lite/kernels/x86/search_group_padding_compute.h b/lite/kernels/x86/search_group_padding_compute.h index 17244d15d9124d9d61d1f4fdef4f12590958c0be..eee2a8ac8ef757d776580eac9dfc2c6e31694107 100644 --- a/lite/kernels/x86/search_group_padding_compute.h +++ b/lite/kernels/x86/search_group_padding_compute.h @@ -50,7 +50,7 @@ class SearchGroupPaddingCompute } } - std::vector new_offset; + std::vector new_offset; new_offset.resize(batch + 1); for (int i = 0; i < batch + 1; ++i) { new_offset[i] = i * max_seq; @@ -67,7 +67,7 @@ class SearchGroupPaddingCompute top1_lod.push_back(offset); top1->set_lod(top1_lod); top1->Resize({dim0, 1}); - memset(top1->mutable_data(), + memset(top1->template mutable_data(), 0, top1->dims()[0] * top1->dims()[1] * sizeof(T)); // for padding input id @@ -76,9 +76,9 @@ class SearchGroupPaddingCompute top2->set_lod(top2_lod); top2->Resize({batch * max_seq, 1}); // copy data - const auto* bottom_data = bottom0->data(); - auto* top_data = top0->mutable_data(); - auto* top_padding_input_data = top2->mutable_data(); + const auto* bottom_data = bottom0->template data(); + auto* top_data = top0->template mutable_data(); + auto* top_padding_input_data = top2->template mutable_data(); for (int i = 0; i < batch; i++) { const int copy_step = offset[i + 1] - offset[i]; const int start = i * max_seq; diff --git a/lite/kernels/x86/search_seq_fc_compute.h b/lite/kernels/x86/search_seq_fc_compute.h index 80ef54b30b762848eceb16940c9f60ef8ba96927..0f19466e0862e36e744fe74d985ab6136dee0e8d 100644 --- a/lite/kernels/x86/search_seq_fc_compute.h +++ b/lite/kernels/x86/search_seq_fc_compute.h @@ -58,8 +58,10 @@ class SearchSeqFcCompute : public KernelLite { int M = x_dims[0]; int N = w_dims[0]; for (int i = 0; i < M; i++) { - blas.AXPY( - N, static_cast(1), b->data(), out->mutable_data() + i * N); + blas.AXPY(N, + static_cast(1), + b->template data(), + out->template mutable_data() + i * N); } } } diff --git a/lite/kernels/x86/sequence_arithmetic_compute.h b/lite/kernels/x86/sequence_arithmetic_compute.h index 88510b8b1c7a04ab01da9af331f9d1f72765b215..080d0bcd0b42f6f59266e56d0f729eb2a28d4179 100644 --- a/lite/kernels/x86/sequence_arithmetic_compute.h +++ b/lite/kernels/x86/sequence_arithmetic_compute.h @@ -39,9 +39,9 @@ class SequenceArithmeticCompute out->Resize(x->dims()); out->set_lod(x->lod()); - auto x_data = x->data(); - auto y_data = y->data(); - auto out_data = out->mutable_data(); + auto x_data = x->template data(); + auto y_data = y->template data(); + auto out_data = out->template mutable_data(); auto x_seq_offset = x->lod()[0]; auto y_seq_offset = y->lod()[0]; int seq_num = x_seq_offset.size() - 1; diff --git a/lite/kernels/x86/sequence_concat_compute.h b/lite/kernels/x86/sequence_concat_compute.h index 8dd7077f7dbbb3e61f21d63e8c935157b3d2d579..cbf8a41b7e2228d3b2fab3fe5049281850961c1e 100644 --- a/lite/kernels/x86/sequence_concat_compute.h +++ b/lite/kernels/x86/sequence_concat_compute.h @@ -25,7 +25,7 @@ namespace x86 { template inline LoD ConcatLoD(const std::vector& xs, std::vector* xs_in_order) { - std::vector result; + std::vector result; result.resize(xs[0]->lod()[0].size()); for (size_t i = 1; i < result.size(); ++i) { @@ -75,7 +75,7 @@ class SequenceConcatCompute out_dims[0] = batch_size; param.Out->Resize(out_dims); - T* dout = param.Out->mutable_data(); + T* dout = param.Out->template mutable_data(); std::vector x_in_order; param.Out->set_lod(ConcatLoD(param.X, &x_in_order)); diff --git a/lite/kernels/x86/sequence_concat_compute_test.cc b/lite/kernels/x86/sequence_concat_compute_test.cc index be1f86a5c848b5c03634ea2a1aed0d57f2283879..eb6678a655ed1eb5a7bcda1dc2a6b8afe4477d2d 100644 --- a/lite/kernels/x86/sequence_concat_compute_test.cc +++ b/lite/kernels/x86/sequence_concat_compute_test.cc @@ -26,7 +26,7 @@ namespace x86 { namespace { inline LoD ConcatLoD(const std::vector& xs, std::vector* xs_in_order) { - std::vector result; + std::vector result; result.resize(xs[0]->lod()[0].size()); for (size_t i = 1; i < result.size(); ++i) { diff --git a/lite/kernels/x86/sequence_expand_as_compute.h b/lite/kernels/x86/sequence_expand_as_compute.h index 16759c1b9f1d136d5aaf58d4531882ab6a2618a2..badbfac14cbeb120d23ea1174a9fc3a218b2224f 100644 --- a/lite/kernels/x86/sequence_expand_as_compute.h +++ b/lite/kernels/x86/sequence_expand_as_compute.h @@ -29,9 +29,10 @@ using Tensor = lite::Tensor; template struct SequenceExpandFunctor { - void operator()(const Tensor &x, - const std::vector &ref_lod, /*expand referenced lod*/ - Tensor *out) { + void operator()( + const Tensor &x, + const std::vector &ref_lod, /*expand referenced lod*/ + Tensor *out) { int64_t hight = x.dims()[0]; int64_t width = x.data_size() / hight; @@ -39,13 +40,13 @@ struct SequenceExpandFunctor { T *out_data = out->mutable_data(); for (int h_id = 0; h_id < hight; ++h_id) { - size_t span = ref_lod[h_id + 1] - ref_lod[h_id]; + uint64_t span = ref_lod[h_id + 1] - ref_lod[h_id]; if (span == 0) continue; const T *src = in_data + h_id * width; - for (int64_t w_id = 0; w_id < width; ++w_id) { + for (uint64_t w_id = 0; w_id < width; ++w_id) { T ele = src[w_id]; size_t offset = ref_lod[h_id] * width; - for (size_t k = 0; k < span; ++k) { + for (uint64_t k = 0; k < span; ++k) { out_data[offset + k * width + w_id] = ele; } } @@ -68,7 +69,7 @@ class SequenceExpandAsCompute CHECK_EQ(y_lod.size(), 1); CHECK_GT(y_lod[0].size(), 1); - out->mutable_data(); + out->template mutable_data(); SequenceExpandFunctor seq_espand_functor; seq_espand_functor(*x, y_lod[0], out); diff --git a/lite/kernels/x86/sequence_pool_compute.h b/lite/kernels/x86/sequence_pool_compute.h index 329a76658d342078ed5d708125d9ff01e0ecef02..20e0307cef2347ce68237f70c990362bbaa210e7 100644 --- a/lite/kernels/x86/sequence_pool_compute.h +++ b/lite/kernels/x86/sequence_pool_compute.h @@ -40,7 +40,7 @@ class SequencePoolCompute : public KernelLite { dims[0] = lod[0].size() - 1; out->Resize({dims}); - out->mutable_data(); + out->template mutable_data(); lite::Tensor* index = nullptr; const bool is_test = true; diff --git a/lite/kernels/x86/sequence_reshape_compute.h b/lite/kernels/x86/sequence_reshape_compute.h index 99f84ebd06e1f5742bbaee9f98ec17aee44bd871..d166f8bc3d80d9f87efb0315462daee3296f393f 100644 --- a/lite/kernels/x86/sequence_reshape_compute.h +++ b/lite/kernels/x86/sequence_reshape_compute.h @@ -64,9 +64,9 @@ class SequenceReshapeCompute out->Resize(std::vector{static_cast(out->lod()[0].back()), out_width}); - auto* dst_ptr = out->mutable_data(); + auto* dst_ptr = out->template mutable_data(); auto size = in->numel() * sizeof(T); - std::memcpy(dst_ptr, in->data(), size); + std::memcpy(dst_ptr, in->template data(), size); } virtual ~SequenceReshapeCompute() = default; diff --git a/lite/kernels/x86/shape_compute.h b/lite/kernels/x86/shape_compute.h index ee3678a7f1c6651226c479aeedcacce91085b295..e78684e629727fc7023e6ae4c3385f9c58d48a6b 100644 --- a/lite/kernels/x86/shape_compute.h +++ b/lite/kernels/x86/shape_compute.h @@ -29,7 +29,7 @@ class ShapeCompute : public KernelLite { void Run() override { auto& param = *param_.get_mutable(); // auto& context = context_->As(); - auto out_data = param.Out->mutable_data(); + auto out_data = param.Out->template mutable_data(); auto in_dims = param.X->dims(); for (int i = 0; i < in_dims.size(); ++i) { out_data[i] = in_dims[i]; diff --git a/lite/kernels/x86/softmax_compute.h b/lite/kernels/x86/softmax_compute.h index 5a18a8022773682c0853a3592a9925f3a6015e83..3abc15145bde35a2c442daa9feff7137bcb40fb4 100644 --- a/lite/kernels/x86/softmax_compute.h +++ b/lite/kernels/x86/softmax_compute.h @@ -58,7 +58,7 @@ class SoftmaxCompute : public KernelLite { auto* x = param.x; auto* output = param.output; - output->mutable_data(); + output->template mutable_data(); const int rank = x->dims().size(); const int axis = CanonicalAxis(param.axis, rank); diff --git a/lite/kernels/x86/squeeze_compute.h b/lite/kernels/x86/squeeze_compute.h index 67086f8c732d412064c6bb0bece7e8208f8a0799..3288421c14447a348efd63c8cc5ea4de9bd2b24e 100644 --- a/lite/kernels/x86/squeeze_compute.h +++ b/lite/kernels/x86/squeeze_compute.h @@ -35,8 +35,8 @@ class SqueezeCompute : public KernelLite { auto x = param.X; auto output = param.Out; auto x_dims = x->dims(); - auto* x_data = x->data(); - auto* out_data = output->mutable_data(); + auto* x_data = x->template data(); + auto* out_data = output->template mutable_data(); memcpy(out_data, x_data, x_dims.production() * sizeof(T)); } @@ -54,9 +54,9 @@ class Squeeze2Compute : public KernelLite { auto output = param.Out; auto xshape = param.XShape; auto x_dims = x->dims(); - auto* x_data = x->data(); - auto* out_data = output->mutable_data(); - auto* xshape_data = xshape->mutable_data(); + auto* x_data = x->template data(); + auto* out_data = output->template mutable_data(); + auto* xshape_data = xshape->template mutable_data(); memcpy(out_data, x_data, x_dims.production() * sizeof(T)); memcpy(xshape_data, x_data, x_dims.production() * sizeof(T)); } diff --git a/lite/kernels/x86/stack_compute.h b/lite/kernels/x86/stack_compute.h index 12a6c3490eff9d446de96366c8dd5fe6b2a4bd06..08b3515948750a5cb36627f0349c852e597619e6 100644 --- a/lite/kernels/x86/stack_compute.h +++ b/lite/kernels/x86/stack_compute.h @@ -40,9 +40,9 @@ class StackCompute : public KernelLite { if (axis < 0) axis += (x[0]->dims().size() + 1); int n = static_cast(x.size()); - auto y_data = y->mutable_data(); + auto y_data = y->template mutable_data(); std::vector x_datas(n); - for (int i = 0; i < n; ++i) x_datas[i] = x[i]->data(); + for (int i = 0; i < n; ++i) x_datas[i] = x[i]->template data(); int pre = 1, post = 1; auto dim = x[0]->dims(); diff --git a/lite/kernels/x86/transpose_compute.h b/lite/kernels/x86/transpose_compute.h index 603b96015e267aa24d20bf20f2c3090a2daab74c..5f6faed2017b6bdef60e7505bf1f0088d86b3ec1 100644 --- a/lite/kernels/x86/transpose_compute.h +++ b/lite/kernels/x86/transpose_compute.h @@ -73,7 +73,7 @@ class TransposeCompute : public KernelLite { auto& param = *param_.get_mutable(); auto* x = param.x; auto* out = param.output; - out->mutable_data(); + out->template mutable_data(); int ndims = param.axis.size(); auto& context = ctx_->As(); TransCompute( @@ -92,7 +92,7 @@ class Transpose2Compute : public KernelLite { auto& param = *param_.get_mutable(); auto* x = param.x; auto* out = param.output; - out->mutable_data(); + out->template mutable_data(); int ndims = param.axis.size(); auto& context = ctx_->As(); TransCompute( diff --git a/lite/kernels/x86/uniform_random_compute.cc b/lite/kernels/x86/uniform_random_compute.cc index 64a701d4c67a9bf908f7fc87e9923f22dde811e3..45c1c08d46e5a23857547aac15b952a1123e741f 100644 --- a/lite/kernels/x86/uniform_random_compute.cc +++ b/lite/kernels/x86/uniform_random_compute.cc @@ -34,8 +34,8 @@ class UniformRandomCompute auto *param_out = ¶m.Out->raw_tensor(); - T *data = - param_out->mutable_data(context.x86_device_context()->GetPlace()); + T *data = param_out->template mutable_data( + context.x86_device_context()->GetPlace()); unsigned int seed = static_cast(param.seed); std::minstd_rand engine; diff --git a/lite/kernels/x86/var_conv_2d_compute.h b/lite/kernels/x86/var_conv_2d_compute.h index 7a9ba16d2ea87adb40df23e1fbe149ab805afbc8..1bed39f479c87636ff217c8fd7234ea2c5bd5904 100644 --- a/lite/kernels/x86/var_conv_2d_compute.h +++ b/lite/kernels/x86/var_conv_2d_compute.h @@ -80,7 +80,7 @@ class VarConv2DCompute : public KernelLite { std::vector col_dims_vec{top_size}; col_dims_vec.push_back(1); col->Resize(col_dims_vec); - auto* top_data = col->mutable_data(); + auto* top_data = col->template mutable_data(); const auto* bottom_data = input.data(); int kernel_win_size = kernel_h * kernel_w; @@ -149,7 +149,7 @@ class VarConv2DCompute : public KernelLite { // const auto& offset_y = in_row->lod()[0]; const auto& offset_y = param.X->lod()[1]; const auto& offset_x = param.X->lod()[2]; - std::vector top_offset; + std::vector top_offset; int top_size = 0; top_offset.push_back(top_size); for (int b = 0; b < batch; ++b) { @@ -178,9 +178,9 @@ class VarConv2DCompute : public KernelLite { std::vector top_dims_vec{top_size}; top_dims_vec.push_back(1); top->Resize(top_dims_vec); - auto* top_data = top->mutable_data(); - const auto* w_data = w->data(); - const auto* col_data = col->data(); + auto* top_data = top->template mutable_data(); + const auto* w_data = w->template data(); + const auto* col_data = col->template data(); auto blas = lite::x86::math::GetBlas(context); for (int b = 0; b < batch; ++b) { diff --git a/lite/kernels/x86/var_conv_2d_compute_test.cc b/lite/kernels/x86/var_conv_2d_compute_test.cc index d6ae5a67bfc9deba1fb097fa5c0c0cf323b65e48..edef8cb2df75dfb45ad4964975365d4ddbbe9086 100644 --- a/lite/kernels/x86/var_conv_2d_compute_test.cc +++ b/lite/kernels/x86/var_conv_2d_compute_test.cc @@ -140,7 +140,7 @@ static void var_conv_2d_ref(const lite::Tensor* bottom, const auto& col_offset = col->lod()[0]; const auto& offset_x = in_col->lod()[0]; const auto& offset_y = in_row->lod()[0]; - std::vector top_offset; + std::vector top_offset; int top_size = 0; top_offset.push_back(top_size); for (int b = 0; b < batch; ++b) {