tqchen commented on code in PR #17599: URL: https://github.com/apache/tvm/pull/17599#discussion_r2009130158
########## include/tvm/relax/transform.h: ########## @@ -666,6 +668,38 @@ TVM_DLL Pass RewriteCUDAGraph(); */ TVM_DLL Pass FewShotTuning(int valid_count, bool benchmark); +/*! + * \brief This pass is designed to annotate the memory scope information via VDevice attribute. + * This pass need operator attrbutes which in general vanish aftre legalization. + * FuseOps and FuseTIR are modified to pass on the operator specific attributes and also + * op_pattern details as part of the PrimFunc. This pass is Adreno specific and annotates each + * BindingVar with appropriate HintInDevice. RealizeVDevice pass followed by handles these hints. + * Followed by this pass we also invoke SpecializePrimFuncBasedOnCallSite which updates the + * var_buffer_map based on this new VDevice information. + */ +TVM_DLL Pass AnnotateCustomMemoryScope(Target target); + +/*! + * \brief This pass updates the var_buffer mapping of PrimFunctions from the call_tir info. + * Primarily used to update the VDevice information if any changes occured from the caller. + * This pass recreates the buffers and updates the map. + */ +TVM_DLL Pass SpecializePrimFuncBasedOnCallSite(); + +/*! + * \brief This pass removes redundant assignment statements. These stmts are result of other pass + * like hint_on_device processed by RealizeVDevice may leave them. The subsequent pass like + * fuse_ops fail to fuse in this case. + */ +TVM_DLL Pass RemoveRedundantAssignments(); + +/* + * \brief This is a texture specific pass that can optimize unnecessary to_device copies. + * Like texture_scope -> ToVDevice -> global scope. In this case the producer can directly + * store into global scope avoiding unnecessary device copy. + */ +TVM_DLL Pass OptimizeToVDeviceForScopeChange(); Review Comment: FoldVDeviceScopeChange ########## src/relax/transform/remove_redundant_assignments.cc: ########## @@ -0,0 +1,124 @@ +/* + * 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 src/relax/transform/remove_redundant_assignments.cc + * \brief This pass removes redundant assignment statements. These stmts are result of other pass + * like hint_on_device processed by RealizeVDevice may leave them. The subsequent pass like + * fuse_ops fail to fuse in this case. Review Comment: is it the same as https://github.com/apache/tvm/blob/main/src/relax/transform/canonicalize_bindings.cc? ########## src/relax/transform/legalize_ops.cc: ########## @@ -385,17 +470,22 @@ class LegalizeMutator : public ExprMutator { * legalization function is not registered. */ bool enable_warning_; + /*! + * \brief List of ops to be skipped from legalization + */ + Optional<Array<String>> skip_ops_; Review Comment: du op.Get() to turn list of string into set of Ops that we can use hash map to do quick checking ########## src/relax/transform/specialize_primfunc_based_on_callsite.cc: ########## @@ -0,0 +1,171 @@ +/* + * 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 src/relax/transform/specialize_tir_params.cc + * \brief Update PrimFunc buffers based on updated scope (or structure) info. + */ + +#include <tvm/node/serialization.h> Review Comment: need testcases for this pass ########## src/relax/transform/annotate_custom_storage.cc: ########## @@ -0,0 +1,746 @@ +/* + * 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 src/relax/transform/annotate_texture_storage.cc Review Comment: if this pass is andreno specific, consider move to relax/backend/adreno ########## src/relax/op/op_common.h: ########## @@ -348,6 +348,10 @@ inline Optional<VDevice> InferBinaryArithOpOutVDevice(const Call& call, const Bl } }; + if (call->sinfo_args.size() > 0) { Review Comment: document the rationale here, we always prefer the device specified in the return statement ########## src/relax/transform/optimize_to_vdevice_for_scope_change.cc: ########## @@ -0,0 +1,184 @@ +/* + * 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. Review Comment: need testcase -- 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]
