Skip to content

Commit 9fb82ea

Browse files
committed
DRAFT circle-mlir version up externals
on-going draft to version up externals and fix changes. Signed-off-by: SaeHie Park <saehie.park@gmail.com>
1 parent 97d6d49 commit 9fb82ea

File tree

18 files changed

+215
-123
lines changed

18 files changed

+215
-123
lines changed

circle-mlir/circle-mlir/lib/dialect/include/circle-mlir/dialect/CircleDialect.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
#ifndef __CIRCLE_MLIR_DIALECT_CIRCLE_DIALECT_H__
2121
#define __CIRCLE_MLIR_DIALECT_CIRCLE_DIALECT_H__
2222

23+
#include <mlir/Bytecode/BytecodeOpInterface.h> // from @llvm-project
2324
#include <mlir/Dialect/Traits.h> // from @llvm-project
2425
#include <mlir/IR/Dialect.h> // from @llvm-project
2526
#include <mlir/IR/DialectImplementation.h> // from @llvm-project
@@ -46,6 +47,7 @@ class ControlType : public Type::TypeBase<ControlType, Type, TypeStorage>
4647
{
4748
public:
4849
using Base::Base;
50+
static constexpr StringLiteral name = "cir.control";
4951
};
5052

5153
#include "mlir/CircleOpInterface.h.inc"

circle-mlir/circle-mlir/lib/dialect/mlir/CircleOps.td

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
#ifndef CIRCLE_OPS
2121
#define CIRCLE_OPS
2222

23-
include "mlir/IR/FunctionInterfaces.td"
23+
// include "mlir/IR/FunctionInterfaces.td"
2424
include "mlir/IR/OpBase.td"
2525
include "mlir/Interfaces/InferTypeOpInterface.td"
2626
include "mlir/Interfaces/SideEffectInterfaces.td"
@@ -81,6 +81,7 @@ class CIR_VariadicTensorOf<list<Type> allowedRuntimeTypes,
8181
Variadic<TensorOf<allowedOpTypes>>,
8282
CIR_RuntimeType<Variadic<TensorOf<allowedRuntimeTypes>>>;
8383

84+
def CIR_I4 : I<4>;
8485
def CIR_Int32Or64 : SignlessIntOfWidths<[32, 64]>;
8586

8687
def CIR_BoolTensor : CIR_TensorOf<[I1]>;
@@ -260,6 +261,8 @@ class CIR_Op<string mnemonic, list<Trait> traits = []> :
260261

261262
// Whether the Circle operator has options in the schema representation.
262263
bit hasOptions = 0b0;
264+
// Whether the Circle operator has options2 in the schema representation.
265+
bit hasOptions2 = 0b0;
263266

264267
// Use to specify a custom options type for Circle operators where
265268
// the option's name does not match the Cirlce operator's name.

