MCPcopy Create free account
hub / github.com/pytorch/pytorch / __init__

Method __init__

scripts/release_notes/categorize.py:23–47  ·  view source on GitHub ↗
(self, path, category="Uncategorized", use_classifier: bool = False)

Source from the content-addressed store, hash-verified

21
22class Categorizer:
23 def __init__(self, path, category="Uncategorized", use_classifier: bool = False):
24 self.cache = get_commit_data_cache()
25 self.commits = CommitList.from_existing(path)
26 if use_classifier:
27 print("Using a classifier to aid with categorization.")
28 device = "cuda" if torch.cuda.is_available() else "cpu"
29 classifier_config = CategoryConfig(common.categories)
30 author_map = get_author_map(
31 Path("results/classifier"), regen_data=False, assert_stored=True
32 )
33 file_map = get_file_map(
34 Path("results/classifier"), regen_data=False, assert_stored=True
35 )
36 self.classifier = CommitClassifier(
37 XLMR_BASE, author_map, file_map, classifier_config
38 ).to(device)
39 self.classifier.load_state_dict(
40 torch.load(Path("results/classifier/commit_classifier.pt"))
41 )
42 self.classifier.eval()
43 else:
44 self.classifier = None
45 # Special categories: 'Uncategorized'
46 # All other categories must be real
47 self.category = category
48
49 def categorize(self):
50 commits = self.commits.filter(category=self.category)

Callers

nothing calls this directly

Calls 12

get_commit_data_cacheFunction · 0.90
CategoryConfigClass · 0.90
get_author_mapFunction · 0.90
get_file_mapFunction · 0.90
CommitClassifierClass · 0.90
PathClass · 0.85
from_existingMethod · 0.80
is_availableMethod · 0.45
toMethod · 0.45
load_state_dictMethod · 0.45
loadMethod · 0.45
evalMethod · 0.45

Tested by

no test coverage detected