You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

grad_other_ops.py 1.5 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. # Copyright 2020 Huawei Technologies Co., Ltd
  2. #
  3. # Licensed under the Apache License, Version 2.0 (the "License");
  4. # you may not use this file except in compliance with the License.
  5. # You may obtain a copy of the License at
  6. #
  7. # http://www.apache.org/licenses/LICENSE-2.0
  8. #
  9. # Unless required by applicable law or agreed to in writing, software
  10. # distributed under the License is distributed on an "AS IS" BASIS,
  11. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. # See the License for the specific language governing permissions and
  13. # limitations under the License.
  14. # ============================================================================
  15. """Generate bprop for other ops"""
  16. from .. import operations as P
  17. from ..composite.multitype_ops.zeros_like_impl import zeros_like
  18. from .grad_base import bprop_getters
  19. # Unused parameters are placeholders.
  20. @bprop_getters.register(P.Assign)
  21. def get_bprop_assign(self):
  22. """Generate bprop for Assign"""
  23. def bprop(x, y, out, dout):
  24. return (x, zeros_like(y))
  25. return bprop
  26. @bprop_getters.register(P.InvertPermutation)
  27. def get_bprop_invert_permutation(self):
  28. """Generate bprop for InvertPermutation"""
  29. def bprop(x, out, dout):
  30. return (zeros_like(x),)
  31. return bprop
  32. @bprop_getters.register(P.IOU)
  33. def get_bprop_iou(self):
  34. """Generate bprop for IOU"""
  35. def bprop(x, y, out, dout):
  36. return zeros_like(x), zeros_like(y)
  37. return bprop