const char* name,
int pos,
DeviceType device_type,
- DataType data_type) {
+ caffe2::TypeMeta dtype) {
if (expr.device_type() != device_type) {
AT_ERROR(
"Expected object of device type ",
name,
"'");
}
- if (expr.dtype().id() != data_type) {
+ if (expr.dtype() != dtype) {
AT_ERROR(
"Expected object of data type ",
- data_type,
+ dtype,
" but got data type ",
expr.dtype().id(),
" for argument #",
'${arg_name},"${arg_name}",${arg_pos}, '
# We're punning here (Backend and DeviceType constructors coincide)
# but DeviceType is the correct way to classify storages
- 'DeviceType::${Backend}, at::scalarTypeToDataType(ScalarType::${ScalarName}))'),
+ 'DeviceType::${Backend}, at::scalarTypeToTypeMeta(ScalarType::${ScalarName}))'),
'THGenerator*':
CodeTemplate(
'check_generator<${Backend}Generator>(${arg_name}, &globalContext().defaultGenerator(device_type()))'),
#include <cuda_runtime.h>
#include <cuda_fp16.h>
-namespace c10 {
-
-#if defined(__CUDACC__) || defined(__HIP_PLATFORM_HCC__)
-template <>
-struct CTypeToScalarType<__half> : public CTypeToScalarType<Half> {};
-#endif
-
-}
-
THC_API THCStorage* THCStorage_new(THCState* state, caffe2::TypeMeta);
THC_API void THCStorage_retain(THCState *state, THCStorage *storage);
NumOptions
};
-static inline at::DataType scalarTypeToDataType(ScalarType scalar_type) {
-#define DEFINE_CASE(ctype, name, _) \
- case ScalarType::name: \
- return caffe2::TypeIdentifier::Get<ctype>();
-
- switch(scalar_type) {
- AT_FORALL_SCALAR_TYPES_WITH_COMPLEX(DEFINE_CASE)
- case ScalarType::Undefined: return at::DataType::uninitialized();
- default: AT_ERROR("Unrecognized Scalartype ", scalar_type, " (please report this error)");
- }
-#undef DEFINE_CASE
-}
-
static inline caffe2::TypeMeta scalarTypeToTypeMeta(ScalarType scalar_type) {
#define DEFINE_CASE(ctype,name,_) \
case ScalarType:: name : return caffe2::TypeMeta::Make<ctype>();
+++ /dev/null
-#pragma once
-
-#include <c10/core/ScalarType.h>
-
-namespace c10 {
-
-template <typename T>
-struct CTypeToScalarType {
-};
-
-#define DEFINE_TO_SCALAR_TYPE(ct, st, _2) \
-template <> \
-struct CTypeToScalarType<ct> { \
- static inline at::ScalarType to() { return at::ScalarType::st; } \
-};
-AT_FORALL_SCALAR_TYPES_WITH_COMPLEX(DEFINE_TO_SCALAR_TYPE)
-#undef DEFINE_TO_SCALAR_TYPE
-
-} // namespace c10
#include <c10/core/Allocator.h>
#include <c10/core/ScalarType.h>
-#include <c10/core/ScalarTypeUtils.h>
#include <c10/util/intrusive_ptr.h>
template <typename T>
inline T* data() const {
- // TODO: This is bad: it means storage.data<T>() calls only work on
- // T that are valid ScalarType. FIXME!
- auto data_type_T = at::scalarTypeToDataType(c10::CTypeToScalarType<T>::to());
- if (dtype().id() != data_type_T) {
+ auto data_type = caffe2::TypeMeta::Make<T>();
+ if (dtype() != data_type) {
AT_ERROR(
"Attempt to access StorageImpl having data type ",
- dtype().id(),
+ dtype(),
" as data type ",
- data_type_T);
+ data_type);
}
return unsafe_data<T>();
}
#include <c10/core/Backend.h>
#include <c10/core/Layout.h>
#include <c10/core/ScalarType.h>
-#include <c10/core/ScalarTypeUtils.h>
#include <c10/core/Device.h>
#include <c10/util/Optional.h>