Skip to content

Commit

Permalink
Upstreaming fbsync changes (#1367)
Browse files Browse the repository at this point in the history
  • Loading branch information
parmeet authored Jul 28, 2021
1 parent c57b1fb commit 760a625
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
8 changes: 8 additions & 0 deletions torchtext/utils.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import torch
import csv
import hashlib
import os
Expand Down Expand Up @@ -241,3 +242,10 @@ def extract_archive(from_path, to_path=None, overwrite=False):
else:
raise NotImplementedError(
"We currently only support tar.gz, .tgz, .gz and zip achives.")


def _log_class_usage(klass):
identifier = "torchtext"
if klass and hasattr(klass, "__name__"):
identifier += f".{klass.__name__}"
torch._C._log_api_usage_once(identifier)
3 changes: 2 additions & 1 deletion torchtext/vocab/vocab.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import torch
import torch.nn as nn
from typing import Dict, List, Optional
from torchtext.utils import _log_class_usage


class Vocab(nn.Module):
Expand All @@ -14,7 +15,7 @@ class Vocab(nn.Module):
def __init__(self, vocab):
super(Vocab, self).__init__()
self.vocab = vocab
torch._C._log_api_usage_once(f"torchtext.{self.__class__.__name__}")
_log_class_usage(__class__)

@property
def is_jitable(self):
Expand Down

0 comments on commit 760a625

Please sign in to comment.