"vscode:/vscode.git/clone" did not exist on "65ca68a96850dc362098743aca9f0dcd3a1c3203"
c_api_common.cc 697 Bytes
Newer Older
1
2
3
4
5
/*!
 *  Copyright (c) 2018 by Contributors
 * \file c_runtime_api.cc
 * \brief DGL C API common implementations
 */
Lingfan Yu's avatar
Lingfan Yu committed
6
7
#include "c_api_common.h"

8
9
10
11
12
using dgl::runtime::DGLArgs;
using dgl::runtime::DGLArgValue;
using dgl::runtime::DGLRetValue;
using dgl::runtime::PackedFunc;
using dgl::runtime::NDArray;
Lingfan Yu's avatar
Lingfan Yu committed
13
14
15
16

namespace dgl {

PackedFunc ConvertNDArrayVectorToPackedFunc(const std::vector<NDArray>& vec) {
17
    auto body = [vec](DGLArgs args, DGLRetValue* rv) {
Da Zheng's avatar
Da Zheng committed
18
        const uint64_t which = args[0];
Lingfan Yu's avatar
Lingfan Yu committed
19
20
21
22
23
24
25
26
27
        if (which >= vec.size()) {
            LOG(FATAL) << "invalid choice";
        } else {
            *rv = std::move(vec[which]);
        }
    };
    return PackedFunc(body);
}

28
}  // namespace dgl