未验证 提交 854a7ab3 编写于 作者: S Shang Zhizhou 提交者: GitHub

add pten dependency to infrt (#39079)

* add pten dependency to infrt

* fix code style

* add pten::CPUContext

* revert .ignore
上级 06803c29
#TO DO:remove fluid
include_directories(${PADDLE_SOURCE_DIR}/paddle/fluid/platform)
if (NOT WITH_INFRT)
return()
endif()
......@@ -88,8 +91,8 @@ set(infrt_mlir_incs
)
message(STATUS "infrt srcs:\n${infrt_src}")
cc_library(infrt SHARED SRCS ${infrt_src} DEPS glog boost ${mlir_libs} paddle_framework_proto)
cc_library(infrt_static SRCS ${infrt_src} DEPS glog boost ${mlir_libs} paddle_framework_proto)
cc_library(infrt SHARED SRCS ${infrt_src} DEPS glog boost ${mlir_libs} paddle_framework_proto pten dense_tensor)
cc_library(infrt_static SRCS ${infrt_src} DEPS glog boost ${mlir_libs} paddle_framework_proto pten dense_tensor)
add_dependencies(infrt ${infrt_mlir_incs})
add_custom_target(test_infrt_exec DEPENDS ${INFRT_TEST_TARGETS})
......@@ -29,6 +29,9 @@
#include "paddle/infrt/tensor/tensor_map.h"
#include "paddle/infrt/tensor/tensor_shape.h"
#include "paddle/pten/backends/cpu/cpu_context.h"
#include "paddle/pten/core/dense_tensor.h"
namespace infrt {
namespace host_context {
......@@ -45,6 +48,8 @@ using ValueVariantType = Variant<int16_t,
tensor::DenseHostTensor,
MlirFunctionExecutable*,
tensor::TensorMap,
pten::CPUContext,
pten::DenseTensor,
std::vector<int16_t>,
std::vector<int32_t>,
std::vector<int64_t>,
......
......@@ -2,6 +2,7 @@ core_gather_headers()
gather_srcs(infrt_src SRCS
basic_kernels.cc
pten_kernels.cc
test_kernels.cc
tensor_shape_kernels.cc
tensor_kernels.cc
......
// Copyright (c) 2022 PaddlePaddle Authors. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#include <iostream>
#include <string>
#include "paddle/infrt/host_context/kernel_registry.h"
#include "paddle/infrt/host_context/kernel_utils.h"
#include "paddle/infrt/kernel/pten_kernels.h"
#include "paddle/pten/backends/cpu/cpu_context.h"
#include "paddle/pten/kernels/math_kernel.h"
using infrt::host_context::Attribute;
namespace infrt {
namespace kernel {
void RegisterPtenKernels(host_context::KernelRegistry* registry) {
registry->AddKernel("pd_cpu.add.float32",
INFRT_KERNEL(pten::AddKernel<float, pten::CPUContext>));
registry->AddKernel("pd_cpu.add.int32",
INFRT_KERNEL(pten::AddKernel<int, pten::CPUContext>));
}
} // namespace kernel
} // namespace infrt
// Copyright (c) 2022 PaddlePaddle Authors. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#pragma once
#include <string>
namespace infrt {
namespace host_context {
struct KernelRegistry;
} // namespace host_context
} // namespace infrt
namespace infrt {
namespace kernel {
/**
* Register all the pten kernels to registry.
*/
void RegisterPtenKernels(host_context::KernelRegistry* registry);
} // namespace kernel
} // namespace infrt
文件模式从 100644 更改为 100755
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册