fix code format (#348)
This commit is contained in:
parent
e1f6ae1336
commit
cc39a92802
|
@ -6,10 +6,10 @@
|
|||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#include <regex>
|
||||
#include <tuple>
|
||||
#include <numeric>
|
||||
#include <regex>
|
||||
#include <string>
|
||||
#include <tuple>
|
||||
|
||||
#include "mlir/Analysis/Verifier.h"
|
||||
#include "mlir/Dialect/StandardOps/Ops.h"
|
||||
|
@ -73,7 +73,6 @@ struct OnnxOnnfSymbolMapping {
|
|||
onnx_name2onnf_tensor.emplace(legalize_name(name), tensor);
|
||||
}
|
||||
|
||||
|
||||
bool ContainKey(std::string name) {
|
||||
return onnx_name2onnf_tensor.count(name) != 0;
|
||||
}
|
||||
|
@ -104,9 +103,7 @@ private:
|
|||
// mapping between string name and symbol
|
||||
OnnxOnnfSymbolMapping sgir_symbols_;
|
||||
|
||||
mlir::Location UnknownLoc() {
|
||||
return mlir::UnknownLoc::get(&context_);
|
||||
}
|
||||
mlir::Location UnknownLoc() { return mlir::UnknownLoc::get(&context_); }
|
||||
|
||||
mlir::Type TypeConvert(onnx::TensorProto_DataType intype) {
|
||||
return builder_.getF32Type();
|
||||
|
@ -131,10 +128,12 @@ private:
|
|||
}
|
||||
}
|
||||
if (!sgir_symbols_.ContainKey(input_tensor_legalized_name)) {
|
||||
mlir::Type elementType = TypeConvert(input.type().tensor_type().elem_type());
|
||||
mlir::Type elementType =
|
||||
TypeConvert(input.type().tensor_type().elem_type());
|
||||
llvm::ArrayRef<int64_t> llvmdimsAR(dims.data(), dims.size());
|
||||
auto dataType = builder_.getTensorType(llvmdimsAR, elementType);
|
||||
mlir::OperationState result(UnknownLoc(), "sgir.input "+input_tensor_legalized_name);
|
||||
mlir::OperationState result(
|
||||
UnknownLoc(), "sgir.input " + input_tensor_legalized_name);
|
||||
result.addTypes(dataType);
|
||||
auto op = builder_.createOperation(result);
|
||||
auto value = op->getResult(0);
|
||||
|
@ -176,7 +175,6 @@ private:
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
void ImportGraph(onnx::GraphProto graph) {
|
||||
// create a function for the graph
|
||||
// TODO:
|
||||
|
@ -185,8 +183,8 @@ private:
|
|||
llvm::SmallVector<mlir::Type, 4> ret_types;
|
||||
llvm::SmallVector<mlir::Type, 4> arg_types;
|
||||
auto func_type = builder_.getFunctionType(arg_types, ret_types);
|
||||
auto llvmfunction = mlir::FuncOp::create(UnknownLoc(),
|
||||
graph.name(), func_type, /* attrs = */ {});
|
||||
auto llvmfunction = mlir::FuncOp::create(
|
||||
UnknownLoc(), graph.name(), func_type, /* attrs = */ {});
|
||||
auto& entryBlock = *llvmfunction.addEntryBlock();
|
||||
builder_.setInsertionPointToStart(&entryBlock);
|
||||
module_.push_back(llvmfunction);
|
||||
|
@ -214,10 +212,9 @@ private:
|
|||
}; // SGIRGenImpl class
|
||||
|
||||
} // namespace
|
||||
} //namespace onnf
|
||||
} // namespace dlc
|
||||
|
||||
namespace onnf {
|
||||
|
||||
/*!
|
||||
* Generate SGIR with MLIR for a onnx model
|
||||
* @param model onnx model.
|
||||
|
@ -233,4 +230,3 @@ mlir::OwningModuleRef SGIRImportModel(onnx::ModelProto model) {
|
|||
}
|
||||
|
||||
} // namespace onnf
|
||||
|
||||
|
|
|
@ -32,4 +32,3 @@ namespace onnf {
|
|||
mlir::OwningModuleRef SGIRImportModel(onnx::ModelProto model);
|
||||
|
||||
} // namespace onnf
|
||||
|
||||
|
|
Loading…
Reference in New Issue