Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[AutoScheduler] Make SearchTask and ComputeDAG serializable #6842

Merged
merged 7 commits into from Nov 7, 2020

Conversation

comaniac
Copy link
Contributor

@comaniac comaniac commented Nov 3, 2020

This PR adds required __setstate__ and __getstate__ to make SearchTask and ComputeDAG serializable. The idea is to serialize the list of tensors or the schedule used to construct a ComputeDAG, so that we can create an identical ComputeDAG by pickle.loads.

cc @merrymercy @tqchen @junrushao1994

@merrymercy merrymercy self-assigned this Nov 4, 2020
return {"compute": SaveJSON(self.compute), "sche": SaveJSON(self.sche)}

def __setstate__(self, state):
self.compute = LoadJSON(state["compute"]) # pylint: disable=assignment-from-no-return
Copy link
Member

@merrymercy merrymercy Nov 7, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@comaniac Do we need to explicitly call SaveJSON, LoadJSON here?
I find that you don't call these functions in the SearchTask::__getstate__

Copy link
Contributor Author

@comaniac comaniac Nov 7, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't call them in SearchTask because all its members have setstate and getstate implemented correctly. This function provides the correct implementation for ConouteDAG and it will be called when processing ComputeDAG in SearchTask.

For Load/SaveJSON here, alternatively we can use pickle.loads/dumps and let them call Load/SaveJSON via Objects. However, this will introduce the dependency of pickle in this function, and will somehow trigger a bug in the unit test. You can test it by replacing Load/SaveJSON with pickle calls. In the unit test I add, you will find that after loading the DAG back, the placeholder A appears twice.

@merrymercy merrymercy merged commit 12582fd into apache:main Nov 7, 2020
@comaniac comaniac deleted the ansor_task_serial branch November 23, 2020 19:48
trevor-m pushed a commit to trevor-m/tvm that referenced this pull request Dec 2, 2020
)

* serialize task and dag

* fix test

* more tests

* format

* format

* format

* trigger ci
trevor-m pushed a commit to trevor-m/tvm that referenced this pull request Dec 4, 2020
)

* serialize task and dag

* fix test

* more tests

* format

* format

* format

* trigger ci
trevor-m pushed a commit to neo-ai/tvm that referenced this pull request Dec 4, 2020
)

* serialize task and dag

* fix test

* more tests

* format

* format

* format

* trigger ci
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.

None yet

2 participants