| 231 | REGISTER_OP_GRADIENT("AvgPool", AvgPoolGrad); |
| 232 | |
| 233 | Status MaxPoolGradGrad(const AttrSlice& attrs, FunctionDef* g) { |
| 234 | // clang-format off |
| 235 | *g = FDH::Define( |
| 236 | // Arg defs |
| 237 | {"input: T", "grad: T"}, |
| 238 | // Ret val defs |
| 239 | {"output: T"}, |
| 240 | // Attr defs |
| 241 | {"T: {float, half} = DT_FLOAT", |
| 242 | "ksize: list(int) >= 4", |
| 243 | "strides: list(int) >= 4", |
| 244 | GetPaddingAttrString()}, |
| 245 | // Nodes |
| 246 | { |
| 247 | // Invoke MaxPool again to recompute the outputs (removed by CSE?). |
| 248 | {{"maxpool"}, "MaxPool", {"input"}, |
| 249 | /*Attrs=*/{{"T", "$T"}, |
| 250 | {"ksize", "$ksize"}, |
| 251 | {"strides", "$strides"}, |
| 252 | {"padding", "$padding"}}}, |
| 253 | {{"output"}, "MaxPoolGradGrad", {"input", "maxpool", "grad"}, |
| 254 | /*Attrs=*/{{"T", "$T"}, |
| 255 | {"ksize", "$ksize"}, |
| 256 | {"strides", "$strides"}, |
| 257 | {"padding", "$padding"}}} |
| 258 | }); |
| 259 | // clang-format on |
| 260 | return Status::OK(); |
| 261 | } |
| 262 | REGISTER_OP_GRADIENT("MaxPoolGrad", MaxPoolGradGrad); |
| 263 | |
| 264 | Status BiasAddGrad(const AttrSlice& attrs, FunctionDef* g) { |