/*************************************************************************
 * Copyright (C) [2023-2024] by Cambricon, Inc.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
 * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
 * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 *************************************************************************/
#include "comm_overlap.h"
namespace tmo {
namespace torch_api {
#define CNCL_TYPE_AND_SCALAR_TYPE(_) \
  _(cnclFloat, at::kFloat)           \
  _(cnclBfloat16, at::kBFloat16)     \
  _(cnclHalf, at::kHalf)             \
  _(cnclInt32, at::kInt)             \
  _(cnclInt64, at::kLong)            \
  _(cnclInt8, at::kChar)             \
  _(cnclUint8, at::kByte)            \
  _(cnclInt16, at::kShort)

cnclDataType_t getCnclDataType(const at::ScalarType &data_type) {
  switch (data_type) {
#define DEFINE_CASE(cncl_dtype, scalar_type) \
  case scalar_type:                          \
    return cncl_dtype;

    CNCL_TYPE_AND_SCALAR_TYPE(DEFINE_CASE)
#undef DEFINE_CASE
    default:
      std::string msg("getCnclDataType() not supported for ");
      throw std::runtime_error(msg + c10::toString(data_type));
  }
}
}  // namespace torch_api
}  // namespace tmo
