This repository has been archived by the owner on Nov 17, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* fix - cpplint * impl - benchmark ffi for ops * rm - FFI for ops with param * fix - makefile * fix - not include unordered_map
- Loading branch information
Ubuntu
committed
Mar 12, 2020
1 parent
bd6e917
commit 2206d8b
Showing
16 changed files
with
330 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF licenses this file | ||
* to you under the Apache License, Version 2.0 (the | ||
* "License"); you may not use this file except in compliance | ||
* with the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
|
||
/*! | ||
* \file np_eigvals.cc | ||
* \brief Implementation of the API of functions in src/operator/numpy/linalg/np_eigvals.cc | ||
*/ | ||
|
||
#include <mxnet/api_registry.h> | ||
#include <mxnet/runtime/packed_func.h> | ||
#include "../../utils.h" | ||
#include "../../../../operator/numpy/linalg/np_eigvals-inl.h" | ||
|
||
namespace mxnet { | ||
|
||
MXNET_REGISTER_API("_npi.eigvalsh") | ||
.set_body([](runtime::MXNetArgs args, runtime::MXNetRetValue* ret) { | ||
using namespace runtime; | ||
const nnvm::Op* op = Op::Get("_npi_eigvalsh"); | ||
nnvm::NodeAttrs attrs; | ||
op::EigvalshParam param; | ||
param.UPLO = *((args[1].operator std::string()).c_str()); | ||
attrs.parsed = param; | ||
attrs.op = op; | ||
SetAttrDict<op::EigvalshParam>(&attrs); | ||
int num_outputs = 0; | ||
NDArray* inputs[] = {args[0].operator mxnet::NDArray*()}; | ||
auto ndoutputs = Invoke(op, &attrs, 1, inputs, &num_outputs, nullptr); | ||
*ret = reinterpret_cast<mxnet::NDArray*>(ndoutputs[0]); | ||
}); | ||
|
||
} // namespace mxnet |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF licenses this file | ||
* to you under the Apache License, Version 2.0 (the | ||
* "License"); you may not use this file except in compliance | ||
* with the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
|
||
/*! | ||
* \file np_pinv.cc | ||
* \brief Implementation of the API of functions in src/operator/numpy/linalg/np_pinv.cc | ||
*/ | ||
|
||
#include <mxnet/api_registry.h> | ||
#include <mxnet/runtime/packed_func.h> | ||
#include "../../utils.h" | ||
#include "../../../../operator/numpy/linalg/np_pinv-inl.h" | ||
|
||
namespace mxnet { | ||
|
||
inline static void _npi_pinv(runtime::MXNetArgs args, runtime::MXNetRetValue* ret) { | ||
using namespace runtime; | ||
const nnvm::Op* op = Op::Get("_npi_pinv"); | ||
op::PinvParam param; | ||
nnvm::NodeAttrs attrs; | ||
param.hermitian = args[2].operator bool(); | ||
attrs.parsed = param; | ||
attrs.op = op; | ||
SetAttrDict<op::PinvParam>(&attrs); | ||
int num_outputs = 0; | ||
NDArray* inputs[] = {args[0].operator mxnet::NDArray*(), args[1].operator mxnet::NDArray*()}; | ||
auto ndoutputs = Invoke(op, &attrs, 2, inputs, &num_outputs, nullptr); | ||
*ret = reinterpret_cast<mxnet::NDArray*>(ndoutputs[0]); | ||
} | ||
|
||
inline static void _npi_pinv_scalar_rcond(runtime::MXNetArgs args, runtime::MXNetRetValue* ret) { | ||
using namespace runtime; | ||
const nnvm::Op* op = Op::Get("_npi_pinv_scalar_rcond"); | ||
op::PinvScalarRcondParam param; | ||
nnvm::NodeAttrs attrs; | ||
param.rcond = args[1].operator double(); | ||
param.hermitian = args[2].operator bool(); | ||
attrs.parsed = param; | ||
attrs.op = op; | ||
SetAttrDict<op::PinvScalarRcondParam>(&attrs); | ||
int num_outputs = 0; | ||
NDArray* inputs[] = {args[0].operator mxnet::NDArray*()}; | ||
auto ndoutputs = Invoke(op, &attrs, 1, inputs, &num_outputs, nullptr); | ||
*ret = reinterpret_cast<mxnet::NDArray*>(ndoutputs[0]); | ||
} | ||
|
||
MXNET_REGISTER_API("_npi.pinv") | ||
.set_body([](runtime::MXNetArgs args, runtime::MXNetRetValue* ret) { | ||
if (args[1].type_code() == kDLFloat || args[1].type_code() == kDLInt) { | ||
_npi_pinv_scalar_rcond(args, ret); | ||
} else { | ||
_npi_pinv(args, ret); | ||
} | ||
}); | ||
|
||
} // namespace mxnet |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF licenses this file | ||
* to you under the Apache License, Version 2.0 (the | ||
* "License"); you may not use this file except in compliance | ||
* with the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
|
||
/*! | ||
* \file np_potrf.cc | ||
* \brief Implementation of the API of functions in src/operator/numpy/linalg/np_potrf.cc | ||
*/ | ||
|
||
#include <mxnet/api_registry.h> | ||
#include <mxnet/runtime/packed_func.h> | ||
#include "../../utils.h" | ||
#include "../../../../operator/numpy/linalg/np_potrf-inl.h" | ||
|
||
namespace mxnet { | ||
|
||
MXNET_REGISTER_API("_npi.cholesky") | ||
.set_body([](runtime::MXNetArgs args, runtime::MXNetRetValue* ret) { | ||
using namespace runtime; | ||
const nnvm::Op* op = Op::Get("_npi_cholesky"); | ||
nnvm::NodeAttrs attrs; | ||
op::LaCholeskyParam param; | ||
param.lower = args[1].operator bool(); | ||
attrs.parsed = param; | ||
attrs.op = op; | ||
SetAttrDict<op::LaCholeskyParam>(&attrs); | ||
int num_outputs = 0; | ||
NDArray* inputs[] = {args[0].operator mxnet::NDArray*()}; | ||
auto ndoutputs = Invoke(op, &attrs, 1, inputs, &num_outputs, nullptr); | ||
*ret = reinterpret_cast<mxnet::NDArray*>(ndoutputs[0]); | ||
}); | ||
|
||
} // namespace mxnet |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF licenses this file | ||
* to you under the Apache License, Version 2.0 (the | ||
* "License"); you may not use this file except in compliance | ||
* with the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
|
||
/*! | ||
* \file np_tensorinv.cc | ||
* \brief Implementation of the API of functions in src/operator/numpy/linalg/np_tensorinv.cc | ||
*/ | ||
|
||
#include <mxnet/api_registry.h> | ||
#include <mxnet/runtime/packed_func.h> | ||
#include "../../utils.h" | ||
#include "../../../../operator/numpy/linalg/np_tensorinv-inl.h" | ||
|
||
namespace mxnet { | ||
|
||
MXNET_REGISTER_API("_npi.tensorinv") | ||
.set_body([](runtime::MXNetArgs args, runtime::MXNetRetValue* ret) { | ||
using namespace runtime; | ||
const nnvm::Op* op = Op::Get("_npi_tensorinv"); | ||
nnvm::NodeAttrs attrs; | ||
op::TensorinvParam param; | ||
param.ind = args[1].operator int(); | ||
attrs.parsed = param; | ||
attrs.op = op; | ||
SetAttrDict<op::TensorinvParam>(&attrs); | ||
int num_outputs = 0; | ||
NDArray* inputs[] = {args[0].operator mxnet::NDArray*()}; | ||
auto ndoutputs = Invoke(op, &attrs, 1, inputs, &num_outputs, nullptr); | ||
*ret = reinterpret_cast<mxnet::NDArray*>(ndoutputs[0]); | ||
}); | ||
|
||
} // namespace mxnet |
Oops, something went wrong.