test_res_models.py 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. # Copyright (c) 2022 PaddlePaddle Authors. All Rights Reserved.
  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. import paddlers
  15. from rs_models.test_model import TestModel
  16. __all__ = []
  17. class TestResModel(TestModel):
  18. def check_output(self, output, target):
  19. output = output.numpy()
  20. self.check_output_equal(output.shape, target.shape)
  21. def set_inputs(self):
  22. def _gen_data(specs):
  23. for spec in specs:
  24. c = spec.get('in_channels', 3)
  25. yield self.get_randn_tensor(c)
  26. self.inputs = _gen_data(self.specs)
  27. def set_targets(self):
  28. def _gen_data(specs):
  29. for spec in specs:
  30. # XXX: Hard coding
  31. if 'out_channels' in spec:
  32. c = spec['out_channels']
  33. elif 'in_channels' in spec:
  34. c = spec['in_channels']
  35. else:
  36. c = 3
  37. yield [self.get_zeros_array(c)]
  38. self.targets = _gen_data(self.specs)