@@ -100,6 +100,51 @@ vcl_result_t allocatedExecutableCreate(vcl_compiler_handle_t compiler, vcl_execu
100100 return VCL_RESULT_SUCCESS;
101101}
102102
103+ vcl_result_t allocatedExecutableCreateWSOneShot (vcl_compiler_handle_t compiler, vcl_executable_desc_t desc,
104+ vcl_allocator2_t * allocator) {
105+ if (!compiler || !allocator || !desc.modelIRData ) {
106+ return VCL_RESULT_ERROR_INVALID_ARGUMENT;
107+ }
108+
109+ VPUXDriverCompiler::VPUXCompilerL0* pCompiler = reinterpret_cast <VPUXDriverCompiler::VPUXCompilerL0*>(compiler);
110+ VPUXDriverCompiler::VCLLogger* vclLogger = pCompiler->getLogger ();
111+
112+ // / To avoid access violation, need to convert to string
113+ std::string descOptions (desc.options , desc.optionsSize );
114+ vclLogger->info (" config: {0}" , descOptions);
115+
116+ // / Create info parser
117+ VPUXDriverCompiler::BuildInfo buildInfo (pCompiler);
118+ // / Parse user descriptions and store the input && output settings, compilation configs
119+ if (auto ret = buildInfo.prepareBuildFlags (descOptions); ret != VCL_RESULT_SUCCESS) {
120+ vclLogger->outputError (formatv (" Failed to prepare io info and config! DescOptions: {0}" , descOptions));
121+ return ret;
122+ }
123+
124+ // / Parse serialized model data and create the model container for compiler
125+ if (auto ret = buildInfo.prepareModel (desc.modelIRData , desc.modelIRSize ); ret != VCL_RESULT_SUCCESS) {
126+ vclLogger->outputError (" Failed to parse model info! Incorrect format!" );
127+ return ret;
128+ }
129+
130+ try {
131+ // NetworkMetadata is part of the result, but unused in VCL
132+ // it'd just get destroyed at function call here
133+ VCLBlobAllocator vcl_allocator{allocator};
134+ auto result = pCompiler->importNetworkWSOneShot (buildInfo, vcl_allocator);
135+ if (result.empty ()) {
136+ vclLogger->warning (" Compiler successfully returned but the blob list is empty!" );
137+ }
138+ } catch (const std::exception& error) {
139+ vclLogger->outputError (formatv (" Compiler returned msg:\n {0}" , error.what ()));
140+ return VCL_RESULT_ERROR_INVALID_ARGUMENT;
141+ } catch (...) {
142+ vclLogger->outputError (" Internal exception! Can't compile model!" );
143+ return VCL_RESULT_ERROR_INVALID_ARGUMENT;
144+ }
145+ return VCL_RESULT_SUCCESS;
146+ }
147+
103148#ifdef __cplusplus
104149extern " C" {
105150#endif
@@ -335,6 +380,11 @@ DLLEXPORT vcl_result_t vclAllocatedExecutableCreate(vcl_compiler_handle_t compil
335380 return allocatedExecutableCreate (compiler, desc, allocator, blob, size);
336381}
337382
383+ DLLEXPORT vcl_result_t vclAllocatedExecutableCreateWSOneShot (vcl_compiler_handle_t compiler, vcl_executable_desc_t desc,
384+ vcl_allocator2_t * allocator) {
385+ return allocatedExecutableCreateWSOneShot (compiler, desc, allocator);
386+ }
387+
338388DLLEXPORT vcl_result_t vclExecutableGetSerializableBlob (vcl_executable_handle_t executable, uint8_t * blobBuffer,
339389 uint64_t * blobSize) {
340390 vcl_result_t ret = VCL_RESULT_SUCCESS;
0 commit comments