1 | /* |
---|---|
2 | * Licensed to the Apache Software Foundation (ASF) under one |
3 | * or more contributor license agreements. See the NOTICE file |
4 | * distributed with this work for additional information |
5 | * regarding copyright ownership. The ASF licenses this file |
6 | * to you under the Apache License, Version 2.0 (the |
7 | * "License"); you may not use this file except in compliance |
8 | * with the License. You may obtain a copy of the License at |
9 | * |
10 | * http://www.apache.org/licenses/LICENSE-2.0 |
11 | * |
12 | * Unless required by applicable law or agreed to in writing, |
13 | * software distributed under the License is distributed on an |
14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
15 | * KIND, either express or implied. See the License for the |
16 | * specific language governing permissions and limitations |
17 | * under the License. |
18 | */ |
19 | #include "../utils.h" |
20 | |
21 | namespace tvm { |
22 | namespace meta_schedule { |
23 | |
24 | class RemoveBuildArtifactNode : public MeasureCallbackNode { |
25 | public: |
26 | void Apply(const TaskScheduler& task_scheduler, int task_id, |
27 | const Array<MeasureCandidate>& measure_candidates, |
28 | const Array<BuilderResult>& builder_results, |
29 | const Array<RunnerResult>& runner_results) final { |
30 | static const PackedFunc* f_rm = runtime::Registry::Get("meta_schedule.remove_build_dir"); |
31 | ICHECK(f_rm != nullptr) << "The `remove_build_dir` func is not in tvm registry."; |
32 | auto _ = Profiler::TimedScope("MeasureCallback/RemoveBuildArtifact"); |
33 | for (const BuilderResult& build_result : builder_results) { |
34 | if (Optional<String> path = build_result->artifact_path) { |
35 | (*f_rm)(path.value()); |
36 | } |
37 | } |
38 | } |
39 | |
40 | static constexpr const char* _type_key = "meta_schedule.RemoveBuildArtifact"; |
41 | TVM_DECLARE_FINAL_OBJECT_INFO(RemoveBuildArtifactNode, MeasureCallbackNode); |
42 | }; |
43 | |
44 | MeasureCallback MeasureCallback::RemoveBuildArtifact() { |
45 | ObjectPtr<RemoveBuildArtifactNode> n = make_object<RemoveBuildArtifactNode>(); |
46 | return MeasureCallback(n); |
47 | } |
48 | |
49 | TVM_REGISTER_NODE_TYPE(RemoveBuildArtifactNode); |
50 | TVM_REGISTER_GLOBAL("meta_schedule.MeasureCallbackRemoveBuildArtifact") |
51 | .set_body_typed(MeasureCallback::RemoveBuildArtifact); |
52 | |
53 | } // namespace meta_schedule |
54 | } // namespace tvm |
55 |