[PATCH] D96796: [mlgo] Fetch models from path / URL

Mircea Trofin via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Feb 16 22:34:11 PST 2021


mtrofin updated this revision to Diff 324185.
mtrofin marked an inline comment as done.
mtrofin edited the summary of this revision.
mtrofin added a comment.

feedback


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D96796/new/

https://reviews.llvm.org/D96796

Files:
  llvm/cmake/modules/TensorFlowCompile.cmake
  llvm/lib/Analysis/CMakeLists.txt


Index: llvm/lib/Analysis/CMakeLists.txt
===================================================================
--- llvm/lib/Analysis/CMakeLists.txt
+++ llvm/lib/Analysis/CMakeLists.txt
@@ -1,7 +1,10 @@
 if (DEFINED LLVM_HAVE_TF_AOT OR DEFINED LLVM_HAVE_TF_API)
   if (DEFINED LLVM_HAVE_TF_AOT)
+    set(LLVM_INLINER_MODEL_PATH "models/inliner" 
+      CACHE STRING 
+      "ML-driven inliner policy location - URL to archive; or path to saved model (relative to this directory, or absolute)")
     include(TensorFlowCompile)
-    tfcompile(models/inliner serve action InlinerSizeModel llvm::InlinerSizeModel)
+    tfcompile(${LLVM_INLINER_MODEL_PATH} serve action InlinerSizeModel llvm::InlinerSizeModel)
     list(APPEND GeneratedMLSources
       $<TARGET_OBJECTS:tf_xla_runtime_objects>
       ${GENERATED_OBJS}
Index: llvm/cmake/modules/TensorFlowCompile.cmake
===================================================================
--- llvm/cmake/modules/TensorFlowCompile.cmake
+++ llvm/cmake/modules/TensorFlowCompile.cmake
@@ -1,3 +1,14 @@
+# Ensure the ${model} is available at ${final_path}.
+#
+function(tfgetmodel model final_path)
+  if (IS_ABSOLUTE ${model})
+    set(${final_path} ${model} PARENT_SCOPE)
+  else()
+    set(${final_path}
+      ${CMAKE_CURRENT_SOURCE_DIR}/${model} PARENT_SCOPE)
+  endif()
+endfunction()
+
 # Run the tensorflow compiler (saved_model_cli) on the saved model in the 
 # ${model} directory, looking for the ${tag_set} tag set, and the SignatureDef
 # ${signature_def_key}.
@@ -5,13 +16,8 @@
 # ${CMAKE_CURRENT_BINARY_DIR}. The generated header will define a C++ class
 # called ${cpp_class} - which may be a namespace-qualified class name.
 function(tfcompile model tag_set signature_def_key fname cpp_class)
-  if (IS_ABSOLUTE ${model})
-    set(LLVM_ML_MODELS_ABSOLUTE ${model})
-  else()
-    set(LLVM_ML_MODELS_ABSOLUTE
-      ${CMAKE_CURRENT_SOURCE_DIR}/${model})
-  endif()
-
+  tfgetmodel(${model} LLVM_ML_MODELS_ABSOLUTE)
+  message("Using model at " ${LLVM_ML_MODELS_ABSOLUTE})
   set(prefix ${CMAKE_CURRENT_BINARY_DIR}/${fname})
   set(obj_file ${prefix}.o)
   set(hdr_file ${prefix}.h)


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D96796.324185.patch
Type: text/x-patch
Size: 2135 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210217/9f10640a/attachment.bin>


More information about the llvm-commits mailing list