This is an automated email from the ASF dual-hosted git repository.
syfeng pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/tvm.git
The following commit(s) were added to refs/heads/main by this push:
new f766c3418c Fix g.costs (#17972)
f766c3418c is described below
commit f766c3418c75d02c9852244942303952ca6af244
Author: Thais Camacho <[email protected]>
AuthorDate: Wed May 14 23:53:37 2025 -0300
Fix g.costs (#17972)
---
python/tvm/meta_schedule/cost_model/xgb_model.py | 18 +++++++++++-------
1 file changed, 11 insertions(+), 7 deletions(-)
diff --git a/python/tvm/meta_schedule/cost_model/xgb_model.py
b/python/tvm/meta_schedule/cost_model/xgb_model.py
index aaee58fc94..5806454cdd 100644
--- a/python/tvm/meta_schedule/cost_model/xgb_model.py
+++ b/python/tvm/meta_schedule/cost_model/xgb_model.py
@@ -537,13 +537,17 @@ class XGBModel(PyCostModel):
self.last_train_size = self.data_size
# Step 5. Re-train the model
- self._train(
- xs=list(itertools_chain.from_iterable([g.features for g in
self.data.values()])),
- ys=np.concatenate(
- [g.min_cost / g.costs for g in self.data.values()],
- axis=0,
- ),
- )
+ with np.errstate(divide="ignore", invalid="ignore"):
+ feature_list = list(
+ itertools_chain.from_iterable([g.features for g in
self.data.values()])
+ )
+ cost_ratio_list = [
+ np.divide(g.min_cost, g.costs, out=np.zeros_like(g.costs),
where=g.costs != 0)
+ for g in self.data.values()
+ ]
+ cost_ratios = np.concatenate(cost_ratio_list, axis=0)
+
+ self._train(xs=feature_list, ys=cost_ratios)
def predict(
self,