masahi commented on code in PR #14513: URL: https://github.com/apache/tvm/pull/14513#discussion_r1162200991
########## src/relax/transform/rewrite_cuda_graph.cc: ########## @@ -0,0 +1,512 @@ +/* + * 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 relax/transform/rewrite_cuda_graph.cc + * \brief Pass for transforming Relax module to execute with CUDA graph. + * + * CUDA graph provides a way to capture a sequence of CUDA kernel launches in the runtime and + * save them as a graph. The graph can be executed multiple times with less overhead than launching + * kernels individually. This pass rewrites the Relax module to execute with CUDA graph. + * + * The transformation is done in two steps: + * + * 1. Identify the regions that can be captured by CUDA graph and create the rewriting plan with + * `CUDAGraphRewritePlaner`. + * + * A region is a subgraph of the Relax function that are executed statically. A region is executed + * statically if 1) it only depends on the memory allocated internally in the Relax function with + * constant shapes, 2) it only contains kernel launches (there are no control flow). + * + * This transformation is expected to run after `StaticPlanBlockMemory`. After + * `StaticPlanBlockMemory`, all the tensors that can be statically allocated are allocated with + * `R.memory.alloc_storage` and `R.memory.alloc_tensor`, while other tensors will be allocated via + * `R.builtin.alloc_tensor`. + * + * `CUDAGraphRewritePlaner` is executed at the level of BindingBlock. It first identify all the Review Comment: same typo ########## src/relax/transform/rewrite_cuda_graph.cc: ########## @@ -0,0 +1,512 @@ +/* + * 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 relax/transform/rewrite_cuda_graph.cc + * \brief Pass for transforming Relax module to execute with CUDA graph. + * + * CUDA graph provides a way to capture a sequence of CUDA kernel launches in the runtime and + * save them as a graph. The graph can be executed multiple times with less overhead than launching + * kernels individually. This pass rewrites the Relax module to execute with CUDA graph. + * + * The transformation is done in two steps: + * + * 1. Identify the regions that can be captured by CUDA graph and create the rewriting plan with + * `CUDAGraphRewritePlaner`. Review Comment: typo `Planer` -- 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]
