@@ -91,6 +91,9 @@ LiteRtStatus LiteRtSetCpuOptionsXnnPackWeightCachePath(LiteRtCpuOptions options,
9191 const char * path) {
9292 LITERT_RETURN_IF_ERROR (options, litert::ErrorStatusBuilder::InvalidArgument ())
9393 << " options is null." ;
94+ LITERT_RETURN_IF_ERROR (options->xnn .weight_cache_file_descriptor <= 0 ,
95+ litert::ErrorStatusBuilder::InvalidArgument ())
96+ << " weight cache file descriptor and path cannot both be set." ;
9497 options->xnn .weight_cache_file_path = path;
9598 return kLiteRtStatusOk ;
9699}
@@ -104,3 +107,24 @@ LiteRtStatus LiteRtGetCpuOptionsXnnPackWeightCachePath(
104107 *path = options->xnn .weight_cache_file_path ;
105108 return kLiteRtStatusOk ;
106109}
110+
111+ LiteRtStatus LiteRtSetCpuOptionsXnnPackWeightCacheFileDescriptor (
112+ LiteRtCpuOptions options, int fd) {
113+ LITERT_RETURN_IF_ERROR (options, litert::ErrorStatusBuilder::InvalidArgument ())
114+ << " options is null." ;
115+ LITERT_RETURN_IF_ERROR (options->xnn .weight_cache_file_path == nullptr ,
116+ litert::ErrorStatusBuilder::InvalidArgument ())
117+ << " weight cache file descriptor and path cannot both be set." ;
118+ options->xnn .weight_cache_file_descriptor = fd;
119+ return kLiteRtStatusOk ;
120+ }
121+
122+ LiteRtStatus LiteRtGetCpuOptionsXnnPackWeightCacheFileDescriptor (
123+ LiteRtCpuOptionsConst options, int * const fd) {
124+ LITERT_RETURN_IF_ERROR (options, litert::ErrorStatusBuilder::InvalidArgument ())
125+ << " options is null." ;
126+ LITERT_RETURN_IF_ERROR (fd, litert::ErrorStatusBuilder::InvalidArgument ())
127+ << " fd is null." ;
128+ *fd = options->xnn .weight_cache_file_descriptor ;
129+ return kLiteRtStatusOk ;
130+ }
0 commit comments