updated os specific codes

This commit is contained in:
lzhengning 2021-06-17 22:04:24 +08:00
parent 9edb1890b6
commit c75c856d2f
3 changed files with 19 additions and 4 deletions

View File

@ -88,8 +88,11 @@ jit_op_entry_t compile(const string& jit_key, const string& src, const bool is_c
+ " '" + jit_src_path + "'" + other_src
+ cc_flags + extra_flags
+ " -o '" + jit_lib_path + "'";
// cmd = python_path+" "+jittor_path+"/utils/asm_tuner.py "
// "--cc_path=" + cmd;
#ifdef __linux__
cmd = python_path+" "+jittor_path+"/utils/asm_tuner.py "
"--cc_path=" + cmd;
#endif
}
cache_compile(cmd, cache_path, jittor_path);
auto symbol_name = get_symbol_name(jit_key);

View File

@ -140,9 +140,13 @@ ArrayOp::ArrayOp(PyObject* obj) {
std::memcpy(host_ptr, args.ptr, size);
} else {
// this is non-continue numpy array
#if defined(__linux__)
int64 dims[args.shape.size()];
#elif defined(__APPLE__)
long dims[args.shape.size()];
#endif
for (int i=0; i<args.shape.size(); i++)
dims[i] = args.shape[i];
dims[i] = (long) args.shape[i];
holder.assign(PyArray_New(
PyArray_Type, // subtype
args.shape.size(), // nd

View File

@ -266,7 +266,11 @@ DEF_IS(ArrayArgs, bool) is_type(PyObject* obj) {
}
DEF_IS(ArrayArgs, PyObject*) to_py_object(const T& a) {
#if defined(__linux__)
int64 dims[a.shape.size()];
#elif defined(__APPLE__)
long dims[a.shape.size()];
#endif
for (int i=0; i<a.shape.size(); i++)
dims[i] = a.shape[i];
PyObjHolder obj(PyArray_SimpleNew(
@ -378,9 +382,13 @@ DEF_IS(VarHolder*, T) from_py_object(PyObject* obj, unique_ptr<VarHolder>& holde
struct DataView;
DEF_IS(DataView, PyObject*) to_py_object(T a) {
#if defined(__linux__)
int64 dims[a.shape.size()];
#elif defined(__APPLE__)
long dims[a.shape.size()];
#endif
for (int i=0; i<a.shape.size(); i++)
dims[i] = a.shape[i];
dims[i] = (int64) a.shape[i];
PyObjHolder oh(PyArray_New(
PyArray_Type, // subtype
a.shape.size(), // nd