std::pair GetHostSizeAndAlignment()

in lib/core_runtime/op_attrs.cc [142:184]


std::pair<size_t, size_t> GetHostSizeAndAlignment(const void *data,
                                                  OpAttrType type) {
  switch (type) {
    case OpAttrType::DTYPE:
      return {sizeof(OpAttrType), alignof(OpAttrType)};
    case OpAttrType::AGGREGATE: {
      AggregateAttr aggregate_attr(data);
      return {aggregate_attr.GetByteSize(), aggregate_attr.Alignment()};
    }
    case OpAttrType::DENSE: {
      DenseAttr dense_attr(data);
      return {dense_attr.GetByteSize(), dense_attr.Alignment()};
    }
    case OpAttrType::SHAPE: {
      ShapeAttr shape_attr(data);
      return {shape_attr.GetByteSize(), shape_attr.Alignment()};
    }
    case OpAttrType::FUNC:
      return {sizeof(char), alignof(char)};
    case OpAttrType::BF16:
      return {sizeof(bf16), alignof(bf16)};
    case OpAttrType::F16:
      return {sizeof(fp16), alignof(fp16)};
    case OpAttrType::I1:
      return {sizeof(bool), alignof(bool)};
    case OpAttrType::COMPLEX64:
      return {sizeof(std::complex<float>), alignof(std::complex<float>)};
    case OpAttrType::COMPLEX128:
      return {sizeof(std::complex<double>), alignof(std::complex<double>)};
    case OpAttrType::UNSUPPORTED_RESOURCE:
    case OpAttrType::UNSUPPORTED_VARIANT:
    case OpAttrType::UNSUPPORTED_QUI8:
    case OpAttrType::UNSUPPORTED_QUI16:
    case OpAttrType::UNSUPPORTED_QI8:
    case OpAttrType::UNSUPPORTED_QI16:
    case OpAttrType::UNSUPPORTED_QI32:
      llvm_unreachable("unsupported attribute type");
#define OP_ATTR_TYPE(ENUM, CPP_TYPE) \
  case OpAttrType::ENUM:             \
    return {sizeof(CPP_TYPE), alignof(CPP_TYPE)};
#include "tfrt/core_runtime/op_attr_type.def"
  }
}