diff --git a/compiler/circlechef/core/src/Op/Dequantize.cpp b/compiler/circlechef/core/src/Op/Dequantize.cpp new file mode 100644 index 00000000000..6fbb38a541d --- /dev/null +++ b/compiler/circlechef/core/src/Op/Dequantize.cpp @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2024 Samsung Electronics Co., Ltd. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "Dequantize.h" + +#include "Convert.h" + +flatbuffers::Offset DequantizeChef::value(flatbuffers::FlatBufferBuilder &fbb) const +{ + return flatbuffers::Offset(); +} + +std::unique_ptr DequantizeChefFactory::create(const circlechef::Operation *operation) const +{ + return std::unique_ptr{new DequantizeChef{operation}}; +} diff --git a/compiler/circlechef/core/src/Op/Dequantize.h b/compiler/circlechef/core/src/Op/Dequantize.h new file mode 100644 index 00000000000..7088cd66c01 --- /dev/null +++ b/compiler/circlechef/core/src/Op/Dequantize.h @@ -0,0 +1,49 @@ +/* + * Copyright (c) 2024 Samsung Electronics Co., Ltd. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef __OP_DEQUANTIZE_H__ +#define __OP_DEQUANTIZE_H__ + +#include "OpChef.h" + +class DequantizeChef final : public OpChef +{ +public: + explicit DequantizeChef(const circlechef::Operation *operation) : _operation{operation} + { + // DO NOTHING + } + +public: + circle::BuiltinOperator code(void) const override { return circle::BuiltinOperator_DEQUANTIZE; } + + circle::BuiltinOptions type(void) const override + { + return circle::BuiltinOptions_DequantizeOptions; + } + + flatbuffers::Offset value(flatbuffers::FlatBufferBuilder &fbb) const override; + +private: + const circlechef::Operation *_operation; +}; + +struct DequantizeChefFactory final : public OpChefFactory +{ + std::unique_ptr create(const circlechef::Operation *operation) const override; +}; + +#endif // __OP_DEQUANTIZE_H__ diff --git a/compiler/circlechef/core/src/Op/Quantize.cpp b/compiler/circlechef/core/src/Op/Quantize.cpp new file mode 100644 index 00000000000..89182030258 --- /dev/null +++ b/compiler/circlechef/core/src/Op/Quantize.cpp @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2024 Samsung Electronics Co., Ltd. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "Quantize.h" + +#include "Convert.h" + +flatbuffers::Offset QuantizeChef::value(flatbuffers::FlatBufferBuilder &fbb) const +{ + return flatbuffers::Offset(); +} + +std::unique_ptr QuantizeChefFactory::create(const circlechef::Operation *operation) const +{ + return std::unique_ptr{new QuantizeChef{operation}}; +} diff --git a/compiler/circlechef/core/src/Op/Quantize.h b/compiler/circlechef/core/src/Op/Quantize.h new file mode 100644 index 00000000000..c910023e1d6 --- /dev/null +++ b/compiler/circlechef/core/src/Op/Quantize.h @@ -0,0 +1,49 @@ +/* + * Copyright (c) 2024 Samsung Electronics Co., Ltd. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef __OP_QUANTIZE_H__ +#define __OP_QUANTIZE_H__ + +#include "OpChef.h" + +class QuantizeChef final : public OpChef +{ +public: + explicit QuantizeChef(const circlechef::Operation *operation) : _operation{operation} + { + // DO NOTHING + } + +public: + circle::BuiltinOperator code(void) const override { return circle::BuiltinOperator_QUANTIZE; } + + circle::BuiltinOptions type(void) const override + { + return circle::BuiltinOptions_QuantizeOptions; + } + + flatbuffers::Offset value(flatbuffers::FlatBufferBuilder &fbb) const override; + +private: + const circlechef::Operation *_operation; +}; + +struct QuantizeChefFactory final : public OpChefFactory +{ + std::unique_ptr create(const circlechef::Operation *operation) const override; +}; + +#endif // __OP_QUANTIZE_H__ diff --git a/compiler/circlechef/core/src/OpChef.def b/compiler/circlechef/core/src/OpChef.def index 9d782b3c3f7..4feb16a5f26 100644 --- a/compiler/circlechef/core/src/OpChef.def +++ b/compiler/circlechef/core/src/OpChef.def @@ -7,8 +7,10 @@ OP_CHEF(BatchMatMul, BatchMatMulChefFactory) OP_CHEF(BCQFullyConnected, BCQFullyConnectedChefFactory) OP_CHEF(BCQGather, BCQGatherChefFactory) +OP_CHEF(Dequantize, DequantizeChefFactory) OP_CHEF(FullyConnected, FullyConnectedChefFactory) OP_CHEF(GRU, GRUChefFactory) OP_CHEF(InstanceNorm, InstanceNormChefFactory) OP_CHEF(RmsNorm, RmsNormChefFactory) OP_CHEF(RoPE, RoPEChefFactory) +OP_CHEF(Quantize, QuantizeChefFactory) diff --git a/compiler/circlechef/core/src/OpChefs.h b/compiler/circlechef/core/src/OpChefs.h index 6ced8403ea0..a60f96d5642 100644 --- a/compiler/circlechef/core/src/OpChefs.h +++ b/compiler/circlechef/core/src/OpChefs.h @@ -20,10 +20,12 @@ #include "Op/BatchMatMul.h" #include "Op/BCQFullyConnected.h" #include "Op/BCQGather.h" +#include "Op/Dequantize.h" #include "Op/FullyConnected.h" #include "Op/GRU.h" #include "Op/InstanceNorm.h" #include "Op/RmsNorm.h" #include "Op/RoPE.h" +#include "Op/Quantize.h" #endif // __OP_CHEFS_H__