Skip to content

Commit

Permalink
Load platform specific lib for tvmdsoop instead of only so (apache#5542)
Browse files Browse the repository at this point in the history
  • Loading branch information
tobegit3hub authored and trevor-m committed Jun 18, 2020
1 parent 2a3ae8b commit 5dc018a
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion python/tvm/contrib/tf_op/module.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
"""Module container of TensorFlow TVMDSO op"""
import tensorflow as tf
from tensorflow.python.framework import load_library
from tensorflow.python import platform


class OpModule:
Expand Down Expand Up @@ -67,7 +68,7 @@ def __init__(self, lib_path, func_name, output_dtype, output_shape):
elif output_shape is not None:
self.dynamic_output_shape = self._pack_shape_tensor(output_shape)

self.module = load_library.load_op_library('tvm_dso_op.so')
self.module = self._load_platform_specific_library("tvm_dso_op")
self.tvm_dso_op = self.module.tvm_dso_op

def apply(self, *params):
Expand All @@ -82,6 +83,16 @@ def apply(self, *params):
def __call__(self, *params):
return self.apply(*params)

def _load_platform_specific_library(self, lib_name):
system = platform.system()
if system == "Darwin":
lib_file_name = lib_name + ".dylib"
elif system == "Windows":
lib_file_name = lib_name + ".dll"
else:
lib_file_name = lib_name + ".so"
return load_library.load_op_library(lib_file_name)

def _is_static_shape(self, shape):
if shape is None or not isinstance(shape, list):
return False
Expand Down

0 comments on commit 5dc018a

Please sign in to comment.