Merged
refactor(ir): Remove class Any, used std::any instead #4037
lidongshengAdd on Jun 15
refactor(ir): Remove class Any, used std::any instead #4037
Merged
lidongshengAdd on Jun 15
Total: 34 files changed+189-817
@@ -51,7 +51,6 @@ operation_vector@pypto:
51 - framework/src/interface/operation/operation.h51 - framework/src/interface/operation/operation.h
52 - framework/src/interface/operation/tile_shape_verifier.h52 - framework/src/interface/operation/tile_shape_verifier.h
53 - framework/src/interface/operation/tile_shape.cpp53 - framework/src/interface/operation/tile_shape.cpp
54- - framework/src/interface/operation/verifier.h
55 - framework/src/interface/tileop/arch32/dynamic/mte_dyn.h54 - framework/src/interface/tileop/arch32/dynamic/mte_dyn.h
56 - framework/src/interface/tileop/arch32/dynamic/vector_bin_brc_dyn.h55 - framework/src/interface/tileop/arch32/dynamic/vector_bin_brc_dyn.h
57 - framework/src/interface/tileop/arch32/dynamic/vector_bin_dyn.h56 - framework/src/interface/tileop/arch32/dynamic/vector_bin_dyn.h
@@ -106,7 +105,7 @@ cost_model@pypto:
106 105 
107frontend@pypto:106frontend@pypto:
108 src:107 src:
109- release: 108+ release:
110 - framework/include/core/any_cast.h109 - framework/include/core/any_cast.h
111 - framework/include/core/common.h110 - framework/include/core/common.h
112 - framework/include/core/dtype.h111 - framework/include/core/dtype.h
@@ -163,7 +162,7 @@ frontend@pypto:
163 162 
164block@pypto:163block@pypto:
165 src:164 src:
166- release: 165+ release:
167 - framework/include/ir/166 - framework/include/ir/
168 - framework/include/block/167 - framework/include/block/
169 - framework/src/interface/ir/168 - framework/src/interface/ir/
@@ -193,7 +192,7 @@ codegen@pypto:
193machine@pypto:192machine@pypto:
194 src:193 src:
195 release:194 release:
196- - framework/include/tilefwk/error_code.h 195+ - framework/include/tilefwk/error_code.h
197 - framework/include/tilefwk/error_manager.h196 - framework/include/tilefwk/error_manager.h
198 - framework/include/tilefwk/error.h197 - framework/include/tilefwk/error.h
199 - framework/include/tilefwk/pypto_fwk_log.h198 - framework/include/tilefwk/pypto_fwk_log.h
@@ -144,4 +144,14 @@ const T& AnyCastRef(const std::any& value, [[maybe_unused]] const std::string& c
144 }144 }
145}145}
146 146 
147+template <typename T>
148+T& AnyCastRef(std::any& value, [[maybe_unused]] const std::string& context = "")
149+{
150+ try {
151+ return std::any_cast<T&>(value);
152+ } catch (const std::bad_any_cast&) {
153+ ThrowAnyCastError(typeid(T).name(), value.type().name(), context);
154+ }
155+}
156+ 
147} // namespace pypto157} // namespace pypto
@@ -25,14 +25,6 @@
25 25 
26namespace pypto {26namespace pypto {
27 27 
28-// ============================================================================
29-// Version Information
30-// ============================================================================
31- 
32-#define PYPTO_VERSION_MAJOR 0
33-#define PYPTO_VERSION_MINOR 1
34-#define PYPTO_VERSION_PATCH 0
35- 
36// ============================================================================28// ============================================================================
37// IR Constants29// IR Constants
38// ============================================================================30// ============================================================================
@@ -41,13 +33,6 @@ namespace pypto {
41// Use -1 to represent dimensions that are unknown at compile time33// Use -1 to represent dimensions that are unknown at compile time
42constexpr int64_t kDynamicDim = -1;34constexpr int64_t kDynamicDim = -1;
43 35 
44-// ============================================================================
45-// nanobind Module Configuration
46-// ============================================================================
47- 
48-// Default docstring for the nanobind module
49-#define PYPTO_NANOBIND_MODULE_DOC "PyPTO core library"
50- 
51// ============================================================================36// ============================================================================
52// Compiler Hints and Attributes37// Compiler Hints and Attributes
53// ============================================================================38// ============================================================================
@@ -603,12 +603,6 @@ Tensor Conv(
603 603 
604} // namespace Conv604} // namespace Conv
605 605 
606-namespace FakeTrans {
607- 
608-Tensor FakeTrans(const Tensor& input, const Tensor& output);
609- 
610-} // namespace FakeTrans
611- 
612namespace Distributed {606namespace Distributed {
613enum class DistReduceType {607enum class DistReduceType {
614 DIST_REDUCE_ADD,608 DIST_REDUCE_ADD,
@@ -366,11 +366,11 @@ std::string CodeGenOp::GenOpAttr(bool hasExistingParam) const
366 if (kv.first.substr(0, OP_ATTR_PREFIX.size()) != OP_ATTR_PREFIX) {366 if (kv.first.substr(0, OP_ATTR_PREFIX.size()) != OP_ATTR_PREFIX) {
367 continue;367 continue;
368 }368 }
369- if (kv.second.Type() == typeid(int64_t)) {369+ if (kv.second.type() == typeid(int64_t)) {
370 attrList.push_back(std::to_string(AnyCast<int64_t>(kv.second)));370 attrList.push_back(std::to_string(AnyCast<int64_t>(kv.second)));
371- } else if (kv.second.Type() == typeid(bool)) {371+ } else if (kv.second.type() == typeid(bool)) {
372 attrList.push_back(std::to_string(AnyCast<bool>(kv.second)));372 attrList.push_back(std::to_string(AnyCast<bool>(kv.second)));
373- } else if (kv.second.Type() == typeid(std::vector<int64_t>)) {373+ } else if (kv.second.type() == typeid(std::vector<int64_t>)) {
374 auto vec = AnyCast<std::vector<int64_t>>(kv.second);374 auto vec = AnyCast<std::vector<int64_t>>(kv.second);
375 for (auto v : vec) {375 for (auto v : vec) {
376 attrList.push_back(std::to_string(v));376 attrList.push_back(std::to_string(v));
@@ -119,8 +119,8 @@ protected:
119 std::vector<long> convParams;119 std::vector<long> convParams;
120 std::vector<int> poolParams;120 std::vector<int> poolParams;
121 121 
122- std::map<std::string, Any> opAttrs;122+ std::map<std::string, std::any> opAttrs;
123- std::map<std::string, Any> tensorAttrs[MAX_OPERANDS];123+ std::map<std::string, std::any> tensorAttrs[MAX_OPERANDS];
124 124 
125 std::shared_ptr<SymbolManager> sm{nullptr};125 std::shared_ptr<SymbolManager> sm{nullptr};
126 const std::map<int, int>& paramLocToParamListOffset{};126 const std::map<int, int>& paramLocToParamListOffset{};
@@ -30,7 +30,7 @@ std::string CodeGenOpNPU::PrintGatherInL1TileTensor() const
30 int64_t blockSize = AnyCast<int64_t>(opAttrs.at("op_attr_blocksize"));30 int64_t blockSize = AnyCast<int64_t>(opAttrs.at("op_attr_blocksize"));
31 31 
32 auto startOffset = opAttrs.at(OpAttributeKey::startOffset);32 auto startOffset = opAttrs.at(OpAttributeKey::startOffset);
33- ASSERT(OperErr::ATTRIBUTE_INVALID, startOffset.HasValue() && (startOffset.Type() == typeid(int64_t)))33+ ASSERT(OperErr::ATTRIBUTE_INVALID, startOffset.has_value() && (startOffset.type() == typeid(int64_t)))
34 << "GenGatherInL1 startOffset must be int64_t!";34 << "GenGatherInL1 startOffset must be int64_t!";
35 auto srcColumnStartOffset = AnyCast<int64_t>(startOffset);35 auto srcColumnStartOffset = AnyCast<int64_t>(startOffset);
36 std::string srcCoordCp = WrapParamByParentheses({std::to_string(srcColumnStartOffset)});36 std::string srcCoordCp = WrapParamByParentheses({std::to_string(srcColumnStartOffset)});
@@ -96,7 +96,7 @@ std::string CodeGenOpNPU::GenGatherInL1() const
96 const int64_t blockSize = AnyCast<int64_t>(opAttrs.at("op_attr_blocksize"));96 const int64_t blockSize = AnyCast<int64_t>(opAttrs.at("op_attr_blocksize"));
97 97 
98 auto startOffset = opAttrs.at(OpAttributeKey::startOffset);98 auto startOffset = opAttrs.at(OpAttributeKey::startOffset);
99- ASSERT(OperErr::ATTRIBUTE_INVALID, startOffset.HasValue() && (startOffset.Type() == typeid(int64_t)))99+ ASSERT(OperErr::ATTRIBUTE_INVALID, startOffset.has_value() && (startOffset.type() == typeid(int64_t)))
100 << "GenGatherInL1 startOffset must be int64_t!";100 << "GenGatherInL1 startOffset must be int64_t!";
101 auto srcColumnStartOffset = AnyCast<int64_t>(startOffset);101 auto srcColumnStartOffset = AnyCast<int64_t>(startOffset);
102 auto blockTableGMStride = GenParamIdxExprByIndex(ID3, SHAPE_DIM2, PREFIX_STR_RAW_SHAPE);102 auto blockTableGMStride = GenParamIdxExprByIndex(ID3, SHAPE_DIM2, PREFIX_STR_RAW_SHAPE);
@@ -677,7 +677,7 @@ void EncodeWaitUntilInfo(const Operation& op, std::vector<int32_t>& code)
677 code.push_back(dimShape);677 code.push_back(dimShape);
678 }678 }
679 // 编码waitUntil的attr属性,顺序固定679 // 编码waitUntil的attr属性,顺序固定
680- std::map<std::string, Any> map = op.GetAllAttribute();680+ auto map = op.GetAllAttribute();
681 auto it = map.find(OpAttributeKey::distOpAttr);681 auto it = map.find(OpAttributeKey::distOpAttr);
682 if (it != map.end()) {682 if (it != map.end()) {
683 Distributed::ShmemWaitUntilAttr distAttr = AnyCast<Distributed::ShmemWaitUntilAttr>(it->second);683 Distributed::ShmemWaitUntilAttr distAttr = AnyCast<Distributed::ShmemWaitUntilAttr>(it->second);
@@ -259,20 +259,20 @@ protected:
259 int GetCacheModeFlag(const std::string& cacheMode) const;259 int GetCacheModeFlag(const std::string& cacheMode) const;
260 260 
261 template <typename T>261 template <typename T>
262- bool GetAttrFromMap(const std::map<std::string, Any>& attrMap, const std::string& key, T& value) const262+ bool GetAttrFromMap(const std::map<std::string, std::any>& attrMap, const std::string& key, T& value) const
263 {263 {
264 auto it = attrMap.find(key);264 auto it = attrMap.find(key);
265 if (it == attrMap.end()) {265 if (it == attrMap.end()) {
266 CODEGEN_LOGI("can not find key: %s in attrMap", key.c_str());266 CODEGEN_LOGI("can not find key: %s in attrMap", key.c_str());
267 return false;267 return false;
268 }268 }
269- if (it->second.Type() == typeid(T)) {269+ if (it->second.type() == typeid(T)) {
270 value = AnyCast<T>(it->second);270 value = AnyCast<T>(it->second);
271 return true;271 return true;
272 }272 }
273 CODEGEN_LOGE(273 CODEGEN_LOGE(
274 GenCodeErr::DATA_TYPE_MISMATCHED, "Type of attribute %s from PASS is mismatch: %s != %s", key.c_str(),274 GenCodeErr::DATA_TYPE_MISMATCHED, "Type of attribute %s from PASS is mismatch: %s != %s", key.c_str(),
275- it->second.Type().name(), typeid(T).name());275+ it->second.type().name(), typeid(T).name());
276 return false;276 return false;
277 }277 }
278 278 
@@ -165,24 +165,24 @@ std::string CodeGenOpNPU::GenDupOp() const
165 std::string dupV;165 std::string dupV;
166 if (opAttrs.count(OpAttributeKey::dynScalar)) {166 if (opAttrs.count(OpAttributeKey::dynScalar)) {
167 auto scalar = opAttrs.at(OpAttributeKey::dynScalar);167 auto scalar = opAttrs.at(OpAttributeKey::dynScalar);
168- ASSERT(OperErr::ATTRIBUTE_INVALID, (scalar.HasValue()) && (scalar.Type() == typeid(SymbolicScalar)))168+ ASSERT(OperErr::ATTRIBUTE_INVALID, (scalar.has_value()) && (scalar.type() == typeid(SymbolicScalar)))
169 << "SCALAR attribute has to be symbolic value: " << AnyCast<SymbolicScalar>(scalar).IsValid();169 << "SCALAR attribute has to be symbolic value: " << AnyCast<SymbolicScalar>(scalar).IsValid();
170 auto scalarExpr = AnyCast<SymbolicScalar>(scalar);170 auto scalarExpr = AnyCast<SymbolicScalar>(scalar);
171 dupV = SymbolicExpressionTable::BuildExpression(scalarExpr);171 dupV = SymbolicExpressionTable::BuildExpression(scalarExpr);
172 } else if (dstDtypeStr == "float" || dstDtypeStr == "half" || dstDtypeStr == "bfloat16_t") {172 } else if (dstDtypeStr == "float" || dstDtypeStr == "half" || dstDtypeStr == "bfloat16_t") {
173 auto scalar = opAttrs.at(OpAttributeKey::scalar);173 auto scalar = opAttrs.at(OpAttributeKey::scalar);
174- ASSERT(OperErr::ATTRIBUTE_INVALID, (scalar.HasValue()) && (scalar.Type() == typeid(Element)))174+ ASSERT(OperErr::ATTRIBUTE_INVALID, (scalar.has_value()) && (scalar.type() == typeid(Element)))
175 << "SCALAR attribute must be float value: " << AnyCast<Element>(scalar).IsFloat();175 << "SCALAR attribute must be float value: " << AnyCast<Element>(scalar).IsFloat();
176 dupV = FormatFloat(AnyCast<Element>(scalar).Cast<float>(), operandDtype[ToUnderlying(MISOIdx::DST_IDX)]);176 dupV = FormatFloat(AnyCast<Element>(scalar).Cast<float>(), operandDtype[ToUnderlying(MISOIdx::DST_IDX)]);
177 } else if (177 } else if (
178 dstDtypeStr == "bool" || dstDtypeStr == "int8_t" || dstDtypeStr == "int16_t" || dstDtypeStr == "int32_t") {178 dstDtypeStr == "bool" || dstDtypeStr == "int8_t" || dstDtypeStr == "int16_t" || dstDtypeStr == "int32_t") {
179 auto scalar = opAttrs.at(OpAttributeKey::scalar);179 auto scalar = opAttrs.at(OpAttributeKey::scalar);
180- ASSERT(OperErr::ATTRIBUTE_INVALID, (scalar.HasValue()) && (scalar.Type() == typeid(Element)))180+ ASSERT(OperErr::ATTRIBUTE_INVALID, (scalar.has_value()) && (scalar.type() == typeid(Element)))
181 << "SCALAR attribute has to be int value: " << AnyCast<Element>(scalar).IsSigned();181 << "SCALAR attribute has to be int value: " << AnyCast<Element>(scalar).IsSigned();
182 dupV = std::to_string(AnyCast<Element>(scalar).Cast<int64_t>());182 dupV = std::to_string(AnyCast<Element>(scalar).Cast<int64_t>());
183 } else if (dstDtypeStr == "uint8_t" || dstDtypeStr == "uint16_t" || dstDtypeStr == "uint32_t") {183 } else if (dstDtypeStr == "uint8_t" || dstDtypeStr == "uint16_t" || dstDtypeStr == "uint32_t") {
184 auto scalar = opAttrs.at(OpAttributeKey::scalar);184 auto scalar = opAttrs.at(OpAttributeKey::scalar);
185- ASSERT(OperErr::ATTRIBUTE_INVALID, (scalar.HasValue()) && (scalar.Type() == typeid(Element)))185+ ASSERT(OperErr::ATTRIBUTE_INVALID, (scalar.has_value()) && (scalar.type() == typeid(Element)))
186 << "SCALAR attribute has to be uint value: " << AnyCast<Element>(scalar).IsUnsigned();186 << "SCALAR attribute has to be uint value: " << AnyCast<Element>(scalar).IsUnsigned();
187 dupV = std::to_string(AnyCast<Element>(scalar).Cast<uint64_t>());187 dupV = std::to_string(AnyCast<Element>(scalar).Cast<uint64_t>());
188 } else {188 } else {
@@ -592,7 +592,7 @@ std::string CodeGenOpNPU::GenUniformOp() const
592 SymbolicScalar counter0 = AnyCast<SymbolicScalar>(counter0Attr);592 SymbolicScalar counter0 = AnyCast<SymbolicScalar>(counter0Attr);
593 593 
594 std::vector<int64_t> randomShape;594 std::vector<int64_t> randomShape;
595- if (shapeAttr.HasValue()) {595+ if (shapeAttr.has_value()) {
596 randomShape = AnyCast<std::vector<int64_t>>(shapeAttr);596 randomShape = AnyCast<std::vector<int64_t>>(shapeAttr);
597 }597 }
598 598 
@@ -613,7 +613,7 @@ std::string CodeGenOpNPU::GenRangeOp() const
613 auto start = opAttrs.at(OP_ATTR_PREFIX + "START");613 auto start = opAttrs.at(OP_ATTR_PREFIX + "START");
614 auto step = opAttrs.at(OP_ATTR_PREFIX + "STEP");614 auto step = opAttrs.at(OP_ATTR_PREFIX + "STEP");
615 std::string startVal, stepVal, tileIdxExpr;615 std::string startVal, stepVal, tileIdxExpr;
616- ASSERT(OperErr::ATTRIBUTE_INVALID, start.HasValue() && step.HasValue()) << "GenRangeOp failed ";616+ ASSERT(OperErr::ATTRIBUTE_INVALID, start.has_value() && step.has_value()) << "GenRangeOp failed ";
617 617 
618 switch (operandDtype[ID0]) {618 switch (operandDtype[ID0]) {
619 case DataType::DT_FP32:619 case DataType::DT_FP32:
@@ -636,7 +636,7 @@ std::string CodeGenOpNPU::GenRangeOp() const
636 }636 }
637 if (opAttrs.count(OpAttributeKey::dynScalar)) {637 if (opAttrs.count(OpAttributeKey::dynScalar)) {
638 auto scalarAny = opAttrs.at(OpAttributeKey::dynScalar);638 auto scalarAny = opAttrs.at(OpAttributeKey::dynScalar);
639- ASSERT(OperErr::ATTRIBUTE_INVALID, (scalarAny.HasValue()) && (scalarAny.Type() == typeid(SymbolicScalar)))639+ ASSERT(OperErr::ATTRIBUTE_INVALID, (scalarAny.has_value()) && (scalarAny.type() == typeid(SymbolicScalar)))
640 << AnyCast<SymbolicScalar>(scalarAny).IsValid() << "SCALAR attribute has to have symbolic value.";640 << AnyCast<SymbolicScalar>(scalarAny).IsValid() << "SCALAR attribute has to have symbolic value.";
641 auto scalarExpr = AnyCast<SymbolicScalar>(scalarAny);641 auto scalarExpr = AnyCast<SymbolicScalar>(scalarAny);
642 tileIdxExpr = "((int64_t)(" + SymbolicExpressionTable::BuildExpression(scalarExpr) + "))";642 tileIdxExpr = "((int64_t)(" + SymbolicExpressionTable::BuildExpression(scalarExpr) + "))";
@@ -873,7 +873,7 @@ std::string CodeGenOpNPU::GenTriULOp() const
873 ASSERT(OperErr::ATTRIBUTE_INVALID, opAttrs.count(OpAttributeKey::dynScalar)) << "cannot get diagonal attr";873 ASSERT(OperErr::ATTRIBUTE_INVALID, opAttrs.count(OpAttributeKey::dynScalar)) << "cannot get diagonal attr";
874 ASSERT(OperErr::ATTRIBUTE_INVALID, opAttrs.count(OpAttributeKey::isUpper)) << "cannot get isUpper attr";874 ASSERT(OperErr::ATTRIBUTE_INVALID, opAttrs.count(OpAttributeKey::isUpper)) << "cannot get isUpper attr";
875 auto scalarAny = opAttrs.at(OpAttributeKey::dynScalar);875 auto scalarAny = opAttrs.at(OpAttributeKey::dynScalar);
876- ASSERT(OperErr::ATTRIBUTE_INVALID, (scalarAny.HasValue()) && (scalarAny.Type() == typeid(SymbolicScalar)))876+ ASSERT(OperErr::ATTRIBUTE_INVALID, (scalarAny.has_value()) && (scalarAny.type() == typeid(SymbolicScalar)))
877 << AnyCast<SymbolicScalar>(scalarAny).IsValid() << "diagonal must have symbolic value.";877 << AnyCast<SymbolicScalar>(scalarAny).IsValid() << "diagonal must have symbolic value.";
878 auto scalarExpr = AnyCast<SymbolicScalar>(scalarAny);878 auto scalarExpr = AnyCast<SymbolicScalar>(scalarAny);
879 879 
@@ -269,7 +269,7 @@ std::string CodeGenOpNPU::GenGatherElementOp() const
269 const std::vector<std::string> dataTypeExpr = {dstDtypeStr, src0DtypeStr, src1DtypeStr};269 const std::vector<std::string> dataTypeExpr = {dstDtypeStr, src0DtypeStr, src1DtypeStr};
270 int gatherEleAxis{-1};270 int gatherEleAxis{-1};
271 auto axis = opAttrs.at(OP_ATTR_PREFIX + "axis");271 auto axis = opAttrs.at(OP_ATTR_PREFIX + "axis");
272- if (axis.HasValue()) {272+ if (axis.has_value()) {
273 gatherEleAxis = AnyCast<int64_t>(axis);273 gatherEleAxis = AnyCast<int64_t>(axis);
274 }274 }
275 if (isSupportLayout) {275 if (isSupportLayout) {
@@ -468,7 +468,7 @@ std::string CodeGenOpNPU::GenTopKSortOp() const
468 std::string startIdx;468 std::string startIdx;
469 if (opAttrs.count(OpAttributeKey::dynScalar)) {469 if (opAttrs.count(OpAttributeKey::dynScalar)) {
470 auto scalar = opAttrs.at(OpAttributeKey::dynScalar);470 auto scalar = opAttrs.at(OpAttributeKey::dynScalar);
471- ASSERT(OperErr::ATTRIBUTE_INVALID, (scalar.HasValue()) && (scalar.Type() == typeid(SymbolicScalar)))471+ ASSERT(OperErr::ATTRIBUTE_INVALID, (scalar.has_value()) && (scalar.type() == typeid(SymbolicScalar)))
472 << AnyCast<SymbolicScalar>(scalar).IsValid() << "SCALAR attribute has to have symbolic value.";472 << AnyCast<SymbolicScalar>(scalar).IsValid() << "SCALAR attribute has to have symbolic value.";
473 auto scalarExpr = AnyCast<SymbolicScalar>(scalar);473 auto scalarExpr = AnyCast<SymbolicScalar>(scalar);
474 startIdx = SymbolicExpressionTable::BuildExpression(scalarExpr);474 startIdx = SymbolicExpressionTable::BuildExpression(scalarExpr);
@@ -67,7 +67,7 @@ std::string CodeGenOpNPU::PrintCastTileTensor() const
67 hasTmpBuffer ? GetTileOpParamsWithTmpBuf({ToUnderlying(MIMOIdx::TMP_IDX)}) : GetTileOpParamsByOrder();67 hasTmpBuffer ? GetTileOpParamsWithTmpBuf({ToUnderlying(MIMOIdx::TMP_IDX)}) : GetTileOpParamsByOrder();
68 auto mode = opAttrs.at(OP_ATTR_PREFIX + "mode");68 auto mode = opAttrs.at(OP_ATTR_PREFIX + "mode");
69 int64_t modeEnum{0};69 int64_t modeEnum{0};
70- if (mode.HasValue()) {70+ if (mode.has_value()) {
71 modeEnum = AnyCast<int64_t>(mode);71 modeEnum = AnyCast<int64_t>(mode);
72 }72 }
73 int64_t satModeEnum = 0;73 int64_t satModeEnum = 0;
@@ -93,7 +93,7 @@ std::string CodeGenOpNPU::PrintRowMaxlineStatic(const PrintUnaryParam& param) co
93{93{
94 int reduceAxis{-1};94 int reduceAxis{-1};
95 auto axis = opAttrs.at(OP_ATTR_PREFIX + "AXIS");95 auto axis = opAttrs.at(OP_ATTR_PREFIX + "AXIS");
96- if (axis.HasValue()) {96+ if (axis.has_value()) {
97 reduceAxis = AnyCast<int64_t>(axis);97 reduceAxis = AnyCast<int64_t>(axis);
98 }98 }
99 bool isValidAxis = ((reduceAxis >= 0) && (reduceAxis < (int(rawShape[1].size()) - 1)));99 bool isValidAxis = ((reduceAxis >= 0) && (reduceAxis < (int(rawShape[1].size()) - 1)));
@@ -128,7 +128,7 @@ std::string CodeGenOpNPU::PrintRowMaxlineDynamicUnaligned(const PrintUnaryParam&
128{128{
129 int reduceAxis{-1};129 int reduceAxis{-1};
130 auto axis = opAttrs.at(OP_ATTR_PREFIX + "AXIS");130 auto axis = opAttrs.at(OP_ATTR_PREFIX + "AXIS");
131- if (axis.HasValue()) {131+ if (axis.has_value()) {
132 reduceAxis = AnyCast<int64_t>(axis);132 reduceAxis = AnyCast<int64_t>(axis);
133 }133 }
134 bool isValidAxis = ((reduceAxis >= 0) && (reduceAxis < (int(rawShape[1].size()) - 1)));134 bool isValidAxis = ((reduceAxis >= 0) && (reduceAxis < (int(rawShape[1].size()) - 1)));
@@ -178,7 +178,7 @@ std::string CodeGenOpNPU::PrintRowMaxlineTileTensor() const
178 std::vector<std::string> tileOpParamList = GetTileOpParamsByOrder();178 std::vector<std::string> tileOpParamList = GetTileOpParamsByOrder();
179 int reduceAxis{-1};179 int reduceAxis{-1};
180 auto axis = opAttrs.at(OP_ATTR_PREFIX + "AXIS");180 auto axis = opAttrs.at(OP_ATTR_PREFIX + "AXIS");
181- if (axis.HasValue()) {181+ if (axis.has_value()) {
182 reduceAxis = AnyCast<int64_t>(axis);182 reduceAxis = AnyCast<int64_t>(axis);
183 }183 }
184 184 
@@ -371,7 +371,7 @@ std::string CodeGenOpNPU::PrintExpand(
371 std::vector<int64_t> ss = NormalizeShape(rawShape[1], SHAPE_DIM4);371 std::vector<int64_t> ss = NormalizeShape(rawShape[1], SHAPE_DIM4);
372 std::vector<int64_t> ds = NormalizeShape(rawShape[0], SHAPE_DIM4);372 std::vector<int64_t> ds = NormalizeShape(rawShape[0], SHAPE_DIM4);
373 auto axesAttr = opAttrs.at(OpAttributeKey::expandDims);373 auto axesAttr = opAttrs.at(OpAttributeKey::expandDims);
374- ASSERT(OperErr::ATTRIBUTE_INVALID, axesAttr.HasValue()) << "expandDims attribute not found";374+ ASSERT(OperErr::ATTRIBUTE_INVALID, axesAttr.has_value()) << "expandDims attribute not found";
375 auto expandAxes = AnyCast<std::vector<int64_t>>(axesAttr);375 auto expandAxes = AnyCast<std::vector<int64_t>>(axesAttr);
376 ASSERT(OperErr::ATTRIBUTE_INVALID, !expandAxes.empty()) << "expandDims is empty";376 ASSERT(OperErr::ATTRIBUTE_INVALID, !expandAxes.empty()) << "expandDims is empty";
377 377 
@@ -420,7 +420,7 @@ std::string CodeGenOpNPU::PrintOneHot(const PrintUnaryParam& param) const
420 paramList.emplace_back(std::to_string(ds[SHAPE_DIM2]));420 paramList.emplace_back(std::to_string(ds[SHAPE_DIM2]));
421 int numClasses{-1};421 int numClasses{-1};
422 auto num = opAttrs.at(OP_ATTR_PREFIX + "numClasses");422 auto num = opAttrs.at(OP_ATTR_PREFIX + "numClasses");
423- if (num.HasValue()) {423+ if (num.has_value()) {
424 numClasses = AnyCast<int64_t>(num);424 numClasses = AnyCast<int64_t>(num);
425 }425 }
426 constexpr int align = BLOCK_SIZE / sizeof(int64_t);426 constexpr int align = BLOCK_SIZE / sizeof(int64_t);
@@ -171,7 +171,7 @@ std::string CodeGenOpNPU::PrintArgReduceTileTensor() const
171 std::vector<std::string> tileOpParamList = GetTileOpParamsWithTmpBuf({ToUnderlying(MILOIdx::TMP2_IDX)});171 std::vector<std::string> tileOpParamList = GetTileOpParamsWithTmpBuf({ToUnderlying(MILOIdx::TMP2_IDX)});
172 int reduceAxis{-1};172 int reduceAxis{-1};
173 auto axis = opAttrs.at(OP_ATTR_PREFIX + "AXIS");173 auto axis = opAttrs.at(OP_ATTR_PREFIX + "AXIS");
174- if (axis.HasValue()) {174+ if (axis.has_value()) {
175 reduceAxis = AnyCast<int64_t>(axis);175 reduceAxis = AnyCast<int64_t>(axis);
176 }176 }
177 reduceAxis += SHAPE_DIM5 - rawShape[0].size();177 reduceAxis += SHAPE_DIM5 - rawShape[0].size();
@@ -291,7 +291,7 @@ std::string CodeGenOpNPU::PrintRowSumlineStatic(const PrintUnaryTmpBuffParam& pa
291{291{
292 int reduceAxis{-1};292 int reduceAxis{-1};
293 auto axis = opAttrs.at(OP_ATTR_PREFIX + "AXIS");293 auto axis = opAttrs.at(OP_ATTR_PREFIX + "AXIS");
294- if (axis.HasValue()) {294+ if (axis.has_value()) {
295 reduceAxis = AnyCast<int64_t>(axis);295 reduceAxis = AnyCast<int64_t>(axis);
296 }296 }
297 ASSERT(OperErr::ATTRIBUTE_INVALID, ((reduceAxis >= 0) && (reduceAxis < (int(rawShape[ID2].size()) - 1))))297 ASSERT(OperErr::ATTRIBUTE_INVALID, ((reduceAxis >= 0) && (reduceAxis < (int(rawShape[ID2].size()) - 1))))
@@ -329,7 +329,7 @@ std::string CodeGenOpNPU::PrintRowSumlineDynamicUnaligned(const PrintUnaryTmpBuf
329{329{
330 int reduceAxis{-1};330 int reduceAxis{-1};
331 auto axis = opAttrs.at(OP_ATTR_PREFIX + "AXIS");331 auto axis = opAttrs.at(OP_ATTR_PREFIX + "AXIS");
332- if (axis.HasValue()) {332+ if (axis.has_value()) {
333 reduceAxis = AnyCast<int64_t>(axis);333 reduceAxis = AnyCast<int64_t>(axis);
334 }334 }
335 ASSERT(OperErr::ATTRIBUTE_INVALID, ((reduceAxis >= 0) && (reduceAxis < (int(rawShape[ID2].size()) - 1))))335 ASSERT(OperErr::ATTRIBUTE_INVALID, ((reduceAxis >= 0) && (reduceAxis < (int(rawShape[ID2].size()) - 1))))
@@ -387,7 +387,7 @@ std::string CodeGenOpNPU::PrintRowSumlineTileTensor() const
387 std::vector<std::string> tileOpParamList = GetTileOpParamsWithTmpBuf({ToUnderlying(MIMOIdx::TMP_IDX)});387 std::vector<std::string> tileOpParamList = GetTileOpParamsWithTmpBuf({ToUnderlying(MIMOIdx::TMP_IDX)});
388 int reduceAxis{-1};388 int reduceAxis{-1};
389 auto axis = opAttrs.at(OP_ATTR_PREFIX + "AXIS");389 auto axis = opAttrs.at(OP_ATTR_PREFIX + "AXIS");
390- if (axis.HasValue()) {390+ if (axis.has_value()) {
391 reduceAxis = AnyCast<int64_t>(axis);391 reduceAxis = AnyCast<int64_t>(axis);
392 }392 }
393 ASSERT(OperErr::ATTRIBUTE_INVALID, ((reduceAxis >= 0) && (reduceAxis < (int(rawShape[ID2].size()) - 1))))393 ASSERT(OperErr::ATTRIBUTE_INVALID, ((reduceAxis >= 0) && (reduceAxis < (int(rawShape[ID2].size()) - 1))))
@@ -26,7 +26,6 @@
26 26 
27#include <nlohmann/json.hpp>27#include <nlohmann/json.hpp>
28 28 
29-#include "interface/inner/any.h"
30#include "interface/utils/common.h"29#include "interface/utils/common.h"
31#include "interface/utils/file_utils.h"30#include "interface/utils/file_utils.h"
32#include "interface/utils/string_utils.h"31#include "interface/utils/string_utils.h"
@@ -153,7 +152,7 @@ struct TypeInfo {
153 std::map<std::string, std::pair<int64_t, int64_t>> rangeInfos;152 std::map<std::string, std::pair<int64_t, int64_t>> rangeInfos;
154};153};
155 154 
156-const Any& ConfigScope::GetAnyConfig(const std::string& key) const155+const std::any& ConfigScope::GetAnyConfig(const std::string& key) const
157{156{
158 if (values_.find(key) == values_.end()) {157 if (values_.find(key) == values_.end()) {
159 if (parent_) {158 if (parent_) {
@@ -223,10 +222,10 @@ void DumpMap(std::stringstream& os, const std::map<int64_t, int64_t>& map)
223 os << '}';222 os << '}';
224}223}
225 224 
226-void DumpValue(std::stringstream& os, const std::string& key, const Any& val, const std::string& prefix)225+void DumpValue(std::stringstream& os, const std::string& key, const std::any& val, const std::string& prefix)
227{226{
228 os << prefix << key << ": ";227 os << prefix << key << ": ";
229- const auto& type = val.Type();228+ const auto& type = val.type();
230 229 
231 if (type == typeid(int64_t)) {230 if (type == typeid(int64_t)) {
232 os << (AnyCast<int64_t>(val));231 os << (AnyCast<int64_t>(val));
@@ -249,7 +248,7 @@ void DumpValue(std::stringstream& os, const std::string& key, const Any& val, co
249 }248 }
250}249}
251 250 
252-void DumpValues(std::stringstream& os, const std::map<std::string, Any>& values, const std::string& prefix)251+void DumpValues(std::stringstream& os, const std::map<std::string, std::any>& values, const std::string& prefix)
253{252{
254 for (const auto& [key, val] : values) {253 for (const auto& [key, val] : values) {
255 DumpValue(os, key, val, prefix);254 DumpValue(os, key, val, prefix);
@@ -285,16 +284,16 @@ bool HasRangeConstraint(
285 return false;284 return false;
286}285}
287 286 
288-void ValidateConfigValueType(const std::string& key, const Any& value)287+void ValidateConfigValueType(const std::string& key, const std::any& value)
289{288{
290 const auto& expectedType = ConfigManagerNg::GetInstance().Type(key);289 const auto& expectedType = ConfigManagerNg::GetInstance().Type(key);
291- if (expectedType == typeid(void) || value.Type() == expectedType) {290+ if (expectedType == typeid(void) || value.type() == expectedType) {
292 return;291 return;
293 }292 }
294 293 
295 std::stringstream os;294 std::stringstream os;
296 os << "Option '" << key << "' has invalid type. Expected " << GetReadableTypeName(expectedType) << ", but got "295 os << "Option '" << key << "' has invalid type. Expected " << GetReadableTypeName(expectedType) << ", but got "
297- << GetReadableTypeName(value.Type());296+ << GetReadableTypeName(value.type());
298 CHECK(ExternalError::INVALID_TYPE, false) << os.str();297 CHECK(ExternalError::INVALID_TYPE, false) << os.str();
299}298}
300 299 
@@ -307,9 +306,9 @@ std::string ConfigScope::ToString() const
307 return os.str();306 return os.str();
308}307}
309 308 
310-const std::map<std::string, Any> ConfigScope::GetAllConfig() const309+const std::map<std::string, std::any> ConfigScope::GetAllConfig() const
311{310{
312- std::map<std::string, Any> values;311+ std::map<std::string, std::any> values;
313 auto scope = this;312 auto scope = this;
314 while (scope) {313 while (scope) {
315 for (auto& [key, val] : scope->values_) {314 for (auto& [key, val] : scope->values_) {
@@ -322,24 +321,24 @@ const std::map<std::string, Any> ConfigScope::GetAllConfig() const
322 return values;321 return values;
323}322}
324 323 
325-void ConfigScope::AddValue(const std::string& key, Any value)324+void ConfigScope::AddValue(const std::string& key, std::any value)
326{325{
327 std::lock_guard<std::mutex> lock(mtx);326 std::lock_guard<std::mutex> lock(mtx);
328 values_[key] = value;327 values_[key] = value;
329}328}
330 329 
331-void ConfigScope::UpdateValueWithAny(const std::string& key, Any value)330+void ConfigScope::UpdateValueWithAny(const std::string& key, std::any value)
332{331{
333 ValidateConfigValueType(key, value);332 ValidateConfigValueType(key, value);
334 const auto& rangeInfos = ConfigManagerNg::GetInstance().Range();333 const auto& rangeInfos = ConfigManagerNg::GetInstance().Range();
335- if (HasRangeConstraint(key, value.Type(), rangeInfos) &&334+ if (HasRangeConstraint(key, value.type(), rangeInfos) &&
336 !ConfigManagerNg::GetInstance().IsWithinRange(key, value)) {335 !ConfigManagerNg::GetInstance().IsWithinRange(key, value)) {
337 std::stringstream os("Option:");336 std::stringstream os("Option:");
338- std::map<std::string, Any> node;337+ std::map<std::string, std::any> node;
339 node[key] = value;338 node[key] = value;
340 DumpValues(os, node, "");339 DumpValues(os, node, "");
341 os << "its value doesn't within the value range. ";340 os << "its value doesn't within the value range. ";
342- DumpRange(os, value.Type(), key, rangeInfos);341+ DumpRange(os, value.type(), key, rangeInfos);
343 CHECK(ExternalError::INVALID_VAL, false) << os.str();342 CHECK(ExternalError::INVALID_VAL, false) << os.str();
344 }343 }
345 std::stringstream oss;344 std::stringstream oss;
@@ -397,7 +396,7 @@ struct ConfigManagerImpl {
397 return true;396 return true;
398 }397 }
399 398 
400- void BeginScope(const std::string& name, std::map<std::string, Any>&& values, const char* file, int lino)399+ void BeginScope(const std::string& name, std::map<std::string, std::any>&& values, const char* file, int lino)
401 {400 {
402 auto scope = std::make_shared<ConfigScope>(scopes.top());401 auto scope = std::make_shared<ConfigScope>(scopes.top());
403 scope->values_ = std::move(values);402 scope->values_ = std::move(values);
@@ -417,7 +416,7 @@ struct ConfigManagerImpl {
417 scopes.pop();416 scopes.pop();
418 }417 }
419 418 
420- void SetScope(std::map<std::string, Any>&& values, const char* file, int lino)419+ void SetScope(std::map<std::string, std::any>&& values, const char* file, int lino)
421 {420 {
422 auto scope = scopes.top();421 auto scope = scopes.top();
423 if (scope.use_count() > 1) { // clone if shared422 if (scope.use_count() > 1) { // clone if shared
@@ -434,7 +433,7 @@ struct ConfigManagerImpl {
434 }433 }
435 }434 }
436 435 
437- void SetGlobalConfig(std::map<std::string, Any>&& values, const char* file, int lino)436+ void SetGlobalConfig(std::map<std::string, std::any>&& values, const char* file, int lino)
438 {437 {
439 if (values.empty()) {438 if (values.empty()) {
440 FE_LOGW("No values provided to set in global config. Locations: %s:%d", file, lino);439 FE_LOGW("No values provided to set in global config. Locations: %s:%d", file, lino);
@@ -550,7 +549,7 @@ private:
550};549};
551 550 
552void ConfigManagerNg::BeginScope(551void ConfigManagerNg::BeginScope(
553- const std::string& name, std::map<std::string, Any>&& values, const char* file, int lino)552+ const std::string& name, std::map<std::string, std::any>&& values, const char* file, int lino)
554{553{
555 impl_->BeginScope(name, std::move(values), file, lino);554 impl_->BeginScope(name, std::move(values), file, lino);
556}555}
@@ -565,19 +564,19 @@ ConfigManagerNg::ScopedRestore::ScopedRestore(std::shared_ptr<ConfigScope> scope
565ConfigManagerNg::ScopedRestore::~ScopedRestore() { ConfigManagerNg::GetInstance().EndScope(); }564ConfigManagerNg::ScopedRestore::~ScopedRestore() { ConfigManagerNg::GetInstance().EndScope(); }
566 565 
567ConfigManagerNg::JitScopeGuard::JitScopeGuard(566ConfigManagerNg::JitScopeGuard::JitScopeGuard(
568- const std::string& name, std::map<std::string, Any>&& values, const char* file, int lino)567+ const std::string& name, std::map<std::string, std::any>&& values, const char* file, int lino)
569{568{
570 ConfigManagerNg::GetInstance().BeginScope(name, std::move(values), file, lino);569 ConfigManagerNg::GetInstance().BeginScope(name, std::move(values), file, lino);
571}570}
572 571 
573ConfigManagerNg::JitScopeGuard::~JitScopeGuard() { ConfigManagerNg::GetInstance().EndScope(); }572ConfigManagerNg::JitScopeGuard::~JitScopeGuard() { ConfigManagerNg::GetInstance().EndScope(); }
574 573 
575-void ConfigManagerNg::SetScope(std::map<std::string, Any>&& values, const char* file, int lino)574+void ConfigManagerNg::SetScope(std::map<std::string, std::any>&& values, const char* file, int lino)
576{575{
577 return impl_->SetScope(std::move(values), file, lino);576 return impl_->SetScope(std::move(values), file, lino);
578}577}
579 578 
580-void ConfigManagerNg::SetGlobalConfig(std::map<std::string, Any>&& values, const char* file, int lino)579+void ConfigManagerNg::SetGlobalConfig(std::map<std::string, std::any>&& values, const char* file, int lino)
581{580{
582 return impl_->SetGlobalConfig(std::move(values), file, lino);581 return impl_->SetGlobalConfig(std::move(values), file, lino);
583}582}
@@ -588,12 +587,12 @@ std::shared_ptr<ConfigScope> ConfigManagerNg::CurrentScope() { return GetInstanc
588 587 
589std::shared_ptr<ConfigScope> ConfigManagerNg::GlobalScope() { return GetInstance().impl_->root; }588std::shared_ptr<ConfigScope> ConfigManagerNg::GlobalScope() { return GetInstance().impl_->root; }
590 589 
591-bool ConfigManagerNg::IsWithinRange(const std::string& properties, Any& value) const590+bool ConfigManagerNg::IsWithinRange(const std::string& properties, std::any& value) const
592{591{
593 try {592 try {
594- if (value.Type() == typeid(std::map<int64_t, int64_t>)) {593+ if (value.type() == typeid(std::map<int64_t, int64_t>)) {
595 return impl_->IsWithinRange(properties, AnyCast<std::map<int64_t, int64_t>>(value));594 return impl_->IsWithinRange(properties, AnyCast<std::map<int64_t, int64_t>>(value));
596- } else if (value.Type() == typeid(int64_t)) {595+ } else if (value.type() == typeid(int64_t)) {
597 return impl_->IsWithinRange(properties, AnyCast<int64_t>(value));596 return impl_->IsWithinRange(properties, AnyCast<int64_t>(value));
598 }597 }
599 } catch (const std::out_of_range& e) {598 } catch (const std::out_of_range& e) {
@@ -22,7 +22,6 @@
22#include <string>22#include <string>
23 23 
24#include "tilefwk/tilefwk.h"24#include "tilefwk/tilefwk.h"
25-#include "interface/inner/any.h"
26#include "tilefwk/tile_shape.h"25#include "tilefwk/tile_shape.h"
27 26 
28namespace npu::tile_fwk {27namespace npu::tile_fwk {
@@ -102,12 +101,12 @@ public:
102 * \brief Get the config value with the specific key. throw runtime_error if101 * \brief Get the config value with the specific key. throw runtime_error if
103 * the key is not found.102 * the key is not found.
104 */103 */
105- const Any& GetAnyConfig(const std::string& key) const;104+ const std::any& GetAnyConfig(const std::string& key) const;
106 105 
107 /**106 /**
108 * \brief Returns a map of all configuration key-value pairs.107 * \brief Returns a map of all configuration key-value pairs.
109 */108 */
110- const std::map<std::string, Any> GetAllConfig() const;109+ const std::map<std::string, std::any> GetAllConfig() const;
111 110 
112 /**111 /**
113 * \brief Get the typed config value with the specific key.112 * \brief Get the typed config value with the specific key.
@@ -183,8 +182,8 @@ public:
183 */182 */
184 CubeTile GetCubeTile() const183 CubeTile GetCubeTile() const
185 {184 {
186- const Any& value = GetAnyConfig("cube_tile_shapes");185+ const std::any& value = GetAnyConfig("cube_tile_shapes");
187- return AnyCast<CubeTile>(value);186+ return pypto::AnyCast<CubeTile>(value);
188 }187 }
189 188 
190 /**189 /**
@@ -192,8 +191,7 @@ public:
192 */191 */
193 ConvTile GetConvTile() const192 ConvTile GetConvTile() const
194 {193 {
195- const Any& value = GetAnyConfig("conv_tile_shapes");194+ return pypto::AnyCast<ConvTile>(GetAnyConfig("conv_tile_shapes"));
196- return AnyCast<ConvTile>(value);
197 }195 }
198 196 
199 /**197 /**
@@ -201,9 +199,8 @@ public:
201 */199 */
202 VecTile GetVecTile() const200 VecTile GetVecTile() const
203 {201 {
204- const Any& value = GetAnyConfig("vec_tile_shapes");202+ auto& value = GetAnyConfig("vec_tile_shapes");
205- 203+ return {pypto::AnyCastRef<std::vector<int64_t>>(value)};
206- return VecTile{AnyCast<std::vector<int64_t>>(value)};
207 }204 }
208 205 
209 /**206 /**
@@ -211,8 +208,8 @@ public:
211 */208 */
212 std::vector<int64_t> GetMatrixSize() const209 std::vector<int64_t> GetMatrixSize() const
213 {210 {
214- const Any& value = GetAnyConfig("matrix_size");211+ auto& value = GetAnyConfig("matrix_size");
215- return AnyCast<std::vector<int64_t>>(value);212+ return pypto::AnyCast<std::vector<int64_t>>(value);
216 }213 }
217 214 
218 /**215 /**
@@ -238,9 +235,9 @@ public:
238 * \param key The config key.235 * \param key The config key.
239 * \param value The config value to set.236 * \param value The config value to set.
240 */237 */
241- void AddValue(const std::string& key, Any value);238+ void AddValue(const std::string& key, std::any value);
242 239 
243- void UpdateValueWithAny(const std::string& key, Any value);240+ void UpdateValueWithAny(const std::string& key, std::any value);
244 241 
245 /**242 /**
246 * \brief update a config value for the given key.243 * \brief update a config value for the given key.
@@ -250,7 +247,7 @@ public:
250 template <typename T>247 template <typename T>
251 void UpdateValue(const std::string& key, T RawValue)248 void UpdateValue(const std::string& key, T RawValue)
252 {249 {
253- Any value = ConvertTtoAny(RawValue);250+ std::any value = ConvertToAny(RawValue);
254 UpdateValueWithAny(key, value);251 UpdateValueWithAny(key, value);
255 }252 }
256 253 
@@ -281,7 +278,7 @@ private:
281 278 
282 std::shared_ptr<ConfigScope> parent_;279 std::shared_ptr<ConfigScope> parent_;
283 std::list<ConfigScope*> children_;280 std::list<ConfigScope*> children_;
284- std::map<std::string, Any> values_;281+ std::map<std::string, std::any> values_;
285 282 
286 std::string name_;283 std::string name_;
287 std::string begin_file_;284 std::string begin_file_;
@@ -290,16 +287,16 @@ private:
290 int end_lino_{0};287 int end_lino_{0};
291 288 
292 template <typename T>289 template <typename T>
293- Any ConvertTtoAny(T value)290+ std::any ConvertToAny(T value)
294 {291 {
295 if constexpr (std::is_same_v<T, bool>) {292 if constexpr (std::is_same_v<T, bool>) {
296- return Any(value);293+ return value;
297 } else if constexpr (std::is_integral_v<T>) {294 } else if constexpr (std::is_integral_v<T>) {
298- return Any(static_cast<int64_t>(value));295+ return static_cast<int64_t>(value);
299 } else if constexpr (std::is_same_v<T, const char*>) {296 } else if constexpr (std::is_same_v<T, const char*>) {
300- return Any(std::string(value));297+ return std::string(value);
301 } else {298 } else {
302- return Any(value);299+ return value;
303 }300 }
304 }301 }
305};302};
@@ -312,7 +309,7 @@ public:
312 * \param values309 * \param values
313 */310 */
314 void BeginScope(311 void BeginScope(
315- const std::string& name, std::map<std::string, Any>&& values, const char* file = __builtin_FILE(),312+ const std::string& name, std::map<std::string, std::any>&& values, const char* file = __builtin_FILE(),
316 int line = __builtin_LINE());313 int line = __builtin_LINE());
317 314 
318 /**315 /**
@@ -328,7 +325,7 @@ public:
328 class JitScopeGuard {325 class JitScopeGuard {
329 public:326 public:
330 JitScopeGuard(327 JitScopeGuard(
331- const std::string& name, std::map<std::string, Any>&& values = {}, const char* file = __builtin_FILE(),328+ const std::string& name, std::map<std::string, std::any>&& values = {}, const char* file = __builtin_FILE(),
332 int line = __builtin_LINE());329 int line = __builtin_LINE());
333 ~JitScopeGuard();330 ~JitScopeGuard();
334 JitScopeGuard(const JitScopeGuard&) = delete;331 JitScopeGuard(const JitScopeGuard&) = delete;
@@ -365,7 +362,7 @@ public:
365 * @param values362 * @param values
366 */363 */
367 void SetScope(364 void SetScope(
368- std::map<std::string, Any>&& values, const char* file = __builtin_FILE(), int line = __builtin_LINE());365+ std::map<std::string, std::any>&& values, const char* file = __builtin_FILE(), int line = __builtin_LINE());
369 366 
370 /**367 /**
371 * @brief Get the Current Scope object368 * @brief Get the Current Scope object
@@ -400,7 +397,7 @@ public:
400 /**397 /**
401 * \brief Check if the value is within the specified range.398 * \brief Check if the value is within the specified range.
402 */399 */
403- bool IsWithinRange(const std::string& properties, Any& value) const;400+ bool IsWithinRange(const std::string& properties, std::any& value) const;
404 401 
405 static ConfigManagerNg& GetInstance();402 static ConfigManagerNg& GetInstance();
406 403 
@@ -430,7 +427,7 @@ public:
430 * @brief Set Global Config for python frontend427 * @brief Set Global Config for python frontend
431 *428 *
432 */429 */
433- void SetGlobalConfig(std::map<std::string, Any>&& values, const char* file, int lino);430+ void SetGlobalConfig(std::map<std::string, std::any>&& values, const char* file, int lino);
434 431 
435 ~ConfigManagerNg();432 ~ConfigManagerNg();
436 433 
@@ -1,154 +0,0 @@
1-/**
2- * Copyright (c) 2025 Huawei Technologies Co., Ltd.
3- * This program is free software, you can redistribute it and/or modify it under the terms and conditions of
4- * CANN Open Software License Agreement Version 2.0 (the "License").
5- * Please refer to the License for details. You may not use this file except in compliance with the License.
6- * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED,
7- * INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE.
8- * See LICENSE in the root of the software repository for the full text of the License.
9- */
10- 
11-/*!
12- * \file any.h
13- * \brief
14- */
15- 
16-#pragma once
17- 
18-#include <typeinfo>
19-#include <type_traits>
20-#include <utility>
21- 
22-namespace npu::tile_fwk {
23-class Any {
24-private:
25- struct Base {
26- virtual ~Base() = default;
27- virtual Base* Clone() const = 0;
28- virtual const std::type_info& Type() const noexcept = 0;
29- };
30- 
31- template <typename T>
32- struct Derived : Base {
33- T value_;
34- 
35- template <typename U>
36- Derived(U&& value) : value_(std::forward<U>(value))
37- {}
38- 
39- Base* Clone() const override { return new Derived(value_); }
40- const std::type_info& Type() const noexcept override { return typeid(T); }
41- };
42- 
43- Base* ptr_ = nullptr;
44- 
45-public:
46- Any() noexcept = default;
47- 
48- Any(const Any& other) : ptr_(other.ptr_ ? other.ptr_->Clone() : nullptr) {}
49- 
50- Any(Any&& other) noexcept : ptr_(other.ptr_) { other.ptr_ = nullptr; }
51- 
52- template <typename T, typename = std::enable_if_t<!std::is_same<std::decay_t<T>, Any>::value>>
53- Any(T&& value) : ptr_(new Derived<std::decay_t<T>>(std::forward<T>(value)))
54- {}
55- 
56- ~Any() { delete ptr_; }
57- 
58- Any& operator=(const Any& other)
59- {
60- if (this != &other) {
61- Any(other).Swap(*this);
62- }
63- return *this;
64- }
65- 
66- Any& operator=(Any&& other) noexcept
67- {
68- if (this != &other) {
69- other.Swap(*this);
70- }
71- return *this;
72- }
73- 
74- template <typename T, typename = std::enable_if_t<!std::is_same<std::decay_t<T>, Any>::value>>
75- Any& operator=(T&& value)
76- {
77- Any(std::forward<T>(value)).Swap(*this);
78- return *this;
79- }
80- 
81- void Reset() noexcept
82- {
83- delete ptr_;
84- ptr_ = nullptr;
85- }
86- 
87- void Swap(Any& other) noexcept { std::swap(ptr_, other.ptr_); }
88- 
89- bool HasValue() const noexcept { return ptr_ != nullptr; }
90- 
91- const std::type_info& Type() const noexcept { return ptr_ ? ptr_->Type() : typeid(void); }
92- 
93- template <typename T>
94- friend T* AnyCast(Any* any) noexcept;
95- 
96- template <typename T>
97- friend const T* AnyCast(const Any* any) noexcept;
98-};
99- 
100-template <typename T>
101-T* AnyCast(Any* any) noexcept
102-{
103- if (!any || any->Type() != typeid(T)) {
104- return nullptr;
105- }
106- return &static_cast<Any::Derived<T>*>(any->ptr_)->value_;
107-}
108- 
109-template <typename T>
110-const T* AnyCast(const Any* any) noexcept
111-{
112- if (!any || any->Type() != typeid(T)) {
113- return nullptr;
114- }
115- 
116- return &static_cast<const Any::Derived<T>*>(any->ptr_)->value_;
117-}
118- 
119-template <typename T>
120-T AnyCast(const Any& any)
121-{
122- using U = std::remove_cv_t<std::remove_reference_t<T>>;
123- auto p = AnyCast<U>(&any);
124- if (!p) {
125- throw std::bad_cast();
126- }
127- 
128- return *p;
129-}
130- 
131-template <typename T>
132-T AnyCast(Any& any)
133-{
134- using U = std::remove_cv_t<std::remove_reference_t<T>>;
135- auto p = AnyCast<U>(&any);
136- if (!p) {
137- throw std::bad_cast();
138- }
139- 
140- return *p;
141-}
142- 
143-template <typename T>
144-T AnyCast(Any&& any)
145-{
146- using U = std::remove_cv_t<std::remove_reference_t<T>>;
147- auto p = AnyCast<U>(&any);
148- if (!p) {
149- throw std::bad_cast();
150- }
151- 
152- return std::move(*p);
153-}
154-} // namespace npu::tile_fwk
@@ -19,7 +19,6 @@
19#include <vector>19#include <vector>
20#include <string>20#include <string>
21#include <array>21#include <array>
22-#include "interface/inner/any.h"
23 22 
24namespace npu::tile_fwk {23namespace npu::tile_fwk {
25 24 
@@ -368,8 +368,7 @@ void ExecutePrint(ExecuteOperationContext* ctx)
368 return;368 return;
369 }369 }
370 370 
371- std::vector<SymbolicScalar>* scalars = nullptr;371+ auto scalars = ctx->op->GetAttr<std::vector<SymbolicScalar>>(OP_ATTR_PREFIX + "scalars");
372- scalars = ctx->op->GetAttr<std::vector<SymbolicScalar> >(OP_ATTR_PREFIX + "scalars");
373 if (ctx->op->HasAttribute(OP_ATTR_PREFIX + "fname")) {372 if (ctx->op->HasAttribute(OP_ATTR_PREFIX + "fname")) {
374 auto fname = ctx->op->GetStringAttribute(OP_ATTR_PREFIX + "fname");373 auto fname = ctx->op->GetStringAttribute(OP_ATTR_PREFIX + "fname");
375 uint64_t ts = 0;374 uint64_t ts = 0;
@@ -19,8 +19,9 @@
19#include <string>19#include <string>
20#include <any>20#include <any>
21 21 
22+#include "core/any_cast.h"
23+ 
22#include "tilefwk/symbolic_scalar.h"24#include "tilefwk/symbolic_scalar.h"
23-#include "interface/inner/any.h"
24#include "interface/utils/common.h"25#include "interface/utils/common.h"
25#include "interface/utils/string_utils.h"26#include "interface/utils/string_utils.h"
26#include "tilefwk/error_code.h"27#include "tilefwk/error_code.h"
@@ -32,11 +33,11 @@ const std::string OP_EMUOP_PREFIX = "op_emuop_";
32 33 
33class AttrHolder {34class AttrHolder {
34protected:35protected:
35- std::map<std::string, npu::tile_fwk::Any> attributes;36+ std::map<std::string, std::any> attributes;
36 37 
37public:38public:
38- const std::map<std::string, npu::tile_fwk::Any>& GetAllAttr() const { return attributes; }39+ const std::map<std::string, std::any>& GetAllAttr() const { return attributes; }
39- std::map<std::string, npu::tile_fwk::Any>& GetAllAttr() { return attributes; }40+ std::map<std::string, std::any>& GetAllAttr() { return attributes; }
40 41 
41 bool HasAttr(const std::string& key) const42 bool HasAttr(const std::string& key) const
42 {43 {
@@ -55,13 +56,13 @@ public:
55 attributes[key] = value;56 attributes[key] = value;
56 }57 }
57 58 
58- npu::tile_fwk::Any GetRawAttr(const std::string& key) const59+ std::any GetRawAttr(const std::string& key) const
59 {60 {
60 auto it = attributes.find(key);61 auto it = attributes.find(key);
61 if (it != attributes.end()) {62 if (it != attributes.end()) {
62 return it->second;63 return it->second;
63 }64 }
64- return npu::tile_fwk::Any();65+ return std::any();
65 }66 }
66 67 
67 template <typename T>68 template <typename T>
@@ -71,10 +72,10 @@ public:
71 static_assert(!std::is_same_v<T, std::vector<int>>);72 static_assert(!std::is_same_v<T, std::vector<int>>);
72 auto it = attributes.find(key);73 auto it = attributes.find(key);
73 if (it != attributes.end()) {74 if (it != attributes.end()) {
74- if (it->second.Type() == typeid(T)) {75+ if (it->second.type() == typeid(T)) {
75- value = npu::tile_fwk::AnyCast<T>(it->second);76+ value = pypto::AnyCast<T>(it->second);
76 } else {77 } else {
77- std::cout << "Type mismatch: " << it->second.Type().name() << " != " << typeid(T).name() << std::endl;78+ std::cout << "Type mismatch: " << it->second.type().name() << " != " << typeid(T).name() << std::endl;
78 return false;79 return false;
79 }80 }
80 } else {81 } else {
@@ -87,8 +88,8 @@ public:
87 T* GetAttr(const std::string& key)88 T* GetAttr(const std::string& key)
88 {89 {
89 auto it = attributes.find(key);90 auto it = attributes.find(key);
90- if (it != attributes.end() && it->second.Type() == typeid(T)) {91+ if (it != attributes.end() && it->second.type() == typeid(T)) {
91- return AnyCast<T>(&it->second);92+ return &pypto::AnyCastRef<T>(it->second);
92 }93 }
93 return nullptr;94 return nullptr;
94 }95 }
@@ -133,20 +134,20 @@ public:
133 }134 }
134 135 
135 std::string result;136 std::string result;
136- if (it->second.Type() == typeid(int64_t)) {137+ if (it->second.type() == typeid(int64_t)) {
137- result = std::to_string(npu::tile_fwk::AnyCast<int64_t>(it->second));138+ result = std::to_string(pypto::AnyCastRef<int64_t>(it->second));
138- } else if (it->second.Type() == typeid(float)) {139+ } else if (it->second.type() == typeid(float)) {
139- result = std::to_string(npu::tile_fwk::AnyCast<float>(it->second));140+ result = std::to_string(pypto::AnyCastRef<float>(it->second));
140- } else if (it->second.Type() == typeid(double)) {141+ } else if (it->second.type() == typeid(double)) {
141- result = std::to_string(npu::tile_fwk::AnyCast<double>(it->second));142+ result = std::to_string(pypto::AnyCastRef<double>(it->second));
142- } else if (it->second.Type() == typeid(std::string)) {143+ } else if (it->second.type() == typeid(std::string)) {
143- result = npu::tile_fwk::AnyCast<std::string>(it->second);144+ result = pypto::AnyCastRef<std::string>(it->second);
144- } else if (it->second.Type() == typeid(bool)) {145+ } else if (it->second.type() == typeid(bool)) {
145- result = std::to_string(npu::tile_fwk::AnyCast<bool>(it->second));146+ result = std::to_string(pypto::AnyCastRef<bool>(it->second));
146- } else if (it->second.Type() == typeid(std::vector<int64_t>)) {147+ } else if (it->second.type() == typeid(std::vector<int64_t>)) {
147- result = IntVecToStr(npu::tile_fwk::AnyCast<std::vector<int64_t>>(it->second));148+ result = IntVecToStr(pypto::AnyCastRef<std::vector<int64_t>>(it->second));
148- } else if (it->second.Type() == typeid(Element)) {149+ } else if (it->second.type() == typeid(Element)) {
149- auto tensorElement = npu::tile_fwk::AnyCast<Element>(it->second);150+ auto tensorElement = pypto::AnyCastRef<Element>(it->second);
150 if (tensorElement.IsSigned()) {151 if (tensorElement.IsSigned()) {
151 result = std::to_string(tensorElement.GetSignedData());152 result = std::to_string(tensorElement.GetSignedData());
152 } else if (tensorElement.IsUnsigned()) {153 } else if (tensorElement.IsUnsigned()) {
@@ -154,11 +155,11 @@ public:
154 } else if (tensorElement.IsFloat()) {155 } else if (tensorElement.IsFloat()) {
155 result = std::to_string(tensorElement.GetFloatData());156 result = std::to_string(tensorElement.GetFloatData());
156 }157 }
157- } else if (it->second.Type() == typeid(SymbolicScalar)) {158+ } else if (it->second.type() == typeid(SymbolicScalar)) {
158- auto scalar = npu::tile_fwk::AnyCast<SymbolicScalar>(it->second);159+ auto scalar = pypto::AnyCastRef<SymbolicScalar>(it->second);
159 result = scalar.Dump();160 result = scalar.Dump();
160- } else if (it->second.Type() == typeid(std::vector<SymbolicScalar>)) {161+ } else if (it->second.type() == typeid(std::vector<SymbolicScalar>)) {
161- auto scalarList = npu::tile_fwk::AnyCast<std::vector<SymbolicScalar>>(it->second);162+ auto scalarList = pypto::AnyCastRef<std::vector<SymbolicScalar>>(it->second);
162 std::ostringstream oss;163 std::ostringstream oss;
163 oss << "[";164 oss << "[";
164 for (size_t k = 0; k < scalarList.size(); k++) {165 for (size_t k = 0; k < scalarList.size(); k++) {
@@ -166,12 +167,12 @@ public:
166 }167 }
167 oss << "]";168 oss << "]";
168 result = oss.str();169 result = oss.str();
169- } else if (it->second.Type() == typeid(std::vector<bool>)) {170+ } else if (it->second.type() == typeid(std::vector<bool>)) {
170- auto scalarList = npu::tile_fwk::AnyCast<std::vector<bool>>(it->second);171+ auto scalarList = pypto::AnyCastRef<std::vector<bool>>(it->second);
171 result = IntVecToStr<bool>(scalarList);172 result = IntVecToStr<bool>(scalarList);
172 } else {173 } else {
173 result += "unsupported type ";174 result += "unsupported type ";
174- result += it->second.Type().name();175+ result += it->second.type().name();
175 }176 }
176 return result;177 return result;
177 }178 }
@@ -191,29 +192,29 @@ public:
191 if (iter != attributes.end()) {192 if (iter != attributes.end()) {
192 auto& second = iter->second;193 auto& second = iter->second;
193 try {194 try {
194- if (second.Type() == typeid(int64_t)) {195+ if (second.type() == typeid(int64_t)) {
195- return nlohmann::json(npu::tile_fwk::AnyCast<int64_t>(second));196+ return nlohmann::json(pypto::AnyCastRef<int64_t>(second));
196- } else if (second.Type() == typeid(std::vector<int64_t>)) {197+ } else if (second.type() == typeid(std::vector<int64_t>)) {
197- return nlohmann::json(npu::tile_fwk::AnyCast<std::vector<int64_t>>(second));198+ return nlohmann::json(pypto::AnyCastRef<std::vector<int64_t>>(second));
198- } else if (second.Type() == typeid(std::vector<float>)) {199+ } else if (second.type() == typeid(std::vector<float>)) {
199- return nlohmann::json(npu::tile_fwk::AnyCast<std::vector<float>>(second));200+ return nlohmann::json(pypto::AnyCastRef<std::vector<float>>(second));
200- } else if (second.Type() == typeid(std::vector<bool>)) {201+ } else if (second.type() == typeid(std::vector<bool>)) {
201- return nlohmann::json(npu::tile_fwk::AnyCast<std::vector<bool>>(second));202+ return nlohmann::json(pypto::AnyCastRef<std::vector<bool>>(second));
202- } else if (second.Type() == typeid(double)) {203+ } else if (second.type() == typeid(double)) {
203- return nlohmann::json(npu::tile_fwk::AnyCast<double>(second));204+ return nlohmann::json(pypto::AnyCastRef<double>(second));
204- } else if (second.Type() == typeid(float)) {205+ } else if (second.type() == typeid(float)) {
205- return nlohmann::json(npu::tile_fwk::AnyCast<float>(second));206+ return nlohmann::json(pypto::AnyCastRef<float>(second));
206- } else if (second.Type() == typeid(std::string)) {207+ } else if (second.type() == typeid(std::string)) {
207- return nlohmann::json(npu::tile_fwk::AnyCast<std::string>(second));208+ return nlohmann::json(pypto::AnyCastRef<std::string>(second));
208- } else if (second.Type() == typeid(bool)) {209+ } else if (second.type() == typeid(bool)) {
209- return nlohmann::json(npu::tile_fwk::AnyCast<bool>(second));210+ return nlohmann::json(pypto::AnyCastRef<bool>(second));
210- } else if (second.Type() == typeid(Element)) {211+ } else if (second.type() == typeid(Element)) {
211- return ToJson(npu::tile_fwk::AnyCast<Element>(second));212+ return ToJson(pypto::AnyCastRef<Element>(second));
212 } else {213 } else {
213 return nlohmann::json("Unsupported type");214 return nlohmann::json("Unsupported type");
214 }215 }
215 } catch (const std::bad_any_cast&) {216 } catch (const std::bad_any_cast&) {
216- std::cout << "Bad any cast" << second.Type().name();217+ std::cout << "Bad any cast" << second.type().name();
217 }218 }
218 }219 }
219 return nlohmann::json();220 return nlohmann::json();
@@ -1,52 +0,0 @@
1-/**
2- * Copyright (c) 2026 Huawei Technologies Co., Ltd.
3- * This program is free software, you can redistribute it and/or modify it under the terms and conditions of
4- * CANN Open Software License Agreement Version 2.0 (the "License").
5- * Please refer to the License for details. You may not use this file except in compliance with the License.
6- * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED,
7- * INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE.
8- * See LICENSE in the root of the software repository for the full text of the License.
9- */
10- 
11-/*!
12- * \file fake_trans_operation_impl.cpp
13- * \brief FakeTrans operation - connects input to output without processing.
14- * This op is a placeholder that will be replaced by a real op in the pass stage.
15- */
16- 
17-#include "interface/inner/pre_def.h"
18-#include "interface/configs/config_manager.h"
19-#include "interface/operation/operation.h"
20-#include "interface/operation/operation_common.h"
21-#include "interface/tensor/logical_tensor.h"
22-#include "interface/program/program.h"
23-#include "interface/utils/common.h"
24-#include "interface/utils/operator_tracer.h"
25-#include "operation_impl.h"
26-#include "tilefwk/error_code.h"
27-#include "tilefwk/data_type.h"
28-#include "tilefwk/tile_shape.h"
29-#include "tilefwk/platform.h"
30- 
31-namespace npu {
32-namespace tile_fwk {
33-namespace FakeTrans {
34- 
35-void ConstructTileGraph(
36- Function& function, const std::vector<LogicalTensorPtr>& operandVec, const LogicalTensorPtr& cTensorPtr)
37-{
38- function.AddOperation(Opcode::OP_FAKE_TRANS, {operandVec[0]}, {cTensorPtr});
39-}
40- 
41-Tensor FakeTrans(const Tensor& input, const Tensor& output)
42-{
43- DECLARE_TRACER();
44- Function* functionPtr = Program::GetInstance().GetCurrentFunction();
45- CHECK_OP(functionPtr != nullptr) << "No current function context.";
46- functionPtr->AddOperation(Opcode::OP_FAKE_TRANS, {input.GetStorage()}, {output.GetStorage()});
47- return Tensor(output.GetStorage());
48-}
49- 
50-} // namespace FakeTrans
51-} // namespace tile_fwk
52-} // namespace npu
@@ -19,7 +19,6 @@
19#include <sstream>19#include <sstream>
20#include <unordered_set>20#include <unordered_set>
21#include "interface/operation/operation.h"21#include "interface/operation/operation.h"
22-#include "interface/operation/verifier.h"
23#include "interface/utils/common.h"22#include "interface/utils/common.h"
24#include "tilefwk/data_type.h"23#include "tilefwk/data_type.h"
25#include "tilefwk/error.h"24#include "tilefwk/error.h"
@@ -25,7 +25,7 @@
25#include "tilefwk/error_code.h"25#include "tilefwk/error_code.h"
26#include "tilefwk/data_type.h"26#include "tilefwk/data_type.h"
27#include "tilefwk/error.h"27#include "tilefwk/error.h"
28-#include "verifier.h"28+ 
29namespace npu::tile_fwk {29namespace npu::tile_fwk {
30enum class Opcode {30enum class Opcode {
31 // Unary Vector31 // Unary Vector
@@ -385,6 +385,10 @@ enum class OpCalcType {
385};385};
386 386 
387enum class AIVCore;387enum class AIVCore;
388+class Function;
389+class Operation;
390+ 
391+using VerifyOperationEntry = std::function<bool(const Function& func, const Operation& op, std::ostream& oss)>;
388 392 
389class TileOpCfg {393class TileOpCfg {
390public:394public:
@@ -899,8 +903,8 @@ const std::unordered_set<Opcode> UNSUPPORT_FP16_OPS{
899 Opcode::OP_ADDS,903 Opcode::OP_ADDS,
900 Opcode::OP_SUBS,904 Opcode::OP_SUBS,
901 Opcode::OP_ADD,905 Opcode::OP_ADD,
902- Opcode::OP_SUB, 906+ Opcode::OP_SUB,
903- Opcode::OP_MOD, 907+ Opcode::OP_MOD,
904 Opcode::OP_MODS};908 Opcode::OP_MODS};
905 909 
906const std::unordered_set<Opcode> UNSUPPORT_FP16_ARCH35_OPS{910const std::unordered_set<Opcode> UNSUPPORT_FP16_ARCH35_OPS{
@@ -1011,7 +1015,7 @@ const std::unordered_set<Opcode> UNSUPPORT_BF16_ARCH35_OPS{
1011 Opcode::OP_ADDS,1015 Opcode::OP_ADDS,
1012 Opcode::OP_SUBS,1016 Opcode::OP_SUBS,
1013 Opcode::OP_ADD,1017 Opcode::OP_ADD,
1014- Opcode::OP_SUB, 1018+ Opcode::OP_SUB,
1015 Opcode::OP_INDEX_ADD,1019 Opcode::OP_INDEX_ADD,
1016 Opcode::OP_EXP,1020 Opcode::OP_EXP,
1017 Opcode::OP_RSQRT,1021 Opcode::OP_RSQRT,
@@ -383,7 +383,7 @@ void Operation::SetAttribute(const std::string& key, const std::vector<Element>&
383 383 
384void Operation::SetAttribute(const std::string& key, Element value) { SetAttr(key, value); }384void Operation::SetAttribute(const std::string& key, Element value) { SetAttr(key, value); }
385 385 
386-std::map<std::string, npu::tile_fwk::Any> Operation::GetAllAttribute() const { return GetAllAttr(); }386+std::map<std::string, std::any> Operation::GetAllAttribute() const { return GetAllAttr(); }
387 387 
388void DebugJson(const Json& j)388void DebugJson(const Json& j)
389{389{
@@ -1213,7 +1213,7 @@ std::vector<std::reference_wrapper<SymbolicScalar>> Operation::GetDynamicAttribu
1213 auto& attrDict = GetAllAttr();1213 auto& attrDict = GetAllAttr();
1214 auto it = attrDict.find(OpAttributeKey::bindTensor);1214 auto it = attrDict.find(OpAttributeKey::bindTensor);
1215 if (it != attrDict.end()) {1215 if (it != attrDict.end()) {
1216- auto& value = *npu::tile_fwk::AnyCast<SymbolicScalar>(&it->second);1216+ auto& value = pypto::AnyCastRef<SymbolicScalar>(it->second);
1217 dynamicAttributeList.push_back(std::reference_wrapper<SymbolicScalar>(value));1217 dynamicAttributeList.push_back(std::reference_wrapper<SymbolicScalar>(value));
1218 }1218 }
1219 } break;1219 } break;
@@ -22,7 +22,6 @@
22#include <unordered_set>22#include <unordered_set>
23#include <variant>23#include <variant>
24#include <nlohmann/json.hpp>24#include <nlohmann/json.hpp>
25-#include "interface/inner/any.h"
26#include "interface/inner/pre_def.h"25#include "interface/inner/pre_def.h"
27#include "tilefwk/tilefwk_op.h"26#include "tilefwk/tilefwk_op.h"
28#include "interface/configs/config_manager.h"27#include "interface/configs/config_manager.h"
@@ -374,7 +373,7 @@ public:
374 373 
375 [[nodiscard]] bool HasAttribute(const std::string& key) const { return HasAttr(key); }374 [[nodiscard]] bool HasAttribute(const std::string& key) const { return HasAttr(key); }
376 375 
377- [[nodiscard]] std::map<std::string, npu::tile_fwk::Any> GetAllAttribute() const;376+ [[nodiscard]] std::map<std::string, std::any> GetAllAttribute() const;
378 377 
379 Json DumpJson(bool dumpTensor = true) const;378 Json DumpJson(bool dumpTensor = true) const;
380 static std::shared_ptr<Operation> LoadJson(379 static std::shared_ptr<Operation> LoadJson(
@@ -1656,7 +1656,7 @@ void ExpandOperationInto(
1656 break;1656 break;
1657 }1657 }
1658 case Opcode::OP_FAKE_TRANS: {1658 case Opcode::OP_FAKE_TRANS: {
1659- FakeTrans::ConstructTileGraph(function, iOperand, oOperand[0]);1659+ function.AddOperation(Opcode::OP_FAKE_TRANS, iOperand, oOperand);
1660 break;1660 break;
1661 }1661 }
1662 case Opcode::OP_TOPK_SORT: {1662 case Opcode::OP_TOPK_SORT: {
@@ -377,12 +377,4 @@ void ConstructTileGraph(
377 const LogicalTensorPtr& cTensorPtr, const Operation& op);377 const LogicalTensorPtr& cTensorPtr, const Operation& op);
378 378 
379} // namespace Conv379} // namespace Conv
380- 
381-namespace FakeTrans {
382- 
383-void ConstructTileGraph(
384- Function& function, const std::vector<LogicalTensorPtr>& operandVec, const LogicalTensorPtr& cTensorPtr);
385- 
386-} // namespace FakeTrans
387- 
388} // namespace npu::tile_fwk380} // namespace npu::tile_fwk
@@ -1,30 +0,0 @@
1-/**
2- * Copyright (c) 2025 Huawei Technologies Co., Ltd.
3- * This program is free software, you can redistribute it and/or modify it under the terms and conditions of
4- * CANN Open Software License Agreement Version 2.0 (the "License").
5- * Please refer to the License for details. You may not use this file except in compliance with the License.
6- * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED,
7- * INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE.
8- * See LICENSE in the root of the software repository for the full text of the License.
9- */
10- 
11-/*!
12- * \file verifier.h
13- * \brief
14- */
15- 
16-#include <ostream>
17- 
18-namespace npu::tile_fwk {
19-class Function;
20-class Operation;
21-/**
22- * \brief Entry for verifying operation
23- *
24- * \param func : the function that contains the operation.
25- * \param op : the target operation.
26- * \param oss : stream printer
27- * \return bool : true means success. false means failure.
28- */
29-using VerifyOperationEntry = std::function<bool(const Function& func, const Operation& op, std::ostream& oss)>;
30-} // namespace npu::tile_fwk
@@ -243,12 +243,12 @@ std::vector<std::reference_wrapper<SymbolicScalar>> DynAttrToStatic::GetOpDynami
243 auto& attrDict = op.GetAllAttr();243 auto& attrDict = op.GetAllAttr();
244 auto it = attrDict.find(OpAttributeKey::dynScalar);244 auto it = attrDict.find(OpAttributeKey::dynScalar);
245 if (it != attrDict.end()) {245 if (it != attrDict.end()) {
246- auto& value = *npu::tile_fwk::AnyCast<SymbolicScalar>(&it->second);246+ auto& value = pypto::AnyCastRef<SymbolicScalar>(it->second);
247 dynamicAttributeList.push_back(std::reference_wrapper<SymbolicScalar>(value));247 dynamicAttributeList.push_back(std::reference_wrapper<SymbolicScalar>(value));
248 }248 }
249 it = attrDict.find(OpAttributeKey::transDataOffset);249 it = attrDict.find(OpAttributeKey::transDataOffset);
250 if (it != attrDict.end()) {250 if (it != attrDict.end()) {
251- auto& values = *npu::tile_fwk::AnyCast<std::vector<SymbolicScalar>>(&it->second);251+ auto& values = pypto::AnyCastRef<std::vector<SymbolicScalar>>(it->second);
252 for (auto& value : values) {252 for (auto& value : values) {
253 dynamicAttributeList.push_back(std::reference_wrapper<SymbolicScalar>(value));253 dynamicAttributeList.push_back(std::reference_wrapper<SymbolicScalar>(value));
254 }254 }
@@ -35,9 +35,9 @@ public:
35 std::vector<SymbolicScalar> dynValidShape;35 std::vector<SymbolicScalar> dynValidShape;
36 MemoryType toType = MemoryType::MEM_UNKNOWN;36 MemoryType toType = MemoryType::MEM_UNKNOWN;
37 bool hasCopyInMode; // 是否有copy_in_mode属性37 bool hasCopyInMode; // 是否有copy_in_mode属性
38- npu::tile_fwk::Any copyInModeValue; // copy_in_mode属性值38+ std::any copyInModeValue; // copy_in_mode属性值
39- bool hasL1PaddingMode; // 是否有copy_in_l1_padding_mode属性39+ bool hasL1PaddingMode; // 是否有copy_in_l1_padding_mode属性
40- npu::tile_fwk::Any l1PaddingMode; // copy_in_l1_padding_mode属性值40+ std::any l1PaddingMode; // copy_in_l1_padding_mode属性值
41 ir::Span span; // 链路最早操作的span41 ir::Span span; // 链路最早操作的span
42 Operation::ScopeInfo scopeInfo;42 Operation::ScopeInfo scopeInfo;
43 };43 };
@@ -214,11 +214,11 @@ TEST_F(TestConfigManager, GlobalConfig)
214 EXPECT_EQ(res_bool, true);214 EXPECT_EQ(res_bool, true);
215 215 
216 // // add code for coverage, python pybind interface216 // // add code for coverage, python pybind interface
217- std::map<std::string, Any> config_values = {{"simulation.timeout_threshold", 10}};217+ std::map<std::string, std::any> config_values = {{"simulation.timeout_threshold", 10}};
218 ConfigManagerNg::GetInstance().SetGlobalConfig(std::move(config_values), "default", 1);218 ConfigManagerNg::GetInstance().SetGlobalConfig(std::move(config_values), "default", 1);
219 ConfigManagerNg::GetInstance().GlobalScope();219 ConfigManagerNg::GetInstance().GlobalScope();
220 220 
221- std::map<std::string, Any> empty_values = {};221+ std::map<std::string, std::any> empty_values = {};
222 ConfigManagerNg::GetInstance().SetGlobalConfig(std::move(empty_values), "default", 1);222 ConfigManagerNg::GetInstance().SetGlobalConfig(std::move(empty_values), "default", 1);
223 223 
224 PrintOptions p = config::GetPrintOptions();224 PrintOptions p = config::GetPrintOptions();
@@ -245,7 +245,7 @@ TEST_F(TestConfigManager, JitScopeGuardBasic)
245 auto& cm = ConfigManagerNg::GetInstance();245 auto& cm = ConfigManagerNg::GetInstance();
246 auto scopeBefore = cm.CurrentScope();246 auto scopeBefore = cm.CurrentScope();
247 {247 {
248- ConfigManagerNg::JitScopeGuard guard("jit_scope", std::map<std::string, Any>{});248+ ConfigManagerNg::JitScopeGuard guard("jit_scope", std::map<std::string, std::any>{});
249 auto scopeInGuard = cm.CurrentScope();249 auto scopeInGuard = cm.CurrentScope();
250 EXPECT_NE(scopeInGuard.get(), scopeBefore.get());250 EXPECT_NE(scopeInGuard.get(), scopeBefore.get());
251 EXPECT_TRUE(scopeInGuard->HasConfig("pass.pg_lower_bound"));251 EXPECT_TRUE(scopeInGuard->HasConfig("pass.pg_lower_bound"));
@@ -258,7 +258,7 @@ TEST_F(TestConfigManager, IsWithinRangeInvalidKey)
258{258{
259 auto& cm = ConfigManagerNg::GetInstance();259 auto& cm = ConfigManagerNg::GetInstance();
260 auto scope = cm.CurrentScope();260 auto scope = cm.CurrentScope();
261- Any value = int64_t(100);261+ std::any value = int64_t(100);
262 scope->UpdateValueWithAny("invalid.key.not.in.scope", int64_t(100));262 scope->UpdateValueWithAny("invalid.key.not.in.scope", int64_t(100));
263 EXPECT_EQ(cm.IsWithinRange("invalid.key.not.in.schema", value), false);263 EXPECT_EQ(cm.IsWithinRange("invalid.key.not.in.schema", value), false);
264}264}
@@ -1,369 +0,0 @@
1-/**
2- * Copyright (c) 2026 Huawei Technologies Co., Ltd.
3- * This program is free software, you can redistribute it and/or modify it under the terms and conditions of
4- * CANN Open Software License Agreement Version 2.0 (the "License").
5- * Please refer to the License for details. You may not use this file except in compliance with the License.
6- * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED,
7- * INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE.
8- * See LICENSE in the root of the software repository for the full text of the License.
9- */
10- 
11-/*!
12- * \file test_common.cpp
13- * \brief Unit tests for core common definitions
14- */
15- 
16-#include "gtest/gtest.h"
17- 
18-#include <cstdint>
19-#include <string>
20- 
21-#include "core/common.h"
22- 
23-namespace pypto {
24- 
25-// ============================================================================
26-// Version Information Tests
27-// ============================================================================
28- 
29-TEST(CoreCommonTest, TestVersionMajor)
30-{
31- // Test that PYPTO_VERSION_MAJOR is defined and has expected value
32- ASSERT_EQ(PYPTO_VERSION_MAJOR, 0);
33-}
34- 
35-TEST(CoreCommonTest, TestVersionMinor)
36-{
37- // Test that PYPTO_VERSION_MINOR is defined and has expected value
38- ASSERT_EQ(PYPTO_VERSION_MINOR, 1);
39-}
40- 
41-TEST(CoreCommonTest, TestVersionPatch)
42-{
43- // Test that PYPTO_VERSION_PATCH is defined and has expected value
44- ASSERT_EQ(PYPTO_VERSION_PATCH, 0);
45-}
46- 
47-TEST(CoreCommonTest, TestVersionNumbers)
48-{
49- // Test that version numbers are non-negative
50- ASSERT_GE(PYPTO_VERSION_MAJOR, 0);
51- ASSERT_GE(PYPTO_VERSION_MINOR, 0);
52- ASSERT_GE(PYPTO_VERSION_PATCH, 0);
53-}
54- 
55-// ============================================================================
56-// IR Constants Tests
57-// ============================================================================
58- 
59-TEST(CoreCommonTest, TestDynamicDimValue)
60-{
61- // Test that kDynamicDim has the expected value
62- ASSERT_EQ(kDynamicDim, -1);
63-}
64- 
65-TEST(CoreCommonTest, TestDynamicDimType)
66-{
67- // Test that kDynamicDim is of type int64_t
68- static_assert(std::is_same<decltype(kDynamicDim), const int64_t>::value, "kDynamicDim should be int64_t");
69- ASSERT_TRUE(true); // Compile-time check
70-}
71- 
72-TEST(CoreCommonTest, TestDynamicDimUsage)
73-{
74- // Test using kDynamicDim in comparisons
75- int64_t dim = kDynamicDim;
76- ASSERT_EQ(dim, -1);
77- ASSERT_LT(dim, 0);
78- ASSERT_NE(dim, 0);
79-}
80- 
81-TEST(CoreCommonTest, TestDynamicDimInArray)
82-{
83- // Test using kDynamicDim in array/vector
84- int64_t dims[] = {10, 20, kDynamicDim, 30};
85- ASSERT_EQ(dims[2], -1);
86- ASSERT_EQ(dims[2], kDynamicDim);
87-}
88- 
89-// ============================================================================
90-// Nanobind Module Configuration Tests
91-// ============================================================================
92- 
93-TEST(CoreCommonTest, TestNanobindModuleDoc)
94-{
95- // Test that PYPTO_NANOBIND_MODULE_DOC is defined
96- std::string doc = PYPTO_NANOBIND_MODULE_DOC;
97- ASSERT_FALSE(doc.empty());
98- ASSERT_EQ(doc, "PyPTO core library");
99-}
100- 
101-TEST(CoreCommonTest, TestNanobindModuleDocLength)
102-{
103- // Test that module doc has reasonable length
104- std::string doc = PYPTO_NANOBIND_MODULE_DOC;
105- ASSERT_GT(doc.length(), 0);
106- ASSERT_LT(doc.length(), 1000); // Reasonable upper bound
107-}
108- 
109-// ============================================================================
110-// Compiler Hints and Attributes Tests
111-// ============================================================================
112- 
113-TEST(CoreCommonTest, TestAlwaysInlineMacro)
114-{
115- // Test that PYPTO_ALWAYS_INLINE is defined
116- // This is a compile-time test - if it compiles, the macro exists
117- auto testFunc = []() PYPTO_ALWAYS_INLINE { return 42; };
118- ASSERT_EQ(testFunc(), 42);
119-}
120- 
121-TEST(CoreCommonTest, TestUnusedMacro)
122-{
123- // Test that PYPTO_UNUSED is defined
124- // This is a compile-time test - if it compiles, the macro exists
125- PYPTO_UNUSED int unusedVar = 100;
126- ASSERT_TRUE(true); // If we get here, the macro worked
127-}
128- 
129-TEST(CoreCommonTest, TestStrConcatMacro)
130-{
131-// Test PYPTO_STR_CONCAT macro
132-#define TEST_PREFIX test_
133-#define TEST_SUFFIX value
134- 
135- // This should concatenate to test_value
136- int PYPTO_STR_CONCAT(TEST_PREFIX, TEST_SUFFIX) = 42;
137- ASSERT_EQ(test_value, 42);
138- 
139-#undef TEST_PREFIX
140-#undef TEST_SUFFIX
141-}
142- 
143-TEST(CoreCommonTest, TestStrConcatWithNumbers)
144-{
145-// Test PYPTO_STR_CONCAT with numbers
146-#define VAR var_
147- int PYPTO_STR_CONCAT(VAR, 1) = 10;
148- int PYPTO_STR_CONCAT(VAR, 2) = 20;
149- int PYPTO_STR_CONCAT(VAR, 3) = 30;
150- 
151- ASSERT_EQ(var_1, 10);
152- ASSERT_EQ(var_2, 20);
153- ASSERT_EQ(var_3, 30);
154- 
155-#undef VAR
156-}
157- 
158-// ============================================================================
159-// Macro Expansion Tests
160-// ============================================================================
161- 
162-TEST(CoreCommonTest, TestStrConcatImplMacro)
163-{
164- // Test PYPTO_STR_CONCAT_IMPL (internal implementation)
165- // Note: PYPTO_STR_CONCAT_IMPL does not expand macros, it directly concatenates tokens
166- int PYPTO_STR_CONCAT_IMPL(foo, bar) = 123;
167- ASSERT_EQ(foobar, 123);
168-}
169- 
170-TEST(CoreCommonTest, TestNestedMacroExpansion)
171-{
172-// Test nested macro expansion with PYPTO_STR_CONCAT
173-#define OUTER outer_
174-#define INNER inner
175- 
176- int PYPTO_STR_CONCAT(PYPTO_STR_CONCAT(OUTER, INNER), _value) = 456;
177- ASSERT_EQ(outer_inner_value, 456);
178- 
179-#undef OUTER
180-#undef INNER
181-}
182- 
183-// ============================================================================
184-// Constant Value Range Tests
185-// ============================================================================
186- 
187-TEST(CoreCommonTest, TestDynamicDimRange)
188-{
189- // Test that kDynamicDim is in valid range for int64_t
190- ASSERT_GE(kDynamicDim, std::numeric_limits<int64_t>::min());
191- ASSERT_LE(kDynamicDim, std::numeric_limits<int64_t>::max());
192-}
193- 
194-TEST(CoreCommonTest, TestDynamicDimDistinctFromZero)
195-{
196- // Test that kDynamicDim is distinct from 0 (valid dimension)
197- ASSERT_NE(kDynamicDim, 0);
198-}
199- 
200-TEST(CoreCommonTest, TestDynamicDimDistinctFromPositive)
201-{
202- // Test that kDynamicDim is distinct from positive dimensions
203- ASSERT_NE(kDynamicDim, 1);
204- ASSERT_NE(kDynamicDim, 10);
205- ASSERT_NE(kDynamicDim, 100);
206- ASSERT_NE(kDynamicDim, 1000);
207-}
208- 
209-// ============================================================================
210-// Practical Usage Tests
211-// ============================================================================
212- 
213-TEST(CoreCommonTest, TestDynamicDimInConditional)
214-{
215- // Test using kDynamicDim in conditional logic
216- auto isDynamic = [](int64_t dim) { return dim == kDynamicDim; };
217- 
218- ASSERT_TRUE(isDynamic(kDynamicDim));
219- ASSERT_TRUE(isDynamic(-1));
220- ASSERT_FALSE(isDynamic(0));
221- ASSERT_FALSE(isDynamic(10));
222-}
223- 
224-TEST(CoreCommonTest, TestDynamicDimInSwitch)
225-{
226- // Test using kDynamicDim in switch statement
227- auto classifyDim = [](int64_t dim) -> std::string {
228- if (dim == kDynamicDim) {
229- return "dynamic";
230- } else if (dim == 0) {
231- return "zero";
232- } else if (dim > 0) {
233- return "positive";
234- } else {
235- return "negative";
236- }
237- };
238- 
239- ASSERT_EQ(classifyDim(kDynamicDim), "dynamic");
240- ASSERT_EQ(classifyDim(-1), "dynamic");
241- ASSERT_EQ(classifyDim(0), "zero");
242- ASSERT_EQ(classifyDim(10), "positive");
243- ASSERT_EQ(classifyDim(-5), "negative");
244-}
245- 
246-TEST(CoreCommonTest, TestVersionComparison)
247-{
248- // Test version comparison logic
249- auto versionCode = PYPTO_VERSION_MAJOR * 10000 + PYPTO_VERSION_MINOR * 100 + PYPTO_VERSION_PATCH;
250- 
251- ASSERT_EQ(versionCode, 100); // 0.1.0 = 100
252-}
253- 
254-TEST(CoreCommonTest, TestVersionString)
255-{
256-// Test constructing version string
257-#define STRINGIFY(x) #x
258-#define TOSTRING(x) STRINGIFY(x)
259- 
260- std::string version = std::string(TOSTRING(PYPTO_VERSION_MAJOR)) + "." +
261- std::string(TOSTRING(PYPTO_VERSION_MINOR)) + "." + std::string(TOSTRING(PYPTO_VERSION_PATCH));
262- 
263- ASSERT_EQ(version, "0.1.0");
264- 
265-#undef STRINGIFY
266-#undef TOSTRING
267-}
268- 
269-// ============================================================================
270-// Attribute Application Tests
271-// ============================================================================
272- 
273-TEST(CoreCommonTest, TestAlwaysInlineFunction)
274-{
275- // Test function with PYPTO_ALWAYS_INLINE attribute
276- auto inlineFunc = []() PYPTO_ALWAYS_INLINE -> int { return 42; };
277- 
278- int result = inlineFunc();
279- ASSERT_EQ(result, 42);
280-}
281- 
282-TEST(CoreCommonTest, TestUnusedVariable)
283-{
284- // Test that PYPTO_UNUSED suppresses warnings
285- PYPTO_UNUSED int x = 10;
286- PYPTO_UNUSED double y = 3.14;
287- PYPTO_UNUSED bool z = true;
288- 
289- // If we get here without warnings, the attribute works
290- ASSERT_TRUE(true);
291-}
292- 
293-TEST(CoreCommonTest, TestUnusedParameter)
294-{
295- // Test PYPTO_UNUSED with function parameters
296- auto func = [](PYPTO_UNUSED int param) { return 100; };
297- 
298- int result = func(42);
299- ASSERT_EQ(result, 100);
300-}
301- 
302-// ============================================================================
303-// Edge Cases Tests
304-// ============================================================================
305- 
306-TEST(CoreCommonTest, TestDynamicDimArithmetic)
307-{
308- // Test arithmetic with kDynamicDim
309- int64_t result1 = kDynamicDim + 1;
310- int64_t result2 = kDynamicDim * 2;
311- int64_t result3 = -kDynamicDim;
312- 
313- ASSERT_EQ(result1, 0);
314- ASSERT_EQ(result2, -2);
315- ASSERT_EQ(result3, 1);
316-}
317- 
318-TEST(CoreCommonTest, TestDynamicDimComparison)
319-{
320- // Test comparison operations with kDynamicDim
321- ASSERT_TRUE(kDynamicDim < 0);
322- ASSERT_TRUE(kDynamicDim <= -1);
323- ASSERT_TRUE(kDynamicDim <= 0);
324- ASSERT_FALSE(kDynamicDim > 0);
325- ASSERT_FALSE(kDynamicDim >= 0);
326-}
327- 
328-TEST(CoreCommonTest, TestMultipleDynamicDims)
329-{
330- // Test multiple dynamic dimensions
331- int64_t dims[] = {kDynamicDim, kDynamicDim, kDynamicDim};
332- 
333- for (int i = 0; i < 3; ++i) {
334- ASSERT_EQ(dims[i], kDynamicDim);
335- }
336-}
337- 
338-TEST(CoreCommonTest, TestMixedDimensions)
339-{
340- // Test mixed static and dynamic dimensions
341- int64_t dims[] = {10, kDynamicDim, 20, kDynamicDim, 30};
342- 
343- ASSERT_EQ(dims[0], 10);
344- ASSERT_EQ(dims[1], kDynamicDim);
345- ASSERT_EQ(dims[2], 20);
346- ASSERT_EQ(dims[3], kDynamicDim);
347- ASSERT_EQ(dims[4], 30);
348-}
349- 
350-// ============================================================================
351-// Namespace Tests
352-// ============================================================================
353- 
354-TEST(CoreCommonTest, TestNamespaceScope)
355-{
356- // Test that constants are in pypto namespace
357- int64_t dim = pypto::kDynamicDim;
358- ASSERT_EQ(dim, -1);
359-}
360- 
361-TEST(CoreCommonTest, TestConstantAccessibility)
362-{
363- // Test that constants are accessible without namespace prefix (when using namespace)
364- using namespace pypto;
365- int64_t dim = kDynamicDim;
366- ASSERT_EQ(dim, -1);
367-}
368- 
369-} // namespace pypto
@@ -211,7 +211,7 @@ void BindControllerUtils(py::module_& m)
211 m.def("ClearSpan", &ir::Span::ClearCurrent);211 m.def("ClearSpan", &ir::Span::ClearCurrent);
212}212}
213 213 
214-npu::tile_fwk::Any ConvertPyList(const std::string& key, const py::list& lst)214+std::any ConvertPyList(const std::string& key, const py::list& lst)
215{215{
216 if (lst.size() == 0) {216 if (lst.size() == 0) {
217 return std::vector<int64_t>();217 return std::vector<int64_t>();
@@ -296,7 +296,7 @@ static void ClassifyKeys(const py::dict& dict_value, bool& has_int, bool& has_st
296 296 
297static void HandleStrOnlyKeys(297static void HandleStrOnlyKeys(
298 const std::string& key, const py::dict& dict_value, bool has_func, bool has_label,298 const std::string& key, const py::dict& dict_value, bool has_func, bool has_label,
299- std::map<std::string, npu::tile_fwk::Any>& cpp_values)299+ std::map<std::string, std::any>& cpp_values)
300{300{
301 cpp_values[key] = std::map<int64_t, int64_t>();301 cpp_values[key] = std::map<int64_t, int64_t>();
302 if (has_func && has_label) {302 if (has_func && has_label) {
@@ -320,7 +320,7 @@ static void HandleStrOnlyKeys(
320}320}
321 321 
322static void HandleMixedKeys(322static void HandleMixedKeys(
323- const std::string& key, const py::dict& dict_value, std::map<std::string, npu::tile_fwk::Any>& cpp_values)323+ const std::string& key, const py::dict& dict_value, std::map<std::string, std::any>& cpp_values)
324{324{
325 std::map<int64_t, int64_t> int_map;325 std::map<int64_t, int64_t> int_map;
326 std::map<std::string, int64_t> func_map, label_map;326 std::map<std::string, int64_t> func_map, label_map;
@@ -347,7 +347,7 @@ static void HandleMixedKeys(
347}347}
348 348 
349void ConvertPyDict(349void ConvertPyDict(
350- const std::string& key, const py::object& value, std::map<std::string, npu::tile_fwk::Any>& cpp_values)350+ const std::string& key, const py::object& value, std::map<std::string, std::any>& cpp_values)
351{351{
352 py::dict dict_value = py::cast<py::dict>(value);352 py::dict dict_value = py::cast<py::dict>(value);
353 bool has_int = false, has_str = false, has_func = false, has_label = false;353 bool has_int = false, has_str = false, has_func = false, has_label = false;
@@ -362,7 +362,7 @@ void ConvertPyDict(
362 }362 }
363}363}
364 364 
365-npu::tile_fwk::Any ConvertPyValue(const std::string& key, const py::object& value)365+std::any ConvertPyValue(const std::string& key, const py::object& value)
366{366{
367 if (py::isinstance<py::bool_>(value)) {367 if (py::isinstance<py::bool_>(value)) {
368 return value.cast<bool>();368 return value.cast<bool>();
@@ -384,9 +384,9 @@ npu::tile_fwk::Any ConvertPyValue(const std::string& key, const py::object& valu
384 throw py::type_error("Unsupported value type for key: " + key);384 throw py::type_error("Unsupported value type for key: " + key);
385}385}
386 386 
387-std::map<std::string, npu::tile_fwk::Any> ConvertPyDictToCppMap(const py::dict& values)387+std::map<std::string, std::any> ConvertPyDictToCppMap(const py::dict& values)
388{388{
389- std::map<std::string, npu::tile_fwk::Any> cpp_values;389+ std::map<std::string, std::any> cpp_values;
390 for (auto item : values) {390 for (auto item : values) {
391 std::string key = py::str(item.first);391 std::string key = py::str(item.first);
392 py::object value = py::reinterpret_borrow<py::object>(item.second);392 py::object value = py::reinterpret_borrow<py::object>(item.second);
@@ -454,31 +454,31 @@ void BindControllerScope(py::module_& m)
454 m.def("GetOptionsTree", []() { return ConfigManagerNg::GetInstance().GetOptionsTree(); });454 m.def("GetOptionsTree", []() { return ConfigManagerNg::GetInstance().GetOptionsTree(); });
455}455}
456 456 
457-py::object AnyToPyObject(const Any& val)457+py::object AnyToPyObject(const std::any& val)
458{458{
459- using Fn = std::function<py::object(const Any&)>;459+ using Fn = std::function<py::object(const std::any&)>;
460 static const std::unordered_map<std::type_index, Fn> table = {460 static const std::unordered_map<std::type_index, Fn> table = {
461- {typeid(bool), [](const Any& a) { return py::cast(AnyCast<bool>(a)); }},461+ {typeid(bool), [](const std::any& a) { return py::cast(AnyCast<bool>(a)); }},
462- {typeid(int64_t), [](const Any& a) { return py::cast(AnyCast<int64_t>(a)); }},462+ {typeid(int64_t), [](const std::any& a) { return py::cast(AnyCast<int64_t>(a)); }},
463- {typeid(double), [](const Any& a) { return py::cast(AnyCast<double>(a)); }},463+ {typeid(double), [](const std::any& a) { return py::cast(AnyCast<double>(a)); }},
464- {typeid(std::string), [](const Any& a) { return py::cast(AnyCast<std::string>(a)); }},464+ {typeid(std::string), [](const std::any& a) { return py::cast(AnyCast<std::string>(a)); }},
465- {typeid(std::vector<int64_t>), [](const Any& a) { return py::cast(AnyCast<std::vector<int64_t>>(a)); }},465+ {typeid(std::vector<int64_t>), [](const std::any& a) { return py::cast(AnyCast<std::vector<int64_t>>(a)); }},
466- {typeid(std::vector<std::string>), [](const Any& a) { return py::cast(AnyCast<std::vector<std::string>>(a)); }},466+ {typeid(std::vector<std::string>), [](const std::any& a) { return py::cast(AnyCast<std::vector<std::string>>(a)); }},
467- {typeid(std::vector<double>), [](const Any& a) { return py::cast(AnyCast<std::vector<double>>(a)); }},467+ {typeid(std::vector<double>), [](const std::any& a) { return py::cast(AnyCast<std::vector<double>>(a)); }},
468 {typeid(std::map<int64_t, int64_t>),468 {typeid(std::map<int64_t, int64_t>),
469- [](const Any& a) { return py::cast(AnyCast<std::map<int64_t, int64_t>>(a)); }},469+ [](const std::any& a) { return py::cast(AnyCast<std::map<int64_t, int64_t>>(a)); }},
470 {typeid(std::map<std::string, int64_t>),470 {typeid(std::map<std::string, int64_t>),
471- [](const Any& a) { return py::cast(AnyCast<std::map<std::string, int64_t>>(a)); }},471+ [](const std::any& a) { return py::cast(AnyCast<std::map<std::string, int64_t>>(a)); }},
472- {typeid(CubeTile), [](const Any& a) { return py::cast(AnyCast<CubeTile>(a)); }},472+ {typeid(CubeTile), [](const std::any& a) { return py::cast(AnyCast<CubeTile>(a)); }},
473- {typeid(ConvTile), [](const Any& a) { return py::cast(AnyCast<ConvTile>(a)); }},473+ {typeid(ConvTile), [](const std::any& a) { return py::cast(AnyCast<ConvTile>(a)); }},
474- {typeid(DistTile), [](const Any& a) { return py::str(AnyCast<DistTile>(a).ToString()); }},474+ {typeid(DistTile), [](const std::any& a) { return py::str(AnyCast<DistTile>(a).ToString()); }},
475 };475 };
476 476 
477- auto it = table.find(std::type_index(val.Type()));477+ auto it = table.find(std::type_index(val.type()));
478 if (it != table.end())478 if (it != table.end())
479 return it->second(val);479 return it->second(val);
480 480 
481- throw py::type_error("Unsupported config value type: " + std::string(val.Type().name()));481+ throw py::type_error("Unsupported config value type: " + std::string(val.type().name()));
482}482}
483 483 
484void BindControllerScopeClasses(py::module_& m)484void BindControllerScopeClasses(py::module_& m)
@@ -1233,7 +1233,7 @@ private:
1233 if (kbinary)1233 if (kbinary)
1234 return kbinary;1234 return kbinary;
1235 1235 
1236- jitScopeGuard.emplace("jit_scope", std::map<std::string, Any>{});1236+ jitScopeGuard.emplace("jit_scope", std::map<std::string, std::any>{});
1237 Program::GetInstance().Reset();1237 Program::GetInstance().Reset();
1238 AclModeGuard guard(AclMdlRICaptureMode::RELAXED);1238 AclModeGuard guard(AclMdlRICaptureMode::RELAXED);
1239#if ENABLE_VERBOSE_LOG1239#if ENABLE_VERBOSE_LOG