Skip to content

Commit 879495d

Browse files
bottlerfacebook-github-bot
authored andcommitted
omegaconf 2.2.2 compatibility
Summary: OmegaConf 2.2.2 doesn't like heterogenous tuples or Sequence or Set members. Workaround this. Reviewed By: shapovalov Differential Revision: D37278736 fbshipit-source-id: 123e6657947f5b27514910e4074c92086a457a2a
1 parent 5c1ca75 commit 879495d

File tree

6 files changed

+16
-20
lines changed

6 files changed

+16
-20
lines changed

pytorch3d/implicitron/dataset/data_loader_map_provider.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
# LICENSE file in the root directory of this source tree.
66

77
from dataclasses import dataclass
8-
from typing import Optional, Sequence
8+
from typing import Optional, Tuple
99

1010
import torch
1111
from pytorch3d.implicitron.tools.config import registry, ReplaceableBase
@@ -86,7 +86,7 @@ class SequenceDataLoaderMapProvider(DataLoaderMapProviderBase):
8686
num_workers: int = 0
8787
dataset_len: int = 1000
8888
dataset_len_val: int = 1
89-
images_per_seq_options: Sequence[int] = (2,)
89+
images_per_seq_options: Tuple[int, ...] = (2,)
9090
sample_consecutive_frames: bool = False
9191
consecutive_frames_max_gap: int = 0
9292
consecutive_frames_max_gap_seconds: float = 0.1

pytorch3d/implicitron/dataset/json_index_dataset.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -122,9 +122,9 @@ class JsonIndexDataset(DatasetBase, ReplaceableBase):
122122
subsets: Optional[List[str]] = None
123123
limit_to: int = 0
124124
limit_sequences_to: int = 0
125-
pick_sequence: Sequence[str] = ()
126-
exclude_sequence: Sequence[str] = ()
127-
limit_category_to: Sequence[int] = ()
125+
pick_sequence: Tuple[str, ...] = ()
126+
exclude_sequence: Tuple[str, ...] = ()
127+
limit_category_to: Tuple[int, ...] = ()
128128
dataset_root: str = ""
129129
load_images: bool = True
130130
load_depths: bool = True

pytorch3d/implicitron/dataset/json_index_dataset_map_provider.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
import json
99
import os
10-
from typing import Dict, List, Sequence, Tuple, Type
10+
from typing import Dict, List, Tuple, Type
1111

1212
from omegaconf import DictConfig, open_dict
1313
from pytorch3d.implicitron.tools.config import (
@@ -98,7 +98,7 @@ class JsonIndexDatasetMapProvider(DatasetMapProviderBase): # pyre-ignore [13]
9898
dataset_root: str = _CO3D_DATASET_ROOT
9999
n_frames_per_sequence: int = -1
100100
test_on_train: bool = False
101-
restrict_sequence_name: Sequence[str] = ()
101+
restrict_sequence_name: Tuple[str, ...] = ()
102102
test_restrict_sequence_id: int = -1
103103
assert_single_seq: bool = False
104104
only_test_set: bool = False

pytorch3d/implicitron/models/implicit_function/idr_feature_field.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
# implicit_differentiable_renderer.py
44
# Copyright (c) 2020 Lior Yariv
55
import math
6-
from typing import Sequence
6+
from typing import Tuple
77

88
import torch
99
from pytorch3d.implicitron.tools.config import registry
@@ -53,10 +53,10 @@ class IdrFeatureField(ImplicitFunctionBase, torch.nn.Module):
5353
feature_vector_size: int = 3
5454
d_in: int = 3
5555
d_out: int = 1
56-
dims: Sequence[int] = (512, 512, 512, 512, 512, 512, 512, 512)
56+
dims: Tuple[int, ...] = (512, 512, 512, 512, 512, 512, 512, 512)
5757
geometric_init: bool = True
5858
bias: float = 1.0
59-
skip_in: Sequence[int] = ()
59+
skip_in: Tuple[int, ...] = ()
6060
weight_norm: bool = True
6161
n_harmonic_functions_xyz: int = 0
6262
pooled_feature_dim: int = 0

pytorch3d/implicitron/models/view_pooler/feature_aggregator.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
from abc import ABC, abstractmethod
88
from enum import Enum
9-
from typing import Dict, Optional, Sequence, Union
9+
from typing import Dict, Optional, Sequence, Tuple, Union
1010

1111
import torch
1212
import torch.nn.functional as F
@@ -176,7 +176,7 @@ class ReductionFeatureAggregator(torch.nn.Module, FeatureAggregatorBase):
176176
the stack of source-view-specific features to a single feature.
177177
"""
178178

179-
reduction_functions: Sequence[ReductionFunction] = (
179+
reduction_functions: Tuple[ReductionFunction, ...] = (
180180
ReductionFunction.AVG,
181181
ReductionFunction.STD,
182182
)
@@ -269,7 +269,7 @@ class AngleWeightedReductionFeatureAggregator(torch.nn.Module, FeatureAggregator
269269
used when calculating the angle-based aggregation weights.
270270
"""
271271

272-
reduction_functions: Sequence[ReductionFunction] = (
272+
reduction_functions: Tuple[ReductionFunction, ...] = (
273273
ReductionFunction.AVG,
274274
ReductionFunction.STD,
275275
)

tests/implicitron/test_config.py

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
import unittest
1010
from dataclasses import dataclass, field, is_dataclass
1111
from enum import Enum
12-
from typing import Any, Dict, List, Optional, Set, Tuple
12+
from typing import Any, Dict, List, Optional, Tuple
1313

1414
from omegaconf import DictConfig, ListConfig, OmegaConf, ValidationError
1515
from pytorch3d.implicitron.tools.config import (
@@ -484,16 +484,14 @@ class MyDataclass:
484484
none_field: Optional[int] = None
485485
float_field: float = 9.3
486486
bool_field: bool = True
487-
tuple_field: tuple = (3, True, "j")
487+
tuple_field: Tuple[int, ...] = (3,)
488488

489489
class SimpleClass:
490490
def __init__(
491491
self,
492492
tuple_member_: Tuple[int, int] = (3, 4),
493-
set_member_: Set[int] = {2}, # noqa
494493
):
495494
self.tuple_member = tuple_member_
496-
self.set_member = set_member_
497495

498496
def get_tuple(self):
499497
return self.tuple_member
@@ -524,11 +522,9 @@ class C(Configurable):
524522
self.assertEqual(simple.get_tuple(), [3, 4])
525523
self.assertTrue(isinstance(simple.get_tuple(), ListConfig))
526524
# get_default_args converts sets to ListConfigs (which act like lists).
527-
self.assertEqual(simple.set_member, [2])
528-
self.assertTrue(isinstance(simple.set_member, ListConfig))
529525
self.assertEqual(c.a_tuple, [4.0, 3.0])
530526
self.assertTrue(isinstance(c.a_tuple, ListConfig))
531-
self.assertEqual(mydata.tuple_field, (3, True, "j"))
527+
self.assertEqual(mydata.tuple_field, (3,))
532528
self.assertTrue(isinstance(mydata.tuple_field, ListConfig))
533529
f(**c.f_args)
534530

0 commit comments

Comments
 (0)