Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[PYTHON] Fix ctypes bug for mac #9

Merged
merged 2 commits into from
Jan 11, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ language: cpp

os:
- linux
# - osx
- osx

env:
# code analysis
Expand Down
14 changes: 8 additions & 6 deletions python/tvm/_ctypes/_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,13 @@ class ArgVariant(ctypes.Union):
kStr = 3
kNodeHandle = 4

NODE_TYPE = {
}

def _type_key(handle):
def _return_node(x):
handle = x.v_handle
if not isinstance(handle, ctypes.c_void_p):
handle = ctypes.c_void_p(handle)
ret_val = ArgVariant()
ret_typeid = ctypes.c_int()
ret_success = ctypes.c_int()
Expand All @@ -35,17 +40,14 @@ def _type_key(handle):
ctypes.byref(ret_val),
ctypes.byref(ret_typeid),
ctypes.byref(ret_success)))
return py_str(ret_val.v_str)

NODE_TYPE = {
}
return NODE_TYPE.get(py_str(ret_val.v_str), NodeBase)(handle)

RET_SWITCH = {
kNull: lambda x: None,
kLong: lambda x: x.v_long,
kDouble: lambda x: x.v_double,
kStr: lambda x: py_str(x.v_str),
kNodeHandle: lambda x: NODE_TYPE.get(_type_key(x), NodeBase)(x.v_handle)
kNodeHandle: lambda x: _return_node(x)
}

class SliceBase(object):
Expand Down