Commit a78ad1ac authored by Myle Ott's avatar Myle Ott Committed by Facebook Github Bot
Browse files

Add utils.deprecation_warning

Summary: Pull Request resolved: https://github.com/pytorch/fairseq/pull/607

Differential Revision: D14681031

Pulled By: myleott

fbshipit-source-id: 466ee526a30543218e2b7138fb651db866ae5ab3
parent 8ab27e6e
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -12,6 +12,7 @@ import os
import re
import sys
import traceback
import warnings

import torch
import torch.nn.functional as F
@@ -463,3 +464,8 @@ def log_softmax(x, dim, onnx_trace=False):
        return F.log_softmax(x.float(), dim=dim)
    else:
        return F.log_softmax(x, dim=dim, dtype=torch.float32)


def deprecation_warning(message, stacklevel=3):
    # don't use DeprecationWarning, since it's ignored by default
    warnings.warn(message, stacklevel=stacklevel)