xref: /aosp_15_r20/external/pytorch/torch/csrc/serialization.h (revision da0073e96a02ea20f0ac840b70461e3646d07c45)
1*da0073e9SAndroid Build Coastguard Worker #ifndef THP_SERIALIZATION_INC
2*da0073e9SAndroid Build Coastguard Worker #define THP_SERIALIZATION_INC
3*da0073e9SAndroid Build Coastguard Worker 
4*da0073e9SAndroid Build Coastguard Worker #include <c10/core/StorageImpl.h>
5*da0073e9SAndroid Build Coastguard Worker #include <c10/util/intrusive_ptr.h>
6*da0073e9SAndroid Build Coastguard Worker template <class io>
7*da0073e9SAndroid Build Coastguard Worker void doRead(io fildes, void* buf, size_t nbytes);
8*da0073e9SAndroid Build Coastguard Worker 
9*da0073e9SAndroid Build Coastguard Worker template <class io>
10*da0073e9SAndroid Build Coastguard Worker void doWrite(io fildes, void* buf, size_t nbytes);
11*da0073e9SAndroid Build Coastguard Worker 
12*da0073e9SAndroid Build Coastguard Worker // Note that this takes a mutable storage because it may pass through
13*da0073e9SAndroid Build Coastguard Worker // to at::from_blob.
14*da0073e9SAndroid Build Coastguard Worker template <class io>
15*da0073e9SAndroid Build Coastguard Worker void THPStorage_writeFileRaw(
16*da0073e9SAndroid Build Coastguard Worker     c10::StorageImpl* self,
17*da0073e9SAndroid Build Coastguard Worker     io fd,
18*da0073e9SAndroid Build Coastguard Worker     bool save_size,
19*da0073e9SAndroid Build Coastguard Worker     uint64_t element_size);
20*da0073e9SAndroid Build Coastguard Worker 
21*da0073e9SAndroid Build Coastguard Worker template <class io>
22*da0073e9SAndroid Build Coastguard Worker c10::intrusive_ptr<c10::StorageImpl> THPStorage_readFileRaw(
23*da0073e9SAndroid Build Coastguard Worker     io fd,
24*da0073e9SAndroid Build Coastguard Worker     c10::intrusive_ptr<c10::StorageImpl> storage,
25*da0073e9SAndroid Build Coastguard Worker     uint64_t element_size);
26*da0073e9SAndroid Build Coastguard Worker 
27*da0073e9SAndroid Build Coastguard Worker #endif
28