predict_set.py 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. # copyright (c) 2024 PaddlePaddle Authors. All Rights Reserve.
  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. class BatchSizeSetMixin:
  15. @property
  16. def batch_size(self):
  17. return self.components["ReadCmp"].batch_size
  18. @batch_size.setter
  19. def batch_size(self, batch_size):
  20. self.components["ReadCmp"].batch_size = batch_size
  21. class DeviceSetMixin:
  22. @property
  23. def device(self):
  24. return self._pp_option.device
  25. @device.setter
  26. def device(self, device):
  27. self._pp_option.device = device
  28. class PPOptionSetMixin:
  29. @property
  30. def pp_option(self):
  31. return self._pp_option
  32. @pp_option.setter
  33. def pp_option(self, pp_option):
  34. self._pp_option = pp_option