From 8c3a3f874d4f5d62d07826f3703a08a29ddae777 Mon Sep 17 00:00:00 2001 From: Jerry Zhang Date: Thu, 9 May 2024 14:20:09 -0700 Subject: [PATCH] Skip depending on torch testing package (#235) Summary: We used to do ``` from torch.testing._internal.common_utils import IS_FBCODE ``` but this caused some internal failures, so we'll just copy paste the code for `IS_FBCODE` so that we don't depend on the testing package Test Plan: internal CI Reviewers: Subscribers: Tasks: Tags: --- torchao/__init__.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/torchao/__init__.py b/torchao/__init__.py index 340bfe3013..c982e09a0c 100644 --- a/torchao/__init__.py +++ b/torchao/__init__.py @@ -5,8 +5,12 @@ ) from . import dtypes import torch -from torch.testing._internal.common_utils import IS_FBCODE -if not IS_FBCODE: +_IS_FBCODE = ( + hasattr(torch._utils_internal, "IS_FBSOURCE") and + torch._utils_internal.IS_FBSOURCE +) + +if not _IS_FBCODE: from . import _C from . import ops