mbs-octoml commented on a change in pull request #9689: URL: https://github.com/apache/tvm/pull/9689#discussion_r766111239
########## File path: src/tir/analysis/device_constraint_utils.h ########## @@ -0,0 +1,85 @@ +/* + * 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 tir/analysis/device_constraint_utils.cc + * \brief Utilities for extracting and applying device-related constraints to \p PrimFunc + * parameters. + * + * These utilities are used by the \p PlanDevices pass to extract memory (aka 'storage') scope + * information from \p PrimFuncs and convert them back into \p SEScope form w.r.t. the original + * Relay type of the \p PrimFunc (ie before flattening of tuple arguments/results and conversion + * to destination-passing style aka DPS). + * + * A utility is also supplied to go the other way: impose memory scopes on \p PrimFunc parameters. + * However that's still in EXPERIMENTAL form. + * + * We may extend these utilities to also gather/apply layout information should we add that to + * \p SEScope. + */ + +#ifndef TVM_TIR_ANALYSIS_DEVICE_CONSTRAINT_UTILS_H_ +#define TVM_TIR_ANALYSIS_DEVICE_CONSTRAINT_UTILS_H_ + +#include <tvm/target/se_scope.h> +#include <tvm/tir/function.h> + +namespace tvm { +namespace tir { + +/* + * A Relay Function with type: + * \code + * fn((Tensor[...], Tensor[...]), Tensor[...]) -> (Tensor[...], Tensor[...]) + * ^ ^ ^ ^ ^ + * a b c d e + * \endcode + * will be represented by a TIR PrimFunc in flattened and DPS form with at least 5 argument a..e. + * Each such PrimFunc argument will have a type annotation for a PointerType to the underlying + * tensor's buffer. The PrimFunc may have additional non-pointer arguments, for example to represent Review comment: thx, added and clarrified -- 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]
