From 71ae54d57fc25bbce42cfe1e2bdcd21f55685151 Mon Sep 17 00:00:00 2001 From: Junru Shao Date: Sat, 6 Jun 2020 15:23:20 -0700 Subject: [PATCH] Add some docs on downstream consistency (#5742) https://github.com/apache/incubator-tvm/pull/5730#issuecomment-639567636 --- include/tvm/runtime/c_runtime_api.h | 18 ++++++++++++++---- include/tvm/runtime/data_type.h | 9 ++++++++- 2 files changed, 22 insertions(+), 5 deletions(-) diff --git a/include/tvm/runtime/c_runtime_api.h b/include/tvm/runtime/c_runtime_api.h index be865635456d..bf24f992bda4 100644 --- a/include/tvm/runtime/c_runtime_api.h +++ b/include/tvm/runtime/c_runtime_api.h @@ -87,12 +87,22 @@ typedef enum { } TVMDeviceExtType; /*! - * \brief The type code in used in the TVM FFI for argument passing. + * \brief The type code in used and only used in TVM FFI for argument passing. + * + * DLPack consistency: + * 1) kTVMArgInt is compatible with kDLInt + * 2) kTVMArgFloat is compatible with kDLFloat + * 3) kDLUInt is not in ArgTypeCode, but has a spared slot + * + * Downstream consistency: + * The kDLInt, kDLUInt, kDLFloat are kept consistent with the original ArgType code + * + * It is only used in argument passing, and should not be confused with + * DataType::TypeCode, which is DLPack-compatible. + * + * \sa tvm::runtime::DataType::TypeCode */ typedef enum { - // The type code of other types are compatible with DLPack. - // The next few fields are extension types - // that is used by TVM API calls. kTVMArgInt = kDLInt, kTVMArgFloat = kDLFloat, kTVMOpaqueHandle = 3U, diff --git a/include/tvm/runtime/data_type.h b/include/tvm/runtime/data_type.h index 1d538105f130..b12938bd751a 100644 --- a/include/tvm/runtime/data_type.h +++ b/include/tvm/runtime/data_type.h @@ -40,7 +40,14 @@ namespace runtime { */ class DataType { public: - /*! \brief Type code for the DataType. */ + /*! + * \brief Type code for the DataType. + * + * DLPack consistency: + * 1) kInt is consistent with kDLInt + * 2) kUInt is consistent with kDLUInt + * 3) kFloat is consistent with kDLFloat + */ enum TypeCode { kInt = kDLInt, kUInt = kDLUInt,