(selected_rows, file_name)
| 733 | |
| 734 | |
| 735 | def _save_selected_rows(selected_rows, file_name): |
| 736 | if not selected_rows.get_tensor()._is_initialized(): |
| 737 | raise ValueError("The saved tensor is not initialized.") |
| 738 | if _is_file_path(file_name): |
| 739 | # '_seek' is the end position of this SelectedRows in the file. |
| 740 | _seek = core.save_selected_rows(selected_rows, file_name) |
| 741 | |
| 742 | elif _is_memory_buffer(file_name): |
| 743 | selected_rows_bytes = core.save_selected_rows_to_memory(selected_rows) |
| 744 | with _open_file_buffer(file_name, 'wb') as f: |
| 745 | f.write(selected_rows_bytes) |
| 746 | _seek = f.tell() |
| 747 | else: |
| 748 | raise NotImplementedError( |
| 749 | f'Only supports saving objects to file or BytesIO, but received {type(file_name)}' |
| 750 | ) |
| 751 | return _seek |
| 752 | |
| 753 | |
| 754 | def _load_selected_rows(file_name): |
no test coverage detected