一些编译torch-mlir到日记
因为版本不匹配,torch-mlir版本老于mlir,报错
/torch-mlir-main/include/torch-mlir/Conversion/TorchToTosa/TosaLegalizeUtils.h:13: In file included from /usr/local/include/mlir/Dialect/Quant/IR/QuantTypes.h:13: /usr/local/include/mlir/IR/Builders.h:507:11: error: no matching member function for call to 'build' OpTy::build(*this, state, std::forward<Args>(args)...); ~~~~~~^~~~~ /usr/local/include/mlir/IR/ImplicitLocOpBuilder.h:67:23: note: in instantiation of function template specialization 'mlir::OpBuilder::create<mlir::tosa::RescaleOp, mlir::Type &, mlir::Value &, mlir::IntegerAttr &, mlir::IntegerAttr &, mlir::detail::DenseArrayAttrImpl<int32_t> &, mlir::detail::DenseArrayAttrImpl<int8_t> &, mlir::BoolAttr &, mlir::BoolAttr &, mlir::BoolAttr &>' requested here return OpBuilder::create<OpTy>(curLoc, std::forward<Args>(args)...);
于是直接跳过编译TOSA:
cmake -G Ninja .. -DCMAKE_BUILD_TYPE=Release -DMLIR_DIR=/usr/local/lib/cmake/mlir -DTORCH_MLIR_ENABLE_TOSA=OFF
然后遇到报错
/Users/haorancheng/Desktop/torch-mlir-main/lib/InitAll.cpp:75:20: error: no member named 'registerStablehloAggressiveSimplificationPass' in namespace 'mlir::stablehlo' mlir::stablehlo::registerStablehloAggressiveSimplificationPass(); ~~~~~~~~~~~~~~~~~^ 1 error generated.
于是comment out InitAll.cpp里的
//mlir::stablehlo::registerStablehloAggressiveSimplificationPass();
大部分问题都是ChatGPT可以解决的