Unverified Commit 67f21071 authored by Vasilis Vryniotis's avatar Vasilis Vryniotis Committed by GitHub
Browse files

[FBcode->GH] Enable GPU/RE teags for pytorch/*/TARGETS that needs GPU (#3384)

Summary:
Pull Request resolved: https://github.com/pytorch/vision/pull/3370

Pull Request resolved: https://github.com/pytorch/vision/pull/3361

Convert pytorch_gpu to use GPU/RE

Reviewed By: datumbox

Differential Revision: D26264102

fbshipit-source-id: b45179215ecb1142f6468386c4fee1759dd82f0c
parent 28575361
import os
# Get relative file path
# this returns relative path from current file.
def get_relative_path(curr_file, *path_components):
return os.path.join(os.path.dirname(curr_file), *path_components)
...@@ -14,6 +14,7 @@ import random ...@@ -14,6 +14,7 @@ import random
from numbers import Number from numbers import Number
from torch._six import string_classes from torch._six import string_classes
from collections import OrderedDict from collections import OrderedDict
from _utils_internal import get_relative_path
import numpy as np import numpy as np
from PIL import Image from PIL import Image
...@@ -110,19 +111,23 @@ class TestCase(unittest.TestCase): ...@@ -110,19 +111,23 @@ class TestCase(unittest.TestCase):
# lives, NOT where test/common_utils.py lives. # lives, NOT where test/common_utils.py lives.
module_id = self.__class__.__module__ module_id = self.__class__.__module__
munged_id = remove_prefix_suffix(self.id(), module_id + ".", strip_suffix) munged_id = remove_prefix_suffix(self.id(), module_id + ".", strip_suffix)
test_file = os.path.realpath(sys.modules[module_id].__file__)
expected_file = os.path.join(os.path.dirname(test_file),
"expect",
munged_id)
# Determine expected file based on environment
expected_file_base = get_relative_path(
os.path.realpath(sys.modules[module_id].__file__),
"expect")
# Set expected_file based on subname.
expected_file = os.path.join(expected_file_base, munged_id)
if subname: if subname:
expected_file += "_" + subname expected_file += "_" + subname
expected_file += "_expect.pkl" expected_file += "_expect.pkl"
if not ACCEPT and not os.path.exists(expected_file): if not ACCEPT and not os.path.exists(expected_file):
raise RuntimeError( raise RuntimeError(
("No expect file exists for {}; to accept the current output, run:\n" f"No expect file exists for {os.path.basename(expected_file)} in {expected_file}; "
"python {} {} --accept").format(os.path.basename(expected_file), __main__.__file__, munged_id)) "to accept the current output, run:\n"
f"python {__main__.__file__} {munged_id} --accept")
return expected_file return expected_file
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment