diff --git a/houseroad/foxi/bd6feb6d0d3fc903df42b4feb82a602a5fcb1fd5/cmake.patch b/houseroad/foxi/bd6feb6d0d3fc903df42b4feb82a602a5fcb1fd5/cmake.patch new file mode 100644 index 0000000..881f2e1 --- /dev/null +++ b/houseroad/foxi/bd6feb6d0d3fc903df42b4feb82a602a5fcb1fd5/cmake.patch @@ -0,0 +1,13 @@ +diff --git a/CMakeLists.txt b/CMakeLists.txt +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -65 +64,0 @@ +- add_msvc_runtime_flag(foxi_loader) +@@ -104 +102,0 @@ +- add_msvc_runtime_flag(foxi_dummy) +@@ -118 +116 @@ +- EXPORT ONNXTargets DESTINATION lib) ++ EXPORT ONNXTargets RUNTIME DESTINATION bin ARCHIVE DESTINATION lib LIBRARY DESTINATION lib) +@@ -122 +120 @@ +- EXPORT ONNXTargets DESTINATION lib) ++ EXPORT ONNXTargets RUNTIME DESTINATION bin ARCHIVE DESTINATION lib LIBRARY DESTINATION lib) diff --git a/houseroad/foxi/bd6feb6d0d3fc903df42b4feb82a602a5fcb1fd5/consumer.c b/houseroad/foxi/bd6feb6d0d3fc903df42b4feb82a602a5fcb1fd5/consumer.c new file mode 100644 index 0000000..10b0ec9 --- /dev/null +++ b/houseroad/foxi/bd6feb6d0d3fc903df42b4feb82a602a5fcb1fd5/consumer.c @@ -0,0 +1,14 @@ +#include + +#include + +int main(void) { + struct onnxifi_library onnx; + int ret = onnxifi_load(ONNXIFI_LOADER_FLAG_VERSION_1_0, NULL, &onnx); + if (!ret) { + printf("Cannot load onnxifi lib\n"); + return 0; + } + onnxifi_unload(&onnx); + return 0; +} diff --git a/houseroad/foxi/bd6feb6d0d3fc903df42b4feb82a602a5fcb1fd5/fix-conflicting-types.patch b/houseroad/foxi/bd6feb6d0d3fc903df42b4feb82a602a5fcb1fd5/fix-conflicting-types.patch new file mode 100644 index 0000000..a1a3a15 --- /dev/null +++ b/houseroad/foxi/bd6feb6d0d3fc903df42b4feb82a602a5fcb1fd5/fix-conflicting-types.patch @@ -0,0 +1,47 @@ +--- a/foxi/onnxifi_dummy.c ++++ b/foxi/onnxifi_dummy.c +@@ -103,7 +103,9 @@ ONNXIFI_PUBLIC ONNXIFI_CHECK_RESULT onnxStatus ONNXIFI_ABI onnxInitGraph( + const void* onnxModel, + uint32_t weightCount, + const onnxTensorDescriptorV1* weightDescriptors, +- onnxGraph* graph) { ++ onnxGraph* graph, ++ uint32_t maxSeqLength, ++ void* deferredWeightReader) { + if (graph == NULL) { + return ONNXIFI_STATUS_INVALID_POINTER; + } +@@ -215,6 +217,8 @@ ONNXIFI_PUBLIC ONNXIFI_CHECK_RESULT onnxStatus ONNXIFI_ABI + onnxWaitEventFor(onnxEvent event, + uint32_t timeoutMs, + onnxEventState* eventState, +- onnxStatus* eventStatus) { ++ onnxStatus* eventStatus, ++ char* message, ++ size_t* messageLength) { + return ONNXIFI_STATUS_SUCCESS; + } +--- a/foxi/onnxifi_wrapper.c ++++ b/foxi/onnxifi_wrapper.c +@@ -761,7 +761,9 @@ ONNXIFI_PUBLIC onnxStatus ONNXIFI_ABI onnxInitGraph( + const void* onnxModel, + uint32_t weightsCount, + const onnxTensorDescriptorV1* weightDescriptors, +- onnxGraph* graph) ++ onnxGraph* graph, ++ uint32_t maxSeqLength, ++ void* deferredWeightReader) + { + if (graph == NULL) { + return ONNXIFI_STATUS_INVALID_POINTER; +@@ -797,7 +799,9 @@ ONNXIFI_PUBLIC onnxStatus ONNXIFI_ABI onnxInitGraph( + onnxModel, + weightsCount, + weightDescriptors, +- &graph_wrapper->graph); ++ &graph_wrapper->graph, ++ maxSeqLength, ++ deferredWeightReader); + switch (status) { + case ONNXIFI_STATUS_SUCCESS: + case ONNXIFI_STATUS_FALLBACK: diff --git a/houseroad/foxi/bd6feb6d0d3fc903df42b4feb82a602a5fcb1fd5/foxi_llar.gox b/houseroad/foxi/bd6feb6d0d3fc903df42b4feb82a602a5fcb1fd5/foxi_llar.gox new file mode 100644 index 0000000..bed6661 --- /dev/null +++ b/houseroad/foxi/bd6feb6d0d3fc903df42b4feb82a602a5fcb1fd5/foxi_llar.gox @@ -0,0 +1,76 @@ +import ( + "os" + "path/filepath" + "strings" +) + +// Conan Center cci.20210217 pins houseroad/foxi to this commit. The upstream +// repository has no release tags, so this commit is the only fetchable source +// ref for the selected recipe snapshot. +id "houseroad/foxi" + +fromVer "bd6feb6d0d3fc903df42b4feb82a602a5fcb1fd5" + +onBuild ctx => { + installDir := ctx.outputDir + + patch := ctx.Proj.readFile("bd6feb6d0d3fc903df42b4feb82a602a5fcb1fd5/fix-conflicting-types.patch")! + patchPath := filepath.join(ctx.SourceDir, "_llar_fix-conflicting-types.patch") + os.writeFile(patchPath, patch, 0o644)! + patch "-p1", "--batch", "--forward", "-i", patchPath + lastErr! + + cmakePatch := ctx.Proj.readFile("bd6feb6d0d3fc903df42b4feb82a602a5fcb1fd5/cmake.patch")! + cmakePatchPath := filepath.join(ctx.SourceDir, "_llar_cmake.patch") + os.writeFile(cmakePatchPath, cmakePatch, 0o644)! + patch "-p1", "--batch", "--forward", "-i", cmakePatchPath + lastErr! + + c := cmake.new(ctx.SourceDir, filepath.join(ctx.SourceDir, "_build"), installDir) + c.define "CMAKE_POLICY_VERSION_MINIMUM", "3.5" + c.configure + c.build + c.install + + licenseDir := filepath.join(installDir, "licenses") + os.mkdirAll(licenseDir, 0o755)! + license := os.readFile(filepath.join(ctx.SourceDir, "LICENSE"))! + os.writeFile(filepath.join(licenseDir, "LICENSE"), license, 0o644)! + + flags := []string{ + "-I" + filepath.join(installDir, "include"), + "-L" + filepath.join(installDir, "lib"), + "-lfoxi_dummy", + "-lfoxi_loader", + "-ldl", + } + ctx.setMetadata strings.join(flags, " ") +} + +onTest ctx => { + installDir := ctx.outputDir + testDir := filepath.join(ctx.SourceDir, "_llar_consumer") + os.mkdirAll(testDir, 0o755)! + + source := ctx.Proj.readFile("bd6feb6d0d3fc903df42b4feb82a602a5fcb1fd5/consumer.c")! + sourcePath := filepath.join(testDir, "consumer.c") + os.writeFile(sourcePath, source, 0o644)! + + flags := []string{ + "-I" + filepath.join(installDir, "include"), + "-L" + filepath.join(installDir, "lib"), + "-lfoxi_dummy", + "-lfoxi_loader", + "-ldl", + } + binary := filepath.join(testDir, "consumer") + args := []string{sourcePath, "-o", binary} + args = append(args, flags...) + exec "cc", args... + lastErr! + + os.setenv("LD_LIBRARY_PATH", filepath.join(installDir, "lib"))! + os.setenv("DYLD_LIBRARY_PATH", filepath.join(installDir, "lib"))! + exec binary + lastErr! +} diff --git a/houseroad/foxi/versions.json b/houseroad/foxi/versions.json new file mode 100644 index 0000000..e239369 --- /dev/null +++ b/houseroad/foxi/versions.json @@ -0,0 +1,4 @@ +{ + "path": "houseroad/foxi", + "deps": {} +}