Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle
提交
b1d38dea
P
Paddle
项目概览
PaddlePaddle
/
Paddle
大约 1 年 前同步成功
通知
2298
Star
20931
Fork
5422
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1423
列表
看板
标记
里程碑
合并请求
543
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
Paddle
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1,423
Issue
1,423
列表
看板
标记
里程碑
合并请求
543
合并请求
543
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
未验证
提交
b1d38dea
编写于
3月 03, 2022
作者:
石
石晓伟
提交者:
GitHub
3月 03, 2022
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
mlir attr types for infrt place, test=develop (#40087)
* mlir attr types for infrt place, test=develop * fix a bug, test=develop
上级
0969a4eb
变更
13
显示空白变更内容
内联
并排
Showing
13 changed file
with
121 addition
and
143 deletion
+121
-143
paddle/infrt/dialect/infrt/common_type.cc
paddle/infrt/dialect/infrt/common_type.cc
+18
-15
paddle/infrt/dialect/infrt/common_type.h
paddle/infrt/dialect/infrt/common_type.h
+8
-3
paddle/infrt/dialect/infrt/infrt_dialect.cc
paddle/infrt/dialect/infrt/infrt_dialect.cc
+1
-0
paddle/infrt/dialect/infrt/infrt_ops_base.td
paddle/infrt/dialect/infrt/infrt_ops_base.td
+44
-2
paddle/infrt/dialect/phi/ir/infrt_phi_base.td
paddle/infrt/dialect/phi/ir/infrt_phi_base.td
+20
-18
paddle/infrt/dialect/phi/ir/infrt_phi_tensor.td
paddle/infrt/dialect/phi/ir/infrt_phi_tensor.td
+5
-5
paddle/infrt/dialect/phi/ir/phi_base.cc
paddle/infrt/dialect/phi/ir/phi_base.cc
+1
-39
paddle/infrt/dialect/phi/ir/phi_base.h
paddle/infrt/dialect/phi/ir/phi_base.h
+4
-3
paddle/infrt/host_context/kernel_frame.cc
paddle/infrt/host_context/kernel_frame.cc
+15
-22
paddle/infrt/kernel/phi/infershaped/phi_kernel_launcher.h
paddle/infrt/kernel/phi/infershaped/phi_kernel_launcher.h
+0
-20
paddle/infrt/kernel/phi/registry.cc
paddle/infrt/kernel/phi/registry.cc
+0
-11
paddle/infrt/tests/dialect/pten/dense_tensor.mlir
paddle/infrt/tests/dialect/pten/dense_tensor.mlir
+4
-4
tools/infrt/generate_phi_kernel_dialect.py
tools/infrt/generate_phi_kernel_dialect.py
+1
-1
未找到文件。
paddle/infrt/dialect/infrt/common_type.cc
浏览文件 @
b1d38dea
...
@@ -43,46 +43,49 @@ llvm::Optional<PrecisionType> GetPrecisionType(llvm::StringRef key) {
...
@@ -43,46 +43,49 @@ llvm::Optional<PrecisionType> GetPrecisionType(llvm::StringRef key) {
return
llvm
::
None
;
return
llvm
::
None
;
}
}
llvm
::
raw_ostream
&
operator
<<
(
llvm
::
raw_ostream
&
os
,
TargetType
type
)
{
llvm
::
StringRef
GetString
(
TargetType
type
)
{
llvm
::
StringRef
str
;
switch
(
type
)
{
switch
(
type
)
{
case
(
TargetType
::
CPU
):
case
(
TargetType
::
CPU
):
os
<<
"CPU"
;
str
=
"CPU"
;
break
;
break
;
case
(
TargetType
::
GPU
):
case
(
TargetType
::
GPU
):
os
<<
"GPU"
;
str
=
"GPU"
;
break
;
break
;
default:
default:
os
<<
"Unsupported"
;
str
=
"Unsupported"
;
}
}
return
os
;
return
str
;
}
}
llvm
::
raw_ostream
&
operator
<<
(
llvm
::
raw_ostream
&
os
,
LayoutType
type
)
{
llvm
::
StringRef
GetString
(
LayoutType
type
)
{
llvm
::
StringRef
str
;
switch
(
type
)
{
switch
(
type
)
{
case
(
LayoutType
::
NCHW
):
case
(
LayoutType
::
NCHW
):
os
<<
"NCHW"
;
str
=
"NCHW"
;
break
;
break
;
case
(
LayoutType
::
NHWC
):
case
(
LayoutType
::
NHWC
):
os
<<
"NHWC"
;
str
=
"NHWC"
;
break
;
break
;
default:
default:
os
<<
"Unsupported"
;
str
=
"Unsupported"
;
}
}
return
os
;
return
str
;
}
}
llvm
::
raw_ostream
&
operator
<<
(
llvm
::
raw_ostream
&
os
,
PrecisionType
type
)
{
llvm
::
StringRef
GetString
(
PrecisionType
type
)
{
llvm
::
StringRef
str
;
switch
(
type
)
{
switch
(
type
)
{
case
(
PrecisionType
::
FLOAT32
):
case
(
PrecisionType
::
FLOAT32
):
os
<<
"FP32"
;
str
=
"FP32"
;
break
;
break
;
case
(
PrecisionType
::
FLOAT16
):
case
(
PrecisionType
::
FLOAT16
):
os
<<
"FP16"
;
str
=
"FP16"
;
break
;
break
;
default:
default:
os
<<
"Unsupported"
;
str
=
"Unsupported"
;
}
}
return
os
;
return
str
;
}
}
}
// namespace infrt
}
// namespace infrt
paddle/infrt/dialect/infrt/common_type.h
浏览文件 @
b1d38dea
...
@@ -54,8 +54,13 @@ llvm::Optional<TargetType> GetTargetType(llvm::StringRef key);
...
@@ -54,8 +54,13 @@ llvm::Optional<TargetType> GetTargetType(llvm::StringRef key);
llvm
::
Optional
<
LayoutType
>
GetLayoutType
(
llvm
::
StringRef
key
);
llvm
::
Optional
<
LayoutType
>
GetLayoutType
(
llvm
::
StringRef
key
);
llvm
::
Optional
<
PrecisionType
>
GetPrecisionType
(
llvm
::
StringRef
key
);
llvm
::
Optional
<
PrecisionType
>
GetPrecisionType
(
llvm
::
StringRef
key
);
llvm
::
raw_ostream
&
operator
<<
(
llvm
::
raw_ostream
&
os
,
TargetType
type
);
llvm
::
StringRef
GetString
(
TargetType
type
);
llvm
::
raw_ostream
&
operator
<<
(
llvm
::
raw_ostream
&
os
,
LayoutType
type
);
llvm
::
StringRef
GetString
(
LayoutType
type
);
llvm
::
raw_ostream
&
operator
<<
(
llvm
::
raw_ostream
&
os
,
PrecisionType
type
);
llvm
::
StringRef
GetString
(
PrecisionType
type
);
template
<
typename
T
>
llvm
::
raw_ostream
&
operator
<<
(
llvm
::
raw_ostream
&
os
,
T
type
)
{
os
<<
GetString
(
type
);
return
os
;
}
}
// end namespace infrt
}
// end namespace infrt
paddle/infrt/dialect/infrt/infrt_dialect.cc
浏览文件 @
b1d38dea
...
@@ -14,6 +14,7 @@
...
@@ -14,6 +14,7 @@
#include "paddle/infrt/dialect/infrt/infrt_dialect.h"
#include "paddle/infrt/dialect/infrt/infrt_dialect.h"
#include <llvm/ADT/TypeSwitch.h>
#include <mlir/IR/Builders.h>
#include <mlir/IR/Builders.h>
#include <mlir/IR/BuiltinOps.h>
#include <mlir/IR/BuiltinOps.h>
#include <mlir/IR/DialectImplementation.h>
#include <mlir/IR/DialectImplementation.h>
...
...
paddle/infrt/dialect/infrt/infrt_ops_base.td
浏览文件 @
b1d38dea
...
@@ -10,16 +10,59 @@ def Infrt_Dialect : Dialect {
...
@@ -10,16 +10,59 @@ def Infrt_Dialect : Dialect {
let name = "infrt";
let name = "infrt";
let cppNamespace = "::infrt";
let cppNamespace = "::infrt";
let useDefaultAttributePrinterParser = 1;
}
}
// Type definitions
// Type definitions
// Base class for Infrt dialect types.
// Base class for Infrt dialect types.
class Infrt_Type<string name, list<Trait> traits = [],
class Infrt_Type<string name, list<Trait> traits = [],
string baseCppClass = "::mlir::Type">
string baseCppClass = "::mlir::Type">
: TypeDef<Infrt_Dialect, name, traits, baseCppClass> {
: TypeDef<Infrt_Dialect, name, traits, baseCppClass> {
}
}
class Infrt_EnumParam<string cppEnumType, string stringToSymbolFnName,
string symbolToStringFnName, string desc = ""> : TypeParameter<cppEnumType, desc> {
let parser = [{[&]() -> ::mlir::FailureOr<}] # cppEnumType # [{> {
::llvm::StringRef enumKeyword;
if (::mlir::failed($_parser.parseKeyword(&enumKeyword)))
return ::mlir::failure();
auto maybeEnum = }] # stringToSymbolFnName # [{(enumKeyword);
if (maybeEnum)
return *maybeEnum;
llvm_unreachable("}] # cppEnumType # [{ can not be found.");
return {};
}()}];
let printer = "$_printer << " # symbolToStringFnName # "($_self)";
}
def TargetParam : Infrt_EnumParam<"::infrt::TargetType", "GetTargetType", "GetString">;
def PrecisionParam : Infrt_EnumParam<"::infrt::PrecisionType", "GetPrecisionType", "GetString">;
def LayoutParam : Infrt_EnumParam<"::infrt::LayoutType", "GetLayoutType", "GetString">;
def TargetAttr : AttrDef<Infrt_Dialect, "Target"> {
let mnemonic = "target";
let parameters = (ins
TargetParam:$target
);
let assemblyFormat = "`<` $target `>`";
}
def PrecisionAttr : AttrDef<Infrt_Dialect, "Precision"> {
let mnemonic = "precision";
let parameters = (ins
PrecisionParam:$precision
);
let assemblyFormat = "`<` $precision `>`";
}
def LayoutAttr : AttrDef<Infrt_Dialect, "Layout"> {
let mnemonic = "layout";
let parameters = (ins
LayoutParam:$layout
);
let assemblyFormat = "`<` $layout `>`";
}
def LoDTensor : Infrt_Type<"LoDTensor"> {
def LoDTensor : Infrt_Type<"LoDTensor"> {
let summary = "infrt lod tensor";
let summary = "infrt lod tensor";
let description = [{lod_tensor<3x64x3x3xf32, 3>}];
let description = [{lod_tensor<3x64x3x3xf32, 3>}];
...
@@ -37,7 +80,6 @@ def DenseTensor : Infrt_Type<"DenseTensor"> {
...
@@ -37,7 +80,6 @@ def DenseTensor : Infrt_Type<"DenseTensor"> {
"::infrt::TargetType":$target,
"::infrt::TargetType":$target,
"::infrt::PrecisionType":$precision,
"::infrt::PrecisionType":$precision,
"::infrt::LayoutType":$layout
"::infrt::LayoutType":$layout
);
);
}
}
...
...
paddle/infrt/dialect/phi/ir/infrt_phi_base.td
浏览文件 @
b1d38dea
...
@@ -2,6 +2,7 @@
...
@@ -2,6 +2,7 @@
#define PHI_BASE
#define PHI_BASE
include "mlir/IR/OpBase.td"
include "mlir/IR/OpBase.td"
include "paddle/infrt/dialect/infrt_base.td"
def PHI_Dialect : Dialect {
def PHI_Dialect : Dialect {
let name = "phi";
let name = "phi";
...
@@ -11,27 +12,28 @@ def PHI_Dialect : Dialect {
...
@@ -11,27 +12,28 @@ def PHI_Dialect : Dialect {
}];
}];
let cppNamespace = "::infrt::phi";
let cppNamespace = "::infrt::phi";
}
let useDefaultTypePrinterParser = 1;
class AllocatorTypeOf<string place, list<Trait> traits=[]>:
TypeDef<PHI_Dialect, place # "Allocator", traits> {
let summary = !strconcat("!phi.allocator_", place, " type");
}
class ContextTypeOf<string place, list<Trait> traits=[]>:
TypeDef<PHI_Dialect, place # "Context", traits> {
let summary = !strconcat("!phi.context_", place, " type");
}
}
def PhiOpTrait : NativeOpTrait<"PhiOpTrait">;
def PhiOpTrait : NativeOpTrait<"PhiOpTrait">;
def CPU_Allocator : AllocatorTypeOf<"CPU">;
class PHI_Type<string type, list<Trait> traits = []>
def GPU_Allocator : AllocatorTypeOf<"GPU">;
: TypeDef<PHI_Dialect, type, !listconcat(traits, [PhiOpTrait, IsolatedFromAbove])> {}
def CPU_Context : ContextTypeOf<"CPU">;
def Allocator : PHI_Type<"Allocator"> {
def GPU_Context : ContextTypeOf<"GPU">;
let mnemonic = "allocator";
let parameters = (ins
def Allocator : AnyTypeOf<[CPU_Allocator, GPU_Allocator], "Allocator type">;
TargetParam:$target
def Context : AnyTypeOf<[CPU_Context, GPU_Context], "Context type">;
);
let assemblyFormat = "`<` $target `>`";
}
def Context : PHI_Type<"Context"> {
let mnemonic = "context";
let parameters = (ins
TargetParam:$target
);
let assemblyFormat = "`<` $target `>`";
}
#endif
#endif
paddle/infrt/dialect/phi/ir/infrt_phi_tensor.td
浏览文件 @
b1d38dea
...
@@ -23,7 +23,7 @@ class PDT_Op<string mnemonic, list<OpTrait> traits = []> : Op<PHI_DenseTensorDia
...
@@ -23,7 +23,7 @@ class PDT_Op<string mnemonic, list<OpTrait> traits = []> : Op<PHI_DenseTensorDia
class CreateDenseTensorOp<string place, string dtype, string layout>
class CreateDenseTensorOp<string place, string dtype, string layout>
: PDT_Op<"create_dense_tensor." # place # "." # dtype # "." # layout, [NoSideEffect]> {
: PDT_Op<"create_dense_tensor." # place # "." # dtype # "." # layout, [NoSideEffect]> {
let arguments = (ins
CPU_
Allocator:$allocator, I64ArrayAttr:$dims, I64ArrayAttr:$lod);
let arguments = (ins Allocator:$allocator, I64ArrayAttr:$dims, I64ArrayAttr:$lod);
let results = (outs DenseTensor:$output);
let results = (outs DenseTensor:$output);
}
}
...
@@ -47,13 +47,13 @@ class PrintDenseTensorOp:
...
@@ -47,13 +47,13 @@ class PrintDenseTensorOp:
class CreateCPUAllocatorOp
class CreateCPUAllocatorOp
: PDT_Op<"create_allocator." # "cpu", [NoSideEffect]> {
: PDT_Op<"create_allocator." # "cpu", [NoSideEffect]> {
let arguments = (ins);
let arguments = (ins);
let results = (outs
CPU_
Allocator:$output);
let results = (outs Allocator:$output);
}
}
class CreateCPUContextOp
class CreateCPUContextOp
: PDT_Op<"create_context." # "cpu", [NoSideEffect]> {
: PDT_Op<"create_context." # "cpu", [NoSideEffect]> {
let arguments = (ins
CPU_
Allocator:$input);
let arguments = (ins Allocator:$input);
let results = (outs C
PU_C
ontext:$output);
let results = (outs Context:$output);
}
}
def PDT_CreateDenseTensorOp_cpu_f32_nchw : CreateDenseTensorOp<"cpu", "f32", "nchw">;
def PDT_CreateDenseTensorOp_cpu_f32_nchw : CreateDenseTensorOp<"cpu", "f32", "nchw">;
...
@@ -63,7 +63,7 @@ def PDT_CreateContextOp_cpu : CreateCPUContextOp;
...
@@ -63,7 +63,7 @@ def PDT_CreateContextOp_cpu : CreateCPUContextOp;
def PDT_PrintDenseTensor_cpu : PrintDenseTensorOp;
def PDT_PrintDenseTensor_cpu : PrintDenseTensorOp;
def FakeKernelOp : PDT_Op<"fake_phi_kernel"> {
def FakeKernelOp : PDT_Op<"fake_phi_kernel"> {
let arguments = (ins C
PU_C
ontext:$dev_ctx, DenseTensor:$x, DenseTensor:$y, BoolAttr:$transpose_x, BoolAttr:$transpose_y);
let arguments = (ins Context:$dev_ctx, DenseTensor:$x, DenseTensor:$y, BoolAttr:$transpose_x, BoolAttr:$transpose_y);
let results = (outs DenseTensor:$output);
let results = (outs DenseTensor:$output);
}
}
...
...
paddle/infrt/dialect/phi/ir/phi_base.cc
浏览文件 @
b1d38dea
...
@@ -14,6 +14,7 @@
...
@@ -14,6 +14,7 @@
#include "paddle/infrt/dialect/phi/ir/phi_base.h"
#include "paddle/infrt/dialect/phi/ir/phi_base.h"
#include <llvm/include/llvm/ADT/TypeSwitch.h>
#include <mlir/IR/Builders.h>
#include <mlir/IR/Builders.h>
#include <mlir/IR/Dialect.h>
#include <mlir/IR/Dialect.h>
#include <mlir/IR/DialectImplementation.h>
#include <mlir/IR/DialectImplementation.h>
...
@@ -27,27 +28,6 @@
...
@@ -27,27 +28,6 @@
namespace
infrt
{
namespace
infrt
{
namespace
phi
{
namespace
phi
{
void
PHIDialect
::
printType
(
::
mlir
::
Type
type
,
mlir
::
DialectAsmPrinter
&
os
)
const
{
if
(
type
.
isa
<
CPUAllocatorType
>
())
{
os
<<
"CPU_Allocator"
;
return
;
}
if
(
type
.
isa
<
GPUAllocatorType
>
())
{
os
<<
"GPU_Allocator"
;
return
;
}
if
(
type
.
isa
<
CPUContextType
>
())
{
os
<<
"CPU_Context"
;
return
;
}
if
(
type
.
isa
<
GPUContextType
>
())
{
os
<<
"GPU_Context"
;
return
;
}
llvm_unreachable
(
"unexpected 'allocator/context' type kind"
);
}
void
PHIDialect
::
initialize
()
{
void
PHIDialect
::
initialize
()
{
addOperations
<
addOperations
<
#define GET_OP_LIST
#define GET_OP_LIST
...
@@ -59,24 +39,6 @@ void PHIDialect::initialize() {
...
@@ -59,24 +39,6 @@ void PHIDialect::initialize() {
>
();
>
();
}
}
mlir
::
Type
PHIDialect
::
parseType
(
mlir
::
DialectAsmParser
&
parser
)
const
{
llvm
::
StringRef
keyword
;
if
(
parser
.
parseKeyword
(
&
keyword
))
return
mlir
::
Type
();
if
(
keyword
==
"CPU_allocator"
)
{
return
CPUAllocatorType
::
get
(
parser
.
getContext
());
}
else
if
(
keyword
==
"GPU_allocator"
)
{
return
GPUAllocatorType
::
get
(
parser
.
getContext
());
}
else
if
(
keyword
==
"CPU_context"
)
{
return
CPUContextType
::
get
(
parser
.
getContext
());
}
else
if
(
keyword
==
"GPU_context"
)
{
return
GPUContextType
::
get
(
parser
.
getContext
());
}
else
{
llvm_unreachable
(
"unexpected 'allocator/context' type kind"
);
}
return
mlir
::
Type
();
}
}
// namespace phi
}
// namespace phi
}
// namespace infrt
}
// namespace infrt
...
...
paddle/infrt/dialect/phi/ir/phi_base.h
浏览文件 @
b1d38dea
...
@@ -18,12 +18,10 @@
...
@@ -18,12 +18,10 @@
#include <mlir/Interfaces/SideEffectInterfaces.h>
#include <mlir/Interfaces/SideEffectInterfaces.h>
#include <string>
#include <string>
#include "paddle/infrt/dialect/infrt/common_type.h"
#include "paddle/infrt/dialect/phi/ir/infrt_phi_baseDialect.h.inc"
#include "paddle/infrt/dialect/phi/ir/infrt_phi_baseDialect.h.inc"
#define GET_TYPEDEF_CLASSES
#include "paddle/infrt/dialect/phi/ir/infrt_phi_baseTypes.h.inc"
#define GET_OP_CLASSES
#define GET_OP_CLASSES
#include "paddle/infrt/dialect/phi/ir/infrt_phi_base.h.inc"
#include "paddle/infrt/dialect/phi/ir/infrt_phi_base.h.inc"
...
@@ -41,6 +39,9 @@ class PhiOpTrait : public OpTrait::TraitBase<ConcreteType, PhiOpTrait> {
...
@@ -41,6 +39,9 @@ class PhiOpTrait : public OpTrait::TraitBase<ConcreteType, PhiOpTrait> {
}
// namespace OpTrait
}
// namespace OpTrait
}
// namespace mlir
}
// namespace mlir
#define GET_TYPEDEF_CLASSES
#include "paddle/infrt/dialect/phi/ir/infrt_phi_baseTypes.h.inc"
namespace
infrt
{
namespace
infrt
{
namespace
phi
{}
// namespace phi
namespace
phi
{}
// namespace phi
}
// namespace infrt
}
// namespace infrt
paddle/infrt/host_context/kernel_frame.cc
浏览文件 @
b1d38dea
...
@@ -30,28 +30,21 @@ std::ostream& operator<<(std::ostream& os, const KernelFrame& frame) {
...
@@ -30,28 +30,21 @@ std::ostream& operator<<(std::ostream& os, const KernelFrame& frame) {
std
::
string
KernelFrame
::
DumpArgTypes
()
const
{
std
::
string
KernelFrame
::
DumpArgTypes
()
const
{
std
::
stringstream
ss
;
std
::
stringstream
ss
;
for
(
auto
*
value
:
GetValues
(
0
,
GetNumElements
()))
{
for
(
auto
*
value
:
GetValues
(
0
,
GetNumElements
()))
{
if
(
value
->
is_type
<
bool
>
())
{
#define DUMP(type_name) \
ss
<<
"bool ("
<<
&
value
->
get
<
bool
>
()
<<
"), "
;
if (value->is_type<type_name>()) { \
}
else
if
(
value
->
is_type
<
tensor
::
DenseHostTensor
>
())
{
ss << #type_name << &value->get<type_name>() << "), "; \
ss
<<
"DenseHostTensor("
<<
&
value
->
get
<
tensor
::
DenseHostTensor
>
()
<<
"), "
;
}
else
if
(
value
->
is_type
<
float
>
())
{
ss
<<
"float("
<<
&
value
->
get
<
float
>
()
<<
"), "
;
}
else
if
(
value
->
is_type
<
int
>
())
{
ss
<<
"int("
<<
&
value
->
get
<
int
>
()
<<
"), "
;
}
else
if
(
value
->
is_type
<
phi
::
DenseTensor
>
())
{
ss
<<
"phi::DenseTensor("
<<
&
value
->
get
<
phi
::
DenseTensor
>
()
<<
"), "
;
}
else
if
(
value
->
is_type
<
phi
::
MetaTensor
>
())
{
ss
<<
"phi::MetaTensor("
<<
&
value
->
get
<
phi
::
MetaTensor
>
()
<<
"), "
;
}
else
if
(
value
->
is_type
<::
phi
::
CPUContext
>
())
{
ss
<<
"phi::CPUContext("
<<
&
value
->
get
<::
phi
::
CPUContext
>
()
<<
"), "
;
}
else
if
(
value
->
is_type
<
host_context
::
None
>
())
{
ss
<<
"none("
<<
&
value
->
get
<
host_context
::
None
>
()
<<
"), "
;
}
else
if
(
value
->
is_type
<
backends
::
CpuPhiContext
>
())
{
ss
<<
"CpuPhiContext("
<<
&
value
->
get
<
backends
::
CpuPhiContext
>
()
<<
"), "
;
}
else
{
ss
<<
"typeid: "
<<
value
->
index
()
<<
", "
;
}
}
DUMP
(
bool
);
DUMP
(
tensor
::
DenseHostTensor
);
DUMP
(
float
);
DUMP
(
int
);
DUMP
(
::
phi
::
DenseTensor
);
DUMP
(
::
phi
::
MetaTensor
);
DUMP
(
::
phi
::
CPUContext
);
DUMP
(
host_context
::
None
);
DUMP
(
backends
::
CpuPhiContext
);
#undef DUMP
ss
<<
"typeid: "
<<
value
->
index
()
<<
", "
;
}
}
return
ss
.
str
();
return
ss
.
str
();
}
}
...
...
paddle/infrt/kernel/phi/infershaped/phi_kernel_launcher.h
浏览文件 @
b1d38dea
...
@@ -24,26 +24,6 @@
...
@@ -24,26 +24,6 @@
namespace
infrt
{
namespace
infrt
{
namespace
kernel
{
namespace
kernel
{
static
void
FakePhiInferShape
(
const
::
phi
::
MetaTensor
&
a
,
const
::
phi
::
MetaTensor
&
b
,
bool
arg_0
,
bool
arg_1
,
::
phi
::
MetaTensor
*
c
)
{
LOG
(
INFO
)
<<
"the ptr of c: "
<<
c
;
LOG
(
INFO
)
<<
"c->numel(): "
<<
c
->
numel
();
}
static
void
FakePhiKernel
(
const
::
phi
::
CPUContext
&
/*Context*/
,
const
::
phi
::
DenseTensor
&
a
,
const
::
phi
::
DenseTensor
&
b
,
bool
arg_0
,
bool
arg_1
,
::
phi
::
DenseTensor
*
c
)
{
std
::
cout
<<
"@FakePhiKernel@"
<<
std
::
endl
;
LOG
(
INFO
)
<<
"the ptr of c: "
<<
c
;
LOG
(
INFO
)
<<
"c->numel(): "
<<
c
->
numel
();
}
template
<
typename
KernelFunc
,
template
<
typename
KernelFunc
,
KernelFunc
kernel
,
KernelFunc
kernel
,
typename
InferShapedFunc
,
typename
InferShapedFunc
,
...
...
paddle/infrt/kernel/phi/registry.cc
浏览文件 @
b1d38dea
...
@@ -44,17 +44,6 @@ void RegisterPhiKernels(host_context::KernelRegistry* registry) {
...
@@ -44,17 +44,6 @@ void RegisterPhiKernels(host_context::KernelRegistry* registry) {
INFRT_KERNEL
(
infrt
::
kernel
::
phi
::
FillDenseTensorF32
));
INFRT_KERNEL
(
infrt
::
kernel
::
phi
::
FillDenseTensorF32
));
registry
->
AddKernel
(
"phi_dt.print_tensor"
,
registry
->
AddKernel
(
"phi_dt.print_tensor"
,
INFRT_KERNEL
(
infrt
::
kernel
::
phi
::
PrintDenseTensor
));
INFRT_KERNEL
(
infrt
::
kernel
::
phi
::
PrintDenseTensor
));
registry
->
AddKernel
(
"phi_dt.fake_phi_kernel"
,
std
::
bind
(
&
KernelLauncherFunc
<
decltype
(
&
FakePhiKernel
),
&
FakePhiKernel
,
decltype
(
&
FakePhiInferShape
),
&
FakePhiInferShape
>
,
KernelLauncher
<
decltype
(
&
FakePhiKernel
),
&
FakePhiKernel
,
decltype
(
&
FakePhiInferShape
),
&
FakePhiInferShape
>
(),
std
::
placeholders
::
_1
));
}
}
}
// namespace kernel
}
// namespace kernel
...
...
paddle/infrt/tests/dialect/pten/dense_tensor.mlir
浏览文件 @
b1d38dea
...
@@ -2,11 +2,11 @@
...
@@ -2,11 +2,11 @@
// CHECK-LABEL: @sign_any_float32_execute
// CHECK-LABEL: @sign_any_float32_execute
func @sign_any_float32_execute() {
func @sign_any_float32_execute() {
%allocator = "phi_dt.create_allocator.cpu" (): () -> !phi.
CPU_allocator
%allocator = "phi_dt.create_allocator.cpu" (): () -> !phi.
allocator<CPU>
%ctx = "phi_dt.create_context.cpu" (%allocator): (!phi.
CPU_allocator) -> !phi.CPU_context
%ctx = "phi_dt.create_context.cpu" (%allocator): (!phi.
allocator<CPU>) -> !phi.context<CPU>
%t = "phi_dt.create_dense_tensor.cpu.f32.nchw" (%allocator) {dims=[1:i64], lod=[1:i64]}: (!phi.
CPU_allocator
) -> (!infrt.dense_tensor<CPU, FP32, NCHW>)
%t = "phi_dt.create_dense_tensor.cpu.f32.nchw" (%allocator) {dims=[1:i64], lod=[1:i64]}: (!phi.
allocator<CPU>
) -> (!infrt.dense_tensor<CPU, FP32, NCHW>)
"phi_dt.fill_dense_tensor.f32"(%t) {value=[3.8:f32]} : (!infrt.dense_tensor<CPU, FP32, NCHW>) -> ()
"phi_dt.fill_dense_tensor.f32"(%t) {value=[3.8:f32]} : (!infrt.dense_tensor<CPU, FP32, NCHW>) -> ()
%e = "phi_cpu.sign.any.float32"(%ctx, %t) : (!phi.
CPU_context
, !infrt.dense_tensor<CPU, FP32, NCHW>) -> (!infrt.dense_tensor<CPU, FP32, NCHW>)
%e = "phi_cpu.sign.any.float32"(%ctx, %t) : (!phi.
context<CPU>
, !infrt.dense_tensor<CPU, FP32, NCHW>) -> (!infrt.dense_tensor<CPU, FP32, NCHW>)
// CHECK: dense_tensor: shape=shape[1], values=[1]
// CHECK: dense_tensor: shape=shape[1], values=[1]
"phi_dt.print_tensor" (%e) : (!infrt.dense_tensor<CPU, FP32, NCHW>) -> ()
"phi_dt.print_tensor" (%e) : (!infrt.dense_tensor<CPU, FP32, NCHW>) -> ()
...
...
tools/infrt/generate_phi_kernel_dialect.py
浏览文件 @
b1d38dea
...
@@ -95,7 +95,7 @@ def generate_inputs_info(input_info):
...
@@ -95,7 +95,7 @@ def generate_inputs_info(input_info):
def
generate_arguments_info
(
op_name
,
input_info
,
attr_info
):
def
generate_arguments_info
(
op_name
,
input_info
,
attr_info
):
input_args
=
generate_inputs_info
(
input_info
)
input_args
=
generate_inputs_info
(
input_info
)
attr_args
=
generate_attrs_info
(
op_name
,
attr_info
)
attr_args
=
generate_attrs_info
(
op_name
,
attr_info
)
context_args
=
"C
PU_C
ontext:$dev_ctx"
context_args
=
"Context:$dev_ctx"
argument_
=
"{},{},{}"
.
format
(
context_args
,
input_args
,
attr_args
)
argument_
=
"{},{},{}"
.
format
(
context_args
,
input_args
,
attr_args
)
return
((
"let arguments = (ins {});"
.
format
(
argument_
.
strip
(
","
))))
return
((
"let arguments = (ins {});"
.
format
(
argument_
.
strip
(
","
))))
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录