| /* |
| * 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 object_internal.h |
| * \brief Expose a few functions for CFFI purposes. |
| * This file is not intended to be used |
| */ |
| // Acknowledgement: This file originates from incubator-tvm |
| #ifndef MXNET_RUNTIME_OBJECT_INTERNAL_H_ |
| #define MXNET_RUNTIME_OBJECT_INTERNAL_H_ |
| |
| #include <mxnet/runtime/object.h> |
| #include <mxnet/runtime/c_runtime_api.h> |
| #include <string> |
| |
| namespace mxnet { |
| namespace runtime { |
| |
| /*! |
| * \brief Internal object namespace to expose |
| * certain util functions for FFI. |
| */ |
| class ObjectInternal { |
| public: |
| /*! |
| * \brief Free an object handle. |
| */ |
| static void ObjectFree(MXNetObjectHandle obj) { |
| if (obj != nullptr) { |
| static_cast<Object*>(obj)->DecRef(); |
| } |
| } |
| |
| /*! |
| * \brief Expose TypeKey2Index |
| * \param type_key The original type key. |
| * \return the corresponding index. |
| */ |
| static uint32_t ObjectTypeKey2Index(const std::string& type_key) { |
| return Object::TypeKey2Index(type_key); |
| } |
| }; |
| |
| } // namespace runtime |
| } // namespace mxnet |
| #endif // MXNET_RUNTIME_OBJECT_INTERNAL_H_ |