circle-mlir/circle-mlir/lib/dialect/src/NameUtils.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ std::string GetNameFromLoc(Location loc)
4646
// in functions where the op's name is first.
4747
auto name = name_loc.getName().strref().split('@').first;
4848
// Skip if the name is for op type.
49-
if (!name.endswith(":"))
49+
if (!name.ends_with(":"))
5050
{
5151
loc_names.push_back(name);
5252
if (!name.empty())

circle-mlir/circle-mlir/lib/dialect/src/ops/Conv2DOp.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,10 +54,11 @@ LogicalResult ComputeConvWindowedOutputSize(int64_t input_size, int64_t filter_s
5454
}
5555

5656
LogicalResult Conv2DOp::inferReturnTypes(MLIRContext *, std::optional<Location> location,
57-
ValueRange operands, DictionaryAttr attr, OpaqueProperties,
58-
RegionRange, SmallVectorImpl<Type> &inferredReturnTypes)
57+
ValueRange operands, DictionaryAttr attr,
58+
OpaqueProperties properties, RegionRange,
59+
SmallVectorImpl<Type> &inferredReturnTypes)
5960
{
60-
Conv2DOpAdaptor op(operands, attr);
61+
Conv2DOpAdaptor op(operands, attr, properties);
6162

6263
const Value input = op.getInput();
6364
const Value filter = op.getFilter();

circle-mlir/circle-mlir/lib/dialect/src/ops/ReshapeOp.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -370,10 +370,10 @@ mlir::LogicalResult ReshapeOp::verify()
370370

371371
LogicalResult ReshapeOp::inferReturnTypes(MLIRContext *context, std::optional<Location> location,
372372
ValueRange operands, DictionaryAttr attr,
373-
OpaqueProperties, RegionRange,
373+
OpaqueProperties properties, RegionRange,
374374
SmallVectorImpl<Type> &inferredReturnTypes)
375375
{
376-
ReshapeOpAdaptor op(operands, attr);
376+
ReshapeOpAdaptor op(operands, attr, properties);
377377
const Value input = op.getInput();
378378
const Value shape = op.getShape();
379379

circle-mlir/circle-mlir/lib/import/src/CircleImport.cpp

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,7 @@ inline constexpr unsigned int flatbuffer_size_max = 2147483648;
3939
#include <llvm/Support/FormatVariadic.h>
4040
#include <mlir/IR/Matchers.h> // m_Constant
4141
#include <mlir/Dialect/Func/IR/FuncOps.h>
42-
#include <mlir/Dialect/Quant/QuantOps.h>
43-
#include <mlir/Dialect/Quant/QuantTypes.h>
42+
#include <mlir/Dialect/Quant/IR/QuantTypes.h>
4443

4544
#include <circle_schema/schema_generated.h>
4645

@@ -226,8 +225,8 @@ template <typename T> llvm::SmallVector<mlir::APInt> ReadAsHostEndian(llvm::Arra
226225
const char *data_ptr = reinterpret_cast<const char *>(bytes.data());
227226
for (size_t i = 0; i < elem_count; i++)
228227
{
229-
T val = llvm::support::endian::readNext<T, llvm::support::endianness::native,
230-
llvm::support::unaligned>(data_ptr);
228+
T val = llvm::support::endian::readNext<T, llvm::endianness::native, llvm::support::unaligned>(
229+
data_ptr);
231230
ret.push_back(mlir::APInt(sizeof(T) * 8, val));
232231
}
233232
return ret;
@@ -254,9 +253,8 @@ std::optional<mlir::ElementsAttr> ConvertFloatBuffer(mlir::RankedTensorType shap
254253

255254
for (int i = 0; i < elem_count; i++)
256255
{
257-
uint32_t bit_repr =
258-
llvm::support::endian::readNext<uint32_t, llvm::support::endianness::native,
259-
llvm::support::unaligned>(data);
256+
uint32_t bit_repr = llvm::support::endian::readNext<uint32_t, llvm::endianness::native,
257+
llvm::support::unaligned>(data);
260258
values.push_back(absl::bit_cast<float>(bit_repr));
261259
}
262260
auto num = shaped_type.getNumElements();

circle-mlir/circle-mlir/lib/pass/src/RewriteCirclePass.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ void RewriteCirclePass::applyActivationFusion()
112112

113113
// TODO add more patterns
114114

115-
(void)applyPatternsAndFoldGreedily(func, std::move(patterns));
115+
(void)applyPatternsGreedily(func, std::move(patterns));
116116
}
117117

118118
std::unique_ptr<mlir::Pass> createRewriteCirclePass(void)

circle-mlir/circle-mlir/lib/pass/src/opt/ConvertMirrorPadPad32.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ struct ConvertMirrorPadPad32 : public OpRewritePattern<MirrorPadOp>
5757
auto intattr = DenseIntElementsAttr::get(si32stype, values);
5858
mlir::Value shape32 = rewriter.create<ConstOp>(opLoc, intattr);
5959

60-
auto pad_mutable = mirrorpad_op.getPadMutable();
60+
auto &pad_mutable = mirrorpad_op.getPadMutable();
6161
pad_mutable.assign(shape32);
6262

6363
return mlir::success();

circle-mlir/circle-mlir/lib/pass/src/opt/ConvertReshapeShape32.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ struct ConvertReshapeShape32 : public OpRewritePattern<ReshapeOp>
5959
mlir::Value shape32 =
6060
rewriter.create<ConstOp>(opLoc, DenseIntElementsAttr::get(si32stype, values));
6161

62-
auto shape_mutable = reshape_op.getShapeMutable();
62+
auto &shape_mutable = reshape_op.getShapeMutable();
6363
shape_mutable.assign(shape32);
6464

6565
return mlir::success();

circle-mlir/circle-mlir/lib/pass/src/opt/ConvertResizeNearestSize32.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ struct ConvertResizeNearestSize32 : public OpRewritePattern<ResizeNearestNeighbo
7474
mlir::Value size32 =
7575
rewriter.create<ConstOp>(opLoc, DenseIntElementsAttr::get(si32stype, values));
7676

77-
auto resize_mutable = resize_op.getSizeMutable();
77+
auto &resize_mutable = resize_op.getSizeMutable();
7878
resize_mutable.assign(size32);
7979

8080
return mlir::success();

0 commit comments

Comments
 (0)