MCPcopy Create free account
hub / github.com/TPCD/DCCL / forward

Method forward

model/attribute_transformer.py:119–158  ·  view source on GitHub ↗
(self, input)

Source from the content-addressed store, hash-verified

117
118class ChannelMaxPoolFlat(MaxPool1d):
119 def forward(self, input):
120 if len(input.size()) == 4:
121 n, c, w, h = input.size()
122 pool = lambda x: F.max_pool1d(
123 x,
124 self.kernel_size,
125 self.stride,
126 self.padding,
127 self.dilation,
128 self.ceil_mode,
129 self.return_indices,
130 )
131 out = rearrange(
132 pool(rearrange(input, "n c w h -> n (w h) c")),
133 "n (w h) c -> n c w h",
134 n=n,
135 w=w,
136 h=h,
137 )
138 return out.squeeze()
139 elif len(input.size()) == 3:
140 n, c, l = input.size()
141 pool = lambda x: F.max_pool1d(
142 x,
143 self.kernel_size,
144 self.stride,
145 self.padding,
146 self.dilation,
147 self.ceil_mode,
148 self.return_indices,
149 )
150 out = rearrange(
151 pool(rearrange(input, "n c l -> n l c")),
152 "n l c -> n c l",
153 n=n,
154 l=l
155 )
156 return out.squeeze()
157 else:
158 raise NotImplementedError
159
160
161class ChannelAvgPoolFlat(AvgPool1d):

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected