Example #1
0
  def _testForwardCase(self,
                       use_cudnn=False,
                       data_format="NHWC",
                       dtype=dtypes.float32):
    for seed in range(5):
      p = self._genParams(use_cudnn, data_format, dtype, seed=seed)
      input_data, filter_data, strides, padding, _ = p

      with test_util.deterministic_ops():
        result_a = nn_impl.depthwise_conv2d_v2(input_data, filter_data, strides,
                                               padding, data_format)
        result_b = nn_impl.depthwise_conv2d_v2(input_data, filter_data, strides,
                                               padding, data_format)

      self.assertAllEqual(result_a, result_b)
 def Gradients(upstream_gradients):
     with backprop.GradientTape() as tape:
         tape.watch(input_data)
         tape.watch(filter_data)
         op_output = nn_impl.depthwise_conv2d_v2(
             input_data, filter_data, strides, padding, data_format)
         gradient_injector_output = op_output * upstream_gradients
     return tape.gradient(gradient_injector_output,
                          [input_data, filter_data])