Skip to content

[Unity] Enhance CopyWithNewVars utility#14764

Merged
tqchen merged 1 commit intoapache:unityfrom
Ubospica:2023-05-04-update-check-params
May 4, 2023
Merged

[Unity] Enhance CopyWithNewVars utility#14764
tqchen merged 1 commit intoapache:unityfrom
Ubospica:2023-05-04-update-check-params

Conversation

@Ubospica
Copy link
Copy Markdown
Contributor

@Ubospica Ubospica commented May 4, 2023

This PR enhances the relax::CopyWithNewVars util by adding a var_map member to the FuncCopier class.

And the FuncCopier pass is moved to src/relax/transform/utils.h to include it in other C++ source files.

Therefore, we can know the variable mapping from the old function to the new function. To use this you will need to:

// only copying a function
#include <tvm/relax/utils.h>
auto func = CopyWithNewVars(old_func);

// getting the var_map_ while copying the function
#include "src/relax/transform/utils.h"
auto copier = FuncCopier();
auto func = copier.Copy(old_func);
Map<Var, Var> var_map = copier.var_map;

@tvm-bot
Copy link
Copy Markdown
Collaborator

tvm-bot commented May 4, 2023

Thanks for contributing to TVM! Please refer to the contributing guidelines https://tvm.apache.org/docs/contribute/ for useful information and tips. Please request code reviews from Reviewers by @-ing them in a comment.

Generated by tvm-bot

@Ubospica Ubospica changed the title [Relax] Enhance CopyWithNewVars utility [Unity] Enhance CopyWithNewVars utility May 4, 2023
@tqchen tqchen merged commit e10ddf1 into apache:unity May 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants