masahi commented on code in PR #14574: URL: https://github.com/apache/tvm/pull/14574#discussion_r1191959520
########## include/tvm/ir/si_builder.h: ########## @@ -0,0 +1,103 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you 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. + */ + +/*! + * \file tvm/ir/si_builder.h + * \brief build a source info during rewriting expressions. + */ +#ifndef TVM_IR_SI_BUILDER_H_ +#define TVM_IR_SI_BUILDER_H_ + +#include <tvm/relay/expr.h> +#include <tvm/relay/expr_functor.h> +#include <tvm/tir/stmt.h> + +#include <memory> +#include <unordered_set> + +namespace tvm { + +/*! + * \brief SIBuilder provides helper APIs for filling spans, + * particularly useful for one-to-many, many-to-one and many-to-many pass transformations. Review Comment: pass transformations -> IR transformations? ########## include/tvm/ir/si_builder.h: ########## @@ -0,0 +1,103 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you 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. + */ + +/*! + * \file tvm/ir/si_builder.h + * \brief build a source info during rewriting expressions. + */ +#ifndef TVM_IR_SI_BUILDER_H_ +#define TVM_IR_SI_BUILDER_H_ + +#include <tvm/relay/expr.h> +#include <tvm/relay/expr_functor.h> +#include <tvm/tir/stmt.h> + +#include <memory> +#include <unordered_set> + +namespace tvm { + +/*! + * \brief SIBuilder provides helper APIs for filling spans, + * particularly useful for one-to-many, many-to-one and many-to-many pass transformations. + */ +class SIBuilder { Review Comment: Please document what "SI" stands for ########## src/ir/si_builder.cc: ########## @@ -0,0 +1,341 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you 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. + */ + +/*! + * \file tvm/ir/si_builder.cc + * \brief Implementation for building a source info during rewriting expressions. + */ +#include <tvm/ir/si_builder.h> +#include <tvm/ir/transform.h> +#include <tvm/tir/stmt_functor.h> + +#include <vector> + +namespace tvm { + +using RelayExprSet = std::unordered_set<relay::Expr, ObjectPtrHash, ObjectPtrEqual>; +using PrimExprSet = std::unordered_set<PrimExpr, ObjectPtrHash, ObjectPtrEqual>; +using StmtSet = std::unordered_set<tir::Stmt, ObjectPtrHash, ObjectPtrEqual>; + +class RelayCollapse : public relay::ExprVisitor { + public: + explicit RelayCollapse(const RelayExprSet& inputs = {}) : inputs_(inputs) {} + + Span Collapse(const relay::Expr& entry); Review Comment: Please document what `Collapse` and `Fill` mean in this file -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
