This commit is contained in:
@@ -0,0 +1,23 @@
|
||||
#include "AttributeUtils.hpp"
|
||||
|
||||
#include "mlir/IR/BuiltinAttributes.h"
|
||||
|
||||
using namespace mlir;
|
||||
|
||||
namespace onnx_mlir {
|
||||
|
||||
int64_t getI64Attr(ArrayAttr attr, size_t index) { return cast<IntegerAttr>(attr[index]).getInt(); }
|
||||
|
||||
int64_t getOptionalI64Attr(std::optional<ArrayAttr> attr, size_t index, int64_t defaultValue) {
|
||||
return attr ? getI64Attr(*attr, index) : defaultValue;
|
||||
}
|
||||
|
||||
llvm::SmallVector<int64_t> getI64ArrayAttrValues(ArrayAttr attr) {
|
||||
llvm::SmallVector<int64_t> values;
|
||||
values.reserve(attr.size());
|
||||
for (Attribute value : attr)
|
||||
values.push_back(cast<IntegerAttr>(value).getInt());
|
||||
return values;
|
||||
}
|
||||
|
||||
} // namespace onnx_mlir
|
||||
Reference in New Issue
Block a user