mxnet
ndarray_handle.h
Go to the documentation of this file.
1 /*
2  * Licensed to the Apache Software Foundation (ASF) under one
3  * or more contributor license agreements. See the NOTICE file
4  * distributed with this work for additional information
5  * regarding copyright ownership. The ASF licenses this file
6  * to you under the Apache License, Version 2.0 (the
7  * "License"); you may not use this file except in compliance
8  * with the License. You may obtain a copy of the License at
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing,
13  * software distributed under the License is distributed on an
14  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15  * KIND, either express or implied. See the License for the
16  * specific language governing permissions and limitations
17  * under the License.
18  */
19 
24 #ifndef MXNET_RUNTIME_NDARRAY_HANDLE_H_
25 #define MXNET_RUNTIME_NDARRAY_HANDLE_H_
26 #include <mxnet/ndarray.h>
27 #include <mxnet/runtime/object.h>
28 
29 namespace mxnet {
30 
31 class NDArrayHandleObj : public Object {
32  public:
35 
36  static constexpr const char* _type_key = "MXNet.NDArrayHandle";
38 };
39 
40 class NDArrayHandle : public ObjectRef {
41  public:
42  explicit NDArrayHandle(NDArray* value) {
43  runtime::ObjectPtr<NDArrayHandleObj> node = make_object<NDArrayHandleObj>();
44  node->value = *value;
45  data_ = std::move(node);
46  }
47  inline NDArray* getArray() const {
48  return static_cast<NDArray*>(&(static_cast<NDArrayHandleObj*>(data_.get())->value));
49  }
51 };
52 
53 }; // namespace mxnet
54 
55 #endif // MXNET_RUNTIME_NDARRAY_HANDLE_H_
mxnet
namespace of mxnet
Definition: api_registry.h:33
mxnet::runtime::Object
base class of all object containers.
Definition: object.h:151
mxnet::runtime::ObjectPtr
A custom smart pointer for Object.
Definition: object.h:346
MXNET_DECLARE_FINAL_OBJECT_INFO
#define MXNET_DECLARE_FINAL_OBJECT_INFO(TypeName, ParentType)
helper macro to declare type information in a final class.
Definition: object.h:668
mxnet::NDArrayHandle::NDArrayHandle
NDArrayHandle(NDArray *value)
Definition: ndarray_handle.h:42
mxnet::NDArrayHandleObj::_type_key
static constexpr const char * _type_key
Definition: ndarray_handle.h:36
mxnet::NDArrayHandleObj
Definition: ndarray_handle.h:31
mxnet::NDArray
ndarray interface
Definition: ndarray.h:82
mxnet::NDArrayHandleObj::value
NDArray value
the Internal value.
Definition: ndarray_handle.h:34
mxnet::runtime::ObjectRef::data_
ObjectPtr< Object > data_
Internal pointer that backs the reference.
Definition: object.h:575
mxnet::NDArrayHandle
Definition: ndarray_handle.h:40
mxnet::NDArrayHandle::getArray
NDArray * getArray() const
Definition: ndarray_handle.h:47
mxnet::runtime::ObjectRef
Base class of all object reference.
Definition: object.h:500
MXNET_DEFINE_OBJECT_REF_METHODS
#define MXNET_DEFINE_OBJECT_REF_METHODS(TypeName, ParentType, ObjectName)
Definition: object.h:689
ndarray.h
NDArray interface that handles array arithematics.
object.h
A managed object in MXNet runtime.