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