Skip to content

Commit

Permalink
[infrt] add parse for infrt.dense_tensor_type. test=develop (#40592)
Browse files Browse the repository at this point in the history
  • Loading branch information
winter-wang authored Mar 16, 2022
1 parent 84e17a3 commit 517b1a7
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
12 changes: 11 additions & 1 deletion paddle/infrt/dialect/infrt/ir/infrt_dialect.cc
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,10 @@ mlir::Type InfrtDialect::parseType(::mlir::DialectAsmParser &parser) const {
return DenseTensorType::get(
parser.getContext(), *targetType, *precisionType, *layoutType);
}

if (keyword == "dense_tensor_map") {
return DenseTensorMapType::get(parser.getContext());
}
// Todo: parse other type
return mlir::Type();
}
Expand All @@ -156,14 +160,20 @@ void InfrtDialect::printType(::mlir::Type type,
}

// print DenseTensorType, for example: !infrt.dense_tensor<CPU, FP32, NCHW>
if (type.isa<infrt::DenseTensorType>()) {
if (type.isa<DenseTensorType>()) {
auto dense_tensor_type = type.cast<infrt::DenseTensorType>();
os << "dense_tensor<" << dense_tensor_type.getTarget() << ", "
<< dense_tensor_type.getPrecision() << ", "
<< dense_tensor_type.getLayout() << ">";
return;
}

// print DenseTensorType, for example: !infrt.dense_tensor<CPU, FP32, NCHW>
if (type.isa<DenseTensorMapType>()) {
os << "dense_tensor_map";
return;
}

llvm_unreachable("unknown infrt type.");
}

Expand Down
2 changes: 1 addition & 1 deletion paddle/infrt/dialect/phi/phi_ir_exec.cc
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
#include "paddle/infrt/common/global.h"
#include "paddle/infrt/dialect/infrt/pass/infrt_op_fuse_pass.h"
#include "paddle/infrt/dialect/mlir_loader.h"
#include "paddle/infrt/dialect/phi/pass/phi_op_cvt_pass.h"
#include "paddle/infrt/dialect/phi/pass/phi_op_convert_pass.h"

int main(int argc, char** argv) {
static llvm::cl::opt<std::string> input_file(
Expand Down

0 comments on commit 517b1a7

Please sign in to comment.