Unify all *_EXPORT and *_IMPORT macros across c++ backend (#12019)

Summary:
TSIA. Right now we should basically use C10_EXPORT and C10_IMPORT for explicitly marking dllexport and dllimport, as a continued effort of the C10 unification.

This is a codemod by mechanically doing the following change:

CAFFE2_{EXPORT,IMPORT} -> C10_{EXPORT,IMPORT}
AT_CORE_{EXPORT,IMPORT} -> C10_{EXPORT,IMPORT}
Pull Request resolved: https://github.com/pytorch/pytorch/pull/12019

Reviewed By: ezyang, teng-li

Differential Revision: D10016276

Pulled By: Yangqing

fbshipit-source-id: a420d62c43d1110105fc88f9e9076e28a3203164
This commit is contained in:
Yangqing Jia 2018-09-25 17:28:37 -07:00 committed by Facebook Github Bot
parent 90bcf41291
commit 28dba2f928
71 changed files with 534 additions and 506 deletions

View File

@ -4,5 +4,5 @@
namespace at {
AT_CORE_API int CoreTest();
CAFFE2_API int CoreTest();
}

View File

@ -1,7 +1,3 @@
#pragma once
#include "ATen/core/Macros.h"
// TODO: Merge the *_API macros.
#define AT_EXPORT AT_CORE_EXPORT
#define AT_IMPORT AT_CORE_IMPORT

View File

@ -115,7 +115,7 @@ struct Allocator {
}
};
struct AT_CORE_API InefficientStdFunctionContext {
struct CAFFE2_API InefficientStdFunctionContext {
std::unique_ptr<void, std::function<void(void*)>> ptr_;
InefficientStdFunctionContext(
std::unique_ptr<void, std::function<void(void*)>>&& ptr)

View File

@ -8,7 +8,7 @@
namespace at {
/// Utility to demangle a C++ symbol name.
AT_CORE_API std::string demangle(const char* name);
CAFFE2_API std::string demangle(const char* name);
/// Returns the printable name of the type.
template <typename T>
@ -21,7 +21,7 @@ inline const char* demangle_type() {
#endif // __GXX_RTTI
}
AT_CORE_API std::string get_backtrace(
CAFFE2_API std::string get_backtrace(
size_t frames_to_skip = 0,
size_t maximum_number_of_frames = 64,
bool skip_python_frames = true);

View File

@ -21,7 +21,7 @@ namespace at {
/// 1. A negative index represents the current device, a non-negative index
/// represents a specific, concrete device,
/// 2. When the device type is CPU, the device index must be zero.
struct AT_CORE_API Device {
struct CAFFE2_API Device {
using Type = at::DeviceType;
/// Constructs a new `Device` from a `DeviceType` and an optional device
@ -92,7 +92,7 @@ struct AT_CORE_API Device {
int32_t index_ = -1;
};
AT_CORE_API std::ostream& operator<<(
CAFFE2_API std::ostream& operator<<(
std::ostream& stream,
const at::Device& device);

View File

@ -26,11 +26,11 @@ enum class DeviceType : int32_t {
ONLY_FOR_TEST = 20901701, // This device type is only for test.
};
AT_CORE_API std::string DeviceTypeName(
CAFFE2_API std::string DeviceTypeName(
at::DeviceType d,
bool lower_case = false);
AT_CORE_API std::ostream& operator<<(std::ostream& stream, at::DeviceType type);
CAFFE2_API std::ostream& operator<<(std::ostream& stream, at::DeviceType type);
} // namespace at

View File

@ -19,7 +19,7 @@ namespace at {
namespace detail {
// Obtains the base name from a full path.
AT_CORE_API std::string StripBasename(const std::string& full_path);
CAFFE2_API std::string StripBasename(const std::string& full_path);
inline std::ostream& _str(std::ostream& ss) {
return ss;
@ -56,7 +56,7 @@ inline std::string str(const char* c_str) {
}
/// Represents a location in source code (for debugging).
struct AT_CORE_API SourceLocation {
struct CAFFE2_API SourceLocation {
const char* function;
const char* file;
uint32_t line;
@ -71,7 +71,7 @@ std::ostream& operator<<(std::ostream& out, const SourceLocation& loc);
///
/// NB: at::Error is handled specially by the default torch to suppress the
/// backtrace, see torch/csrc/Exceptions.h
class AT_CORE_API Error : public std::exception {
class CAFFE2_API Error : public std::exception {
std::vector<std::string> msg_stack_;
std::string backtrace_;
@ -128,7 +128,7 @@ class AT_CORE_API Error : public std::exception {
}
};
class AT_CORE_API Warning {
class CAFFE2_API Warning {
using handler_t =
void (*)(const SourceLocation& source_location, const char* msg);
@ -152,7 +152,7 @@ class AT_CORE_API Warning {
// A utility function to return an exception std::string by prepending its
// exception type before its what() content
AT_CORE_API std::string GetExceptionString(const std::exception& e);
CAFFE2_API std::string GetExceptionString(const std::exception& e);
} // namespace at

View File

@ -34,8 +34,8 @@ namespace at {
namespace detail {
AT_CORE_API float halfbits2float(unsigned short bits);
AT_CORE_API unsigned short float2halfbits(float value);
CAFFE2_API float halfbits2float(unsigned short bits);
CAFFE2_API unsigned short float2halfbits(float value);
} // namespace detail
@ -178,7 +178,7 @@ To checked_convert(From f, const char* name) {
return convert<To, From>(f);
}
AT_CORE_API std::ostream& operator<<(std::ostream& out, const Half& value);
CAFFE2_API std::ostream& operator<<(std::ostream& out, const Half& value);
} // namespace at

View File

@ -22,7 +22,7 @@ namespace at {
* for you, given the underlying type supports it.
*/
template <class ConcreteType, class UnderlyingType>
class AT_CORE_API IdWrapper {
class CAFFE2_API IdWrapper {
public:
using underlying_type = UnderlyingType;
using concrete_type = ConcreteType;

View File

@ -30,7 +30,7 @@
namespace at {
struct AT_CORE_API LegacyTypeInitInterface {
struct CAFFE2_API LegacyTypeInitInterface {
virtual ~LegacyTypeInitInterface() {}
virtual void initCPU() const {
AT_ERROR("cannot use CPU without ATen library");
@ -42,15 +42,15 @@ struct AT_CORE_API LegacyTypeInitInterface {
AT_ERROR("cannot use complex without ATen Complex library");
}
};
struct AT_CORE_API LegacyTypeInitArgs {};
struct CAFFE2_API LegacyTypeInitArgs {};
AT_DECLARE_REGISTRY(LegacyTypeInitRegistry, LegacyTypeInitInterface, LegacyTypeInitArgs);
#define REGISTER_LEGACY_TYPE_INIT(clsname) AT_REGISTER_CLASS(LegacyTypeInitRegistry, clsname, clsname)
AT_CORE_API const LegacyTypeInitInterface& getLegacyTypeInit();
CAFFE2_API const LegacyTypeInitInterface& getLegacyTypeInit();
struct Type;
struct AT_CORE_API LegacyTypeDeleter {
struct CAFFE2_API LegacyTypeDeleter {
using TypeDeleterFun = void(Type*);
TypeDeleterFun *fn_ = nullptr;
LegacyTypeDeleter() {}
@ -62,8 +62,8 @@ struct AT_CORE_API LegacyTypeDeleter {
}
};
class AT_CORE_API LegacyTypeDispatch {
public:
class CAFFE2_API LegacyTypeDispatch {
public:
using TypeUniquePtr = std::unique_ptr<Type, LegacyTypeDeleter>;
// WARNING: This function has the precondition that you have
// initialized the type you want to call. This initialization
@ -150,6 +150,6 @@ private:
[static_cast<int>(ScalarType::NumOptions)];
};
AT_CORE_API LegacyTypeDispatch & globalLegacyTypeDispatch();
CAFFE2_API LegacyTypeDispatch& globalLegacyTypeDispatch();
} // namespace at

View File

@ -59,7 +59,7 @@ static inline uint64_t NextPowerOf2(uint64_t A) {
} // namespace detail
/// This is all the non-templated stuff common to all SmallVectors.
class AT_CORE_API SmallVectorBase {
class CAFFE2_API SmallVectorBase {
protected:
void *BeginX, *EndX, *CapacityX;

View File

@ -17,7 +17,7 @@ using _tensorTypeId_underlyingType = uint8_t;
* Dynamic type ID of a Tensor argument. It represents something like
* CPUTensor, etc.
*/
class AT_CORE_API TensorTypeId final
class CAFFE2_API TensorTypeId final
: public at::
IdWrapper<TensorTypeId, details::_tensorTypeId_underlyingType> {
public:
@ -32,10 +32,10 @@ class AT_CORE_API TensorTypeId final
: IdWrapper(id) {}
friend class TensorTypeIdCreator;
friend AT_CORE_API std::ostream& operator<<(std::ostream&, TensorTypeId);
friend CAFFE2_API std::ostream& operator<<(std::ostream&, TensorTypeId);
};
AT_CORE_API std::ostream& operator<<(std::ostream&, at::TensorTypeId);
CAFFE2_API std::ostream& operator<<(std::ostream&, at::TensorTypeId);
} // namespace at

View File

@ -16,7 +16,7 @@
namespace at {
class AT_CORE_API TensorTypeIdCreator final {
class CAFFE2_API TensorTypeIdCreator final {
public:
TensorTypeIdCreator();
@ -29,10 +29,10 @@ class AT_CORE_API TensorTypeIdCreator final {
private:
std::atomic<details::_tensorTypeId_underlyingType> last_id_;
AT_DISABLE_COPY_AND_ASSIGN(TensorTypeIdCreator);
C10_DISABLE_COPY_AND_ASSIGN(TensorTypeIdCreator);
};
class AT_CORE_API TensorTypeIdRegistry final {
class CAFFE2_API TensorTypeIdRegistry final {
public:
TensorTypeIdRegistry();
@ -43,10 +43,10 @@ class AT_CORE_API TensorTypeIdRegistry final {
std::unordered_set<at::TensorTypeId> registeredTypeIds_;
std::mutex mutex_;
AT_DISABLE_COPY_AND_ASSIGN(TensorTypeIdRegistry);
C10_DISABLE_COPY_AND_ASSIGN(TensorTypeIdRegistry);
};
class AT_CORE_API TensorTypeIds final {
class CAFFE2_API TensorTypeIds final {
public:
static TensorTypeIds& singleton();
@ -61,14 +61,14 @@ class AT_CORE_API TensorTypeIds final {
TensorTypeIdCreator creator_;
TensorTypeIdRegistry registry_;
AT_DISABLE_COPY_AND_ASSIGN(TensorTypeIds);
C10_DISABLE_COPY_AND_ASSIGN(TensorTypeIds);
};
inline constexpr at::TensorTypeId TensorTypeIds::undefined() noexcept {
return TensorTypeIdCreator::undefined();
}
class AT_CORE_API TensorTypeIdRegistrar final {
class CAFFE2_API TensorTypeIdRegistrar final {
public:
TensorTypeIdRegistrar();
~TensorTypeIdRegistrar();
@ -78,14 +78,15 @@ class AT_CORE_API TensorTypeIdRegistrar final {
private:
at::TensorTypeId id_;
AT_DISABLE_COPY_AND_ASSIGN(TensorTypeIdRegistrar);
C10_DISABLE_COPY_AND_ASSIGN(TensorTypeIdRegistrar);
};
inline at::TensorTypeId TensorTypeIdRegistrar::id() const noexcept {
return id_;
}
#define AT_DECLARE_TENSOR_TYPE(TensorName) AT_CORE_API at::TensorTypeId TensorName();
#define AT_DECLARE_TENSOR_TYPE(TensorName) \
CAFFE2_API at::TensorTypeId TensorName();
#define AT_DEFINE_TENSOR_TYPE(TensorName) \
at::TensorTypeId TensorName() { \

View File

@ -10,7 +10,7 @@ using DeleterFnPtr = void (*)(void*);
namespace detail {
// Does not delete anything
AT_CORE_API void deleteNothing(void*);
CAFFE2_API void deleteNothing(void*);
// A detail::UniqueVoidPtr is an owning smart pointer like unique_ptr, but
// with three major differences:

View File

@ -25,7 +25,7 @@ class BaseContext;
functions that are invoked statically before in Tensor class, e.g. New,
We will merge this with Allocator later.
*/
class AT_CORE_API BaseStaticContext {
class CAFFE2_API BaseStaticContext {
public:
virtual ~BaseStaticContext() noexcept {}
@ -55,7 +55,7 @@ class AT_CORE_API BaseStaticContext {
* functions in the BaseContext class.
* TODO: add docs after this is finalized.
*/
class AT_CORE_API BaseContext {
class CAFFE2_API BaseContext {
public:
virtual ~BaseContext() noexcept {}

View File

@ -33,7 +33,7 @@ namespace c10 {
// tells us if the object was allocated by us. If it wasn't, no
// intrusive_ptr for you!
class AT_CORE_API intrusive_ptr_target {
class CAFFE2_API intrusive_ptr_target {
// Note [Weak references for intrusive refcounting]
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Here's the scheme:
@ -114,7 +114,7 @@ class AT_CORE_API intrusive_ptr_target {
namespace detail {
template <class TTarget>
struct AT_CORE_EXPORT intrusive_target_default_null_type final {
struct C10_EXPORT intrusive_target_default_null_type final {
static constexpr TTarget* singleton() noexcept {
return nullptr;
}
@ -136,7 +136,7 @@ class weak_intrusive_ptr;
template <
class TTarget,
class NullType = detail::intrusive_target_default_null_type<TTarget>>
class AT_CORE_EXPORT intrusive_ptr final {
class C10_EXPORT intrusive_ptr final {
private:
static_assert(
std::is_base_of<intrusive_ptr_target, TTarget>::value,
@ -391,7 +391,7 @@ inline bool operator!=(
template <
typename TTarget,
class NullType = detail::intrusive_target_default_null_type<TTarget>>
class AT_CORE_EXPORT weak_intrusive_ptr final {
class C10_EXPORT weak_intrusive_ptr final {
private:
static_assert(
std::is_base_of<intrusive_ptr_target, TTarget>::value,
@ -739,13 +739,13 @@ namespace std {
// To allow intrusive_ptr and weak_intrusive_ptr inside std::unordered_map or
// std::unordered_set, we need std::hash
template <class TTarget, class NullType>
struct AT_CORE_EXPORT hash<c10::intrusive_ptr<TTarget, NullType>> {
struct C10_EXPORT hash<c10::intrusive_ptr<TTarget, NullType>> {
size_t operator()(const c10::intrusive_ptr<TTarget, NullType>& x) const {
return std::hash<TTarget*>()(x.get());
}
};
template <class TTarget, class NullType>
struct AT_CORE_EXPORT hash<c10::weak_intrusive_ptr<TTarget, NullType>> {
struct C10_EXPORT hash<c10::weak_intrusive_ptr<TTarget, NullType>> {
size_t operator()(const c10::weak_intrusive_ptr<TTarget, NullType>& x) const {
return std::hash<TTarget*>()(x._unsafe_get_target());
}

View File

@ -34,7 +34,7 @@ struct CAFFE2_API ConstantString final : c10::intrusive_ptr_target {
// non-mutable list
template <typename Elem>
struct AT_CORE_EXPORT ConstantList final : c10::intrusive_ptr_target {
struct C10_EXPORT ConstantList final : c10::intrusive_ptr_target {
private:
const std::vector<Elem> elements_;
public:

View File

@ -47,7 +47,8 @@ class TypeMeta;
* use TypeIdentifier with custom types. This is for example used to store the
* dtype of tensors.
*/
class AT_CORE_API TypeIdentifier final : public at::IdWrapper<TypeIdentifier, uint16_t> {
class CAFFE2_API TypeIdentifier final
: public at::IdWrapper<TypeIdentifier, uint16_t> {
public:
static TypeIdentifier createTypeId();
@ -90,8 +91,8 @@ AT_DEFINE_HASH_FOR_IDWRAPPER(caffe2::TypeIdentifier)
namespace caffe2 {
AT_CORE_API std::unordered_map<TypeIdentifier, std::string>& gTypeNames();
AT_CORE_API std::unordered_set<std::string>& gRegisteredTypeNames();
CAFFE2_API std::unordered_map<TypeIdentifier, std::string>& gTypeNames();
CAFFE2_API std::unordered_set<std::string>& gRegisteredTypeNames();
inline const char* TypeIdentifier::name() const noexcept {
auto it = gTypeNames().find(*this);
@ -99,7 +100,7 @@ inline const char* TypeIdentifier::name() const noexcept {
return it->second.c_str();
}
AT_CORE_API std::mutex& gTypeRegistrationMutex();
CAFFE2_API std::mutex& gTypeRegistrationMutex();
template <typename T>
struct TypeNameRegisterer {
@ -146,7 +147,7 @@ struct TypeNameRegisterer {
* stores some additional data such as the item size and the name of the type
* for run-time inspection.
*/
class AT_CORE_API TypeMeta {
class CAFFE2_API TypeMeta {
public:
using PlacementNew = void(void*, size_t);
using TypedCopy = void(const void*, void*, size_t);
@ -247,7 +248,7 @@ class AT_CORE_API TypeMeta {
* is generated during run-time. Do NOT serialize the id for storage.
*/
template <typename T>
AT_CORE_API static TypeIdentifier Id();
CAFFE2_API static TypeIdentifier Id();
/**
* Returns the item size of the type. This is equivalent to sizeof(T).
@ -403,20 +404,16 @@ inline bool operator!=(const TypeMeta& lhs, const TypeMeta& rhs) noexcept {
*
* NOTE: the macro needs to be invoked in ::caffe2 namespace
*/
// Implementation note: in MSVC, we will need to prepend the AT_CORE_API
// Implementation note: in MSVC, we will need to prepend the CAFFE2_API
// keyword in order to get things compiled properly. in Linux, gcc seems to
// create attribute ignored error for explicit template instantiations, see
// http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2017/p0537r0.html
// https://gcc.gnu.org/bugzilla/show_bug.cgi?id=51930
// and as a result, we define these two macros slightly differently.
// TODO(jiayq): AT_CORE_API below is not correct, because we may use the
// definition in third party dependent libraries. The proper way is to use
// CAFFE2_EXPORT (which explicitly requires dllexport). Marking this as a
// todo item when the unified build is finished.
#ifdef _MSC_VER
#define CAFFE_KNOWN_TYPE(T) \
template <> \
AT_CORE_EXPORT TypeIdentifier TypeMeta::Id<T>() { \
C10_EXPORT TypeIdentifier TypeMeta::Id<T>() { \
static const TypeIdentifier type_id = TypeIdentifier::createTypeId(); \
static TypeNameRegisterer<T> registerer(type_id, #T); \
return type_id; \
@ -438,10 +435,10 @@ inline bool operator!=(const TypeMeta& lhs, const TypeMeta& rhs) noexcept {
* for your own types to allocate dynamic ids for them.
*/
#ifdef _MSC_VER
#define CAFFE_DECLARE_KNOWN_TYPE(PreallocatedId, T) \
template <> \
inline AT_CORE_API TypeIdentifier TypeMeta::Id<T>() { \
return TypeIdentifier(PreallocatedId); \
#define CAFFE_DECLARE_KNOWN_TYPE(PreallocatedId, T) \
template <> \
inline CAFFE2_API TypeIdentifier TypeMeta::Id<T>() { \
return TypeIdentifier(PreallocatedId); \
}
#else // _MSC_VER
#define CAFFE_DECLARE_KNOWN_TYPE(PreallocatedId, T) \

View File

@ -20,6 +20,11 @@ file(GLOB_RECURSE C10_HEADERS *.h)
add_library(c10 ${C10_SRCS} ${C10_HEADERS})
# If building shared library, set dllimport/dllexport proper.
target_compile_options(c10 PRIVATE "-DC10_BUILD_MAIN_LIB")
# Enable hidden visibility if compiler supports it.
if (${COMPILER_SUPPORTS_HIDDEN_VISIBILITY})
target_compile_options(c10 PRIVATE "-fvisibility=hidden")
endif()
target_include_directories(
c10 PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/../>

View File

@ -5,16 +5,3 @@
*/
#pragma once
// Note: this is for caffe2/*. Will need to codemod to use direct C10.
#define CAFFE2_EXPORT C10_EXPORT
#define CAFFE2_IMPORT C10_IMPORT
// Note: this is for aten/src/*. Will need to codemod.
#define AT_CORE_API CAFFE2_API
#define AT_CORE_EXPORT C10_EXPORT
#define AT_CORE_IMPORT C10_IMPORT
// Note: this is for both aten and c2, due to cross reference between c2 and
// aten that we try to unentangle. Will need to codemod.
#define AT_DISABLE_COPY_AND_ASSIGN C10_DISABLE_COPY_AND_ASSIGN

View File

@ -72,7 +72,7 @@ class NCCLContext {
cudaEvent_t master_event_;
std::vector<cudaEvent_t> events_;
AT_DISABLE_COPY_AND_ASSIGN(NCCLContext);
C10_DISABLE_COPY_AND_ASSIGN(NCCLContext);
};
// We share the contexts across multiple operators, hence the

View File

@ -219,7 +219,7 @@ class CAFFE2_API Blob final {
void* pointer_ = nullptr;
DestroyCall* destroy_ = nullptr;
AT_DISABLE_COPY_AND_ASSIGN(Blob);
C10_DISABLE_COPY_AND_ASSIGN(Blob);
};
inline void swap(Blob& lhs, Blob& rhs) {

View File

@ -258,7 +258,7 @@ class cudnnTensorDescWrapper {
cudnnTensorFormat_t format_;
cudnnDataType_t type_;
vector<int> dims_;
AT_DISABLE_COPY_AND_ASSIGN(cudnnTensorDescWrapper);
C10_DISABLE_COPY_AND_ASSIGN(cudnnTensorDescWrapper);
};
class cudnnFilterDescWrapper {
@ -312,7 +312,7 @@ class cudnnFilterDescWrapper {
StorageOrder order_;
cudnnDataType_t type_;
vector<int> dims_;
AT_DISABLE_COPY_AND_ASSIGN(cudnnFilterDescWrapper);
C10_DISABLE_COPY_AND_ASSIGN(cudnnFilterDescWrapper);
};

View File

@ -89,7 +89,7 @@ class CuDNNState {
cudaStream_t stream_{nullptr};
CuDNNWorkspace workspace_;
size_t gpu_id_{0};
AT_DISABLE_COPY_AND_ASSIGN(CuDNNState);
C10_DISABLE_COPY_AND_ASSIGN(CuDNNState);
};
/**
@ -153,7 +153,7 @@ class CuDNNWrapper {
CAFFE2_COMPILE_TIME_MAX_GPUS>;
static PerGPUCuDNNStates& cudnn_states();
AT_DISABLE_COPY_AND_ASSIGN(CuDNNWrapper);
C10_DISABLE_COPY_AND_ASSIGN(CuDNNWrapper);
};
}; // namespace caffe2

View File

@ -119,7 +119,7 @@ class MiniDBTransaction : public Transaction {
FILE* file_;
std::lock_guard<std::mutex> lock_;
AT_DISABLE_COPY_AND_ASSIGN(MiniDBTransaction);
C10_DISABLE_COPY_AND_ASSIGN(MiniDBTransaction);
};
class MiniDB : public DB {

View File

@ -52,7 +52,7 @@ class CAFFE2_API Cursor {
*/
virtual bool Valid() = 0;
AT_DISABLE_COPY_AND_ASSIGN(Cursor);
C10_DISABLE_COPY_AND_ASSIGN(Cursor);
};
/**
@ -71,7 +71,7 @@ class CAFFE2_API Transaction {
*/
virtual void Commit() = 0;
AT_DISABLE_COPY_AND_ASSIGN(Transaction);
C10_DISABLE_COPY_AND_ASSIGN(Transaction);
};
/**
@ -99,7 +99,7 @@ class CAFFE2_API DB {
protected:
Mode mode_;
AT_DISABLE_COPY_AND_ASSIGN(DB);
C10_DISABLE_COPY_AND_ASSIGN(DB);
};
// Database classes are registered by their names so we can do optional
@ -285,7 +285,7 @@ class CAFFE2_API DBReader {
uint32_t num_shards_;
uint32_t shard_id_;
AT_DISABLE_COPY_AND_ASSIGN(DBReader);
C10_DISABLE_COPY_AND_ASSIGN(DBReader);
};
class CAFFE2_API DBReaderSerializer : public BlobSerializerBase {

View File

@ -57,7 +57,7 @@ private:
const typename Schema::dispatch::dispatch_key_type dispatch_key_;
bool owns_registration_;
AT_DISABLE_COPY_AND_ASSIGN(KernelRegistrar);
C10_DISABLE_COPY_AND_ASSIGN(KernelRegistrar);
};
/**

View File

@ -9,7 +9,7 @@ namespace caffe2 {
#ifdef CAFFE2_USE_GFLAGS
CAFFE2_EXPORT void SetUsageMessage(const string& str) {
C10_EXPORT void SetUsageMessage(const string& str) {
if (UsageMessage() != nullptr) {
// Usage message has already been set, so we will simply return.
return;
@ -17,16 +17,16 @@ CAFFE2_EXPORT void SetUsageMessage(const string& str) {
gflags::SetUsageMessage(str);
}
CAFFE2_EXPORT const char* UsageMessage() {
C10_EXPORT const char* UsageMessage() {
return gflags::ProgramUsage();
}
CAFFE2_EXPORT bool ParseCaffeCommandLineFlags(int* pargc, char*** pargv) {
C10_EXPORT bool ParseCaffeCommandLineFlags(int* pargc, char*** pargv) {
if (*pargc == 0) return true;
return gflags::ParseCommandLineFlags(pargc, pargv, true);
}
CAFFE2_EXPORT bool CommandLineFlagsHasBeenParsed() {
C10_EXPORT bool CommandLineFlagsHasBeenParsed() {
// There is no way we query gflags right now, so we will simply return true.
return true;
}
@ -48,11 +48,14 @@ std::stringstream& GlobalInitStream() {
static string gUsageMessage = "(Usage message not set.)";
}
C10_EXPORT void SetUsageMessage(const string& str) {
gUsageMessage = str;
}
C10_EXPORT const char* UsageMessage() {
return gUsageMessage.c_str();
}
CAFFE2_EXPORT void SetUsageMessage(const string& str) { gUsageMessage = str; }
CAFFE2_EXPORT const char* UsageMessage() { return gUsageMessage.c_str(); }
CAFFE2_EXPORT bool ParseCaffeCommandLineFlags(int* pargc, char*** pargv) {
C10_EXPORT bool ParseCaffeCommandLineFlags(int* pargc, char*** pargv) {
if (*pargc == 0) return true;
char** argv = *pargv;
bool success = true;
@ -136,18 +139,22 @@ CAFFE2_EXPORT bool ParseCaffeCommandLineFlags(int* pargc, char*** pargv) {
return success;
}
CAFFE2_EXPORT bool CommandLineFlagsHasBeenParsed() {
C10_EXPORT bool CommandLineFlagsHasBeenParsed() {
return gCommandLineFlagsParsed;
}
template <>
CAFFE2_EXPORT bool Caffe2FlagParser::Parse<string>(const string& content, string* value) {
C10_EXPORT bool Caffe2FlagParser::Parse<string>(
const string& content,
string* value) {
*value = content;
return true;
}
template <>
CAFFE2_EXPORT bool Caffe2FlagParser::Parse<int>(const string& content, int* value) {
C10_EXPORT bool Caffe2FlagParser::Parse<int>(
const string& content,
int* value) {
try {
*value = std::atoi(content.c_str());
return true;
@ -159,7 +166,9 @@ CAFFE2_EXPORT bool Caffe2FlagParser::Parse<int>(const string& content, int* valu
}
template <>
CAFFE2_EXPORT bool Caffe2FlagParser::Parse<int64_t>(const string& content, int64_t* value) {
C10_EXPORT bool Caffe2FlagParser::Parse<int64_t>(
const string& content,
int64_t* value) {
try {
static_assert(sizeof(long long) == sizeof(int64_t), "");
#ifdef __ANDROID__
@ -177,7 +186,9 @@ CAFFE2_EXPORT bool Caffe2FlagParser::Parse<int64_t>(const string& content, int64
}
template <>
CAFFE2_EXPORT bool Caffe2FlagParser::Parse<double>(const string& content, double* value) {
C10_EXPORT bool Caffe2FlagParser::Parse<double>(
const string& content,
double* value) {
try {
*value = std::atof(content.c_str());
return true;
@ -190,7 +201,9 @@ CAFFE2_EXPORT bool Caffe2FlagParser::Parse<double>(const string& content, double
}
template <>
CAFFE2_EXPORT bool Caffe2FlagParser::Parse<bool>(const string& content, bool* value) {
C10_EXPORT bool Caffe2FlagParser::Parse<bool>(
const string& content,
bool* value) {
if (content == "false" || content == "False" || content == "FALSE" ||
content == "0") {
*value = false;

View File

@ -79,14 +79,14 @@ namespace gflags = google;
// (3) Gflags has a design issue that does not properly expose the global flags,
// if one builds the library with -fvisibility=hidden. The current gflags (as of
// Aug 2018) only deals with the Windows case using dllexport, and not the Linux
// counterparts. As a result, we will explciitly use CAFFE2_EXPORT to export the
// counterparts. As a result, we will explciitly use C10_EXPORT to export the
// flags defined in Caffe2. This is done via a global reference, so the flag
// itself is not duplicated - under the hood it is the same global gflags flag.
#define CAFFE2_GFLAGS_DEF_WRAPPER( \
type, real_type, name, default_value, help_str) \
DEFINE_##type(name, default_value, help_str); \
namespace caffe2 { \
CAFFE2_EXPORT real_type& FLAGS_##name = ::FLAGS_##name; \
#define CAFFE2_GFLAGS_DEF_WRAPPER( \
type, real_type, name, default_value, help_str) \
DEFINE_##type(name, default_value, help_str); \
namespace caffe2 { \
C10_EXPORT real_type& FLAGS_##name = ::FLAGS_##name; \
}
#define CAFFE2_DEFINE_int(name, default_value, help_str) \
@ -102,11 +102,11 @@ namespace gflags = google;
string, ::fLS::clstring, name, default_value, help_str)
// DECLARE_typed_var should be used in header files and in the global namespace.
#define CAFFE2_GFLAGS_DECLARE_WRAPPER(type, real_type, name) \
DECLARE_##type(name); \
namespace caffe2 { \
CAFFE2_IMPORT extern real_type& FLAGS_##name; \
} // namespace caffe2
#define CAFFE2_GFLAGS_DECLARE_WRAPPER(type, real_type, name) \
DECLARE_##type(name); \
namespace caffe2 { \
C10_IMPORT extern real_type& FLAGS_##name; \
} // namespace caffe2
#define CAFFE2_DECLARE_int(name) \
CAFFE2_GFLAGS_DECLARE_WRAPPER(int32, gflags::int32, name)
@ -150,22 +150,22 @@ CAFFE_DECLARE_REGISTRY(Caffe2FlagsRegistry, Caffe2FlagParser, const string&);
// write the CAFFE2_DEFINE_* and CAFFE2_DECLARE_* macros outside any namespace
// as well.
#define CAFFE2_DEFINE_typed_var(type, name, default_value, help_str) \
namespace caffe2 { \
CAFFE2_EXPORT type FLAGS_##name = default_value; \
namespace { \
class Caffe2FlagParser_##name : public Caffe2FlagParser { \
public: \
explicit Caffe2FlagParser_##name(const string& content) { \
success_ = Caffe2FlagParser::Parse<type>(content, &FLAGS_##name); \
} \
}; \
} \
RegistererCaffe2FlagsRegistry g_Caffe2FlagsRegistry_##name( \
#name, \
Caffe2FlagsRegistry(), \
RegistererCaffe2FlagsRegistry::DefaultCreator<Caffe2FlagParser_##name>, \
"(" #type ", default " #default_value ") " help_str); \
#define CAFFE2_DEFINE_typed_var(type, name, default_value, help_str) \
namespace caffe2 { \
C10_EXPORT type FLAGS_##name = default_value; \
namespace { \
class Caffe2FlagParser_##name : public Caffe2FlagParser { \
public: \
explicit Caffe2FlagParser_##name(const string& content) { \
success_ = Caffe2FlagParser::Parse<type>(content, &FLAGS_##name); \
} \
}; \
} \
RegistererCaffe2FlagsRegistry g_Caffe2FlagsRegistry_##name( \
#name, \
Caffe2FlagsRegistry(), \
RegistererCaffe2FlagsRegistry::DefaultCreator<Caffe2FlagParser_##name>, \
"(" #type ", default " #default_value ") " help_str); \
}
#define CAFFE2_DEFINE_int(name, default_value, help_str) \
@ -180,9 +180,9 @@ CAFFE_DECLARE_REGISTRY(Caffe2FlagsRegistry, Caffe2FlagParser, const string&);
CAFFE2_DEFINE_typed_var(string, name, default_value, help_str)
// DECLARE_typed_var should be used in header files and in the global namespace.
#define CAFFE2_DECLARE_typed_var(type, name) \
namespace caffe2 { \
CAFFE2_IMPORT extern type FLAGS_##name; \
#define CAFFE2_DECLARE_typed_var(type, name) \
namespace caffe2 { \
C10_IMPORT extern type FLAGS_##name; \
} // namespace caffe2
#define CAFFE2_DECLARE_int(name) CAFFE2_DECLARE_typed_var(int, name)

View File

@ -164,7 +164,7 @@ class miopenTensorDescWrapper
miopenTensorDescriptor_t desc_;
miopenDataType_t type_;
vector<int> dims_;
AT_DISABLE_COPY_AND_ASSIGN(miopenTensorDescWrapper);
C10_DISABLE_COPY_AND_ASSIGN(miopenTensorDescWrapper);
};
} // namespace caffe2

View File

@ -92,7 +92,7 @@ class MIOPENState
hipStream_t stream_{nullptr};
MIOPENWorkspace workspace_;
size_t gpu_id_{0};
AT_DISABLE_COPY_AND_ASSIGN(MIOPENState);
C10_DISABLE_COPY_AND_ASSIGN(MIOPENState);
};
/**
@ -157,7 +157,7 @@ class MIOPENWrapper
CAFFE2_COMPILE_TIME_MAX_HIP_GPUS>;
static PerGPUMIOPENStates& miopen_states();
AT_DISABLE_COPY_AND_ASSIGN(MIOPENWrapper);
C10_DISABLE_COPY_AND_ASSIGN(MIOPENWrapper);
};
}; // namespace caffe2

View File

@ -58,7 +58,7 @@ class ProfiledRange
ProfiledRange(const OperatorDef& def, Color color) {}
private:
AT_DISABLE_COPY_AND_ASSIGN(ProfiledRange);
C10_DISABLE_COPY_AND_ASSIGN(ProfiledRange);
};
} // namespace

View File

@ -124,7 +124,7 @@ class CAFFE2_API NetBase : public Observable<NetBase> {
string name_;
vector<const Event*> events_;
std::shared_ptr<const NetDef> net_def_;
AT_DISABLE_COPY_AND_ASSIGN(NetBase);
C10_DISABLE_COPY_AND_ASSIGN(NetBase);
};
class CAFFE2_API ExecutorHelper {

View File

@ -125,7 +125,7 @@ class CAFFE2_API AsyncNetBase : public NetBase {
bool use_per_net_pools_;
bool is_blocking_;
AT_DISABLE_COPY_AND_ASSIGN(AsyncNetBase);
C10_DISABLE_COPY_AND_ASSIGN(AsyncNetBase);
private:
void storeExceptionPtr();

View File

@ -71,7 +71,7 @@ class ProfiledRange {
private:
nvtxRangeId_t range_ = 0;
AT_DISABLE_COPY_AND_ASSIGN(ProfiledRange);
C10_DISABLE_COPY_AND_ASSIGN(ProfiledRange);
};
#else
@ -81,7 +81,7 @@ class ProfiledRange {
ProfiledRange(const OperatorDef& def, Color color) {}
private:
AT_DISABLE_COPY_AND_ASSIGN(ProfiledRange);
C10_DISABLE_COPY_AND_ASSIGN(ProfiledRange);
};
#endif // ifdef CAFFE2_USE_NVTX

View File

@ -32,7 +32,7 @@ class AsyncDAGNet : public DAGNetBase {
int stream(const DeviceOption& device_option);
static thread_local std::vector<int> stream_counters_;
AT_DISABLE_COPY_AND_ASSIGN(AsyncDAGNet);
C10_DISABLE_COPY_AND_ASSIGN(AsyncDAGNet);
};
} // namespace caffe2

View File

@ -40,7 +40,7 @@ class AsyncPollingNet : public AsyncNetBase {
void reset() override;
std::atomic<bool> has_chain_failed_;
AT_DISABLE_COPY_AND_ASSIGN(AsyncPollingNet);
C10_DISABLE_COPY_AND_ASSIGN(AsyncPollingNet);
};
} // namespace caffe2

View File

@ -30,7 +30,7 @@ class CAFFE2_API AsyncSchedulingNet : public AsyncNetBase {
std::atomic<int> processed_tasks_num_;
AT_DISABLE_COPY_AND_ASSIGN(AsyncSchedulingNet);
C10_DISABLE_COPY_AND_ASSIGN(AsyncSchedulingNet);
};
} // namespace caffe2

View File

@ -84,7 +84,7 @@ class CAFFE2_API DAGNetBase : public NetBase {
mutable std::vector<DAGNetStats> stats_;
std::unordered_map<int, std::unique_ptr<Timer>> task_timers_;
AT_DISABLE_COPY_AND_ASSIGN(DAGNetBase);
C10_DISABLE_COPY_AND_ASSIGN(DAGNetBase);
};
class CAFFE2_API DAGNet : public DAGNetBase {

View File

@ -48,7 +48,7 @@ class CAFFE2_API SimpleNet : public NetBase {
vector<unique_ptr<OperatorBase>> operators_;
AT_DISABLE_COPY_AND_ASSIGN(SimpleNet);
C10_DISABLE_COPY_AND_ASSIGN(SimpleNet);
};
} // namespace caffe2

View File

@ -43,7 +43,7 @@ class AsyncSimpleNet : public NetBase {
vector<unique_ptr<OperatorBase>> operators_;
AT_DISABLE_COPY_AND_ASSIGN(AsyncSimpleNet);
C10_DISABLE_COPY_AND_ASSIGN(AsyncSimpleNet);
};
} // namespace caffe2

View File

@ -259,7 +259,7 @@ template <bool B, class T = void>
using enable_if_t = typename std::enable_if<B, T>::type;
template <typename T, typename U>
struct CAFFE2_EXPORT inheritedFrom {
struct C10_EXPORT inheritedFrom {
static constexpr bool value =
std::is_base_of<U, T>::value && !std::is_same<U, T>::value;
};
@ -267,14 +267,15 @@ struct CAFFE2_EXPORT inheritedFrom {
// This is just a way to fix issues when the isa<> implementation
// can't automatically downcast.
template <typename T, typename N, typename = void>
struct CAFFE2_EXPORT is_impl {
struct C10_EXPORT is_impl {
inline static bool impl(N n) {
return isa<T>(n->data());
}
};
template <typename T, typename N>
struct CAFFE2_EXPORT is_impl<T, N, enable_if_t<inheritedFrom<T, NeuralNetOperator>::value>> {
struct C10_EXPORT
is_impl<T, N, enable_if_t<inheritedFrom<T, NeuralNetOperator>::value>> {
inline static bool impl(N n) {
if (!isa<NeuralNetOperator>(n->data().get())) {
return false;
@ -285,7 +286,8 @@ struct CAFFE2_EXPORT is_impl<T, N, enable_if_t<inheritedFrom<T, NeuralNetOperato
};
template <typename T, typename N>
struct CAFFE2_EXPORT is_impl<T, N, enable_if_t<inheritedFrom<T, NeuralNetData>::value>> {
struct C10_EXPORT
is_impl<T, N, enable_if_t<inheritedFrom<T, NeuralNetData>::value>> {
inline static bool impl(N n) {
if (!isa<NeuralNetData>(n->data().get())) {
return false;
@ -303,14 +305,15 @@ inline bool is(N n) {
// This is just a way to fix issues when the dyn_cast<> implementation
// can't automatically downcast.
template <typename T, typename N, typename = void>
struct CAFFE2_EXPORT get_impl {
struct C10_EXPORT get_impl {
inline static T* impl(N n) {
return dyn_cast<T>(n->data().get());
}
};
template <typename T, typename N>
struct CAFFE2_EXPORT get_impl<T, N, enable_if_t<inheritedFrom<T, NeuralNetOperator>::value>> {
struct C10_EXPORT
get_impl<T, N, enable_if_t<inheritedFrom<T, NeuralNetOperator>::value>> {
inline static T* impl(N n) {
if (!is<T>(n)) {
assert(0 && "Cannot get type from node");
@ -322,7 +325,8 @@ struct CAFFE2_EXPORT get_impl<T, N, enable_if_t<inheritedFrom<T, NeuralNetOperat
};
template <typename T, typename N>
struct CAFFE2_EXPORT get_impl<T, N, enable_if_t<inheritedFrom<T, NeuralNetData>::value>> {
struct C10_EXPORT
get_impl<T, N, enable_if_t<inheritedFrom<T, NeuralNetData>::value>> {
inline static T* impl(N n) {
if (!is<T>(n)) {
assert(0 && "Cannot get type from node");
@ -422,7 +426,7 @@ CAFFE2_API std::vector<NNGraph::NodeRef> getOutputs(NNGraph::NodeRef n);
CAFFE2_API void coalesceInsertedDataDependencies(repr::NNModule* m);
template <NNGraph* G>
struct CAFFE2_EXPORT NodeHelper {};
struct C10_EXPORT NodeHelper {};
struct NNNodeMatchCriteria {
std::function<bool(NNGraph::NodeRef)> predicate;

View File

@ -51,7 +51,7 @@ class Observable {
virtual ~Observable() = default;
AT_DISABLE_COPY_AND_ASSIGN(Observable);
C10_DISABLE_COPY_AND_ASSIGN(Observable);
using Observer = ObserverBase<T>;

View File

@ -397,7 +397,7 @@ class CAFFE2_API OperatorBase : public Observable<OperatorBase> {
// An event used by asynchronous execution.
std::unique_ptr<Event> event_;
AT_DISABLE_COPY_AND_ASSIGN(OperatorBase);
C10_DISABLE_COPY_AND_ASSIGN(OperatorBase);
};
// If your operator does not need any specialized contructor or destructor,
@ -825,7 +825,7 @@ CAFFE_DECLARE_REGISTRY(
#define REGISTER_CPU_OPERATOR_CREATOR(key, ...) \
CAFFE_REGISTER_CREATOR(CPUOperatorRegistry, key, __VA_ARGS__)
#define REGISTER_CPU_OPERATOR(name, ...) \
CAFFE2_IMPORT void CAFFE2_PLEASE_ADD_OPERATOR_SCHEMA_FOR_##name();\
C10_IMPORT void CAFFE2_PLEASE_ADD_OPERATOR_SCHEMA_FOR_##name(); \
static void CAFFE2_UNUSED CAFFE_ANONYMOUS_VARIABLE_CPU##name() { \
CAFFE2_PLEASE_ADD_OPERATOR_SCHEMA_FOR_##name(); \
} \
@ -844,7 +844,7 @@ CAFFE_DECLARE_REGISTRY(
#define REGISTER_CUDA_OPERATOR_CREATOR(key, ...) \
CAFFE_REGISTER_CREATOR(CUDAOperatorRegistry, key, __VA_ARGS__)
#define REGISTER_CUDA_OPERATOR(name, ...) \
CAFFE2_IMPORT void CAFFE2_PLEASE_ADD_OPERATOR_SCHEMA_FOR_##name(); \
C10_IMPORT void CAFFE2_PLEASE_ADD_OPERATOR_SCHEMA_FOR_##name(); \
static void CAFFE2_UNUSED CAFFE_ANONYMOUS_VARIABLE_CUDA##name() { \
CAFFE2_PLEASE_ADD_OPERATOR_SCHEMA_FOR_##name(); \
} \
@ -869,10 +869,10 @@ CAFFE_DECLARE_REGISTRY(
#define REGISTER_HIP_OPERATOR_CREATOR(key, ...) \
CAFFE_REGISTER_CREATOR(HIPOperatorRegistry, key, __VA_ARGS__)
#define REGISTER_HIP_OPERATOR(name, ...) \
CAFFE2_IMPORT void CAFFE2_PLEASE_ADD_OPERATOR_SCHEMA_FOR_##name(); \
C10_IMPORT void CAFFE2_PLEASE_ADD_OPERATOR_SCHEMA_FOR_##name(); \
static void CAFFE2_UNUSED CAFFE_ANONYMOUS_VARIABLE_HIP##name() { \
CAFFE2_PLEASE_ADD_OPERATOR_SCHEMA_FOR_##name(); \
} \
CAFFE2_PLEASE_ADD_OPERATOR_SCHEMA_FOR_##name(); \
} \
CAFFE_REGISTER_CLASS(HIPOperatorRegistry, name, __VA_ARGS__)
#define REGISTER_HIP_OPERATOR_STR(str_name, ...) \
CAFFE_REGISTER_TYPED_CLASS(HIPOperatorRegistry, str_name, __VA_ARGS__)

View File

@ -415,7 +415,7 @@ std::vector<TensorFiller> OpSchema::SupplyDenseFillers(
return fillers;
}
CAFFE2_EXPORT std::ostream& operator<<(std::ostream& out, const OpSchema& schema) {
C10_EXPORT std::ostream& operator<<(std::ostream& out, const OpSchema& schema) {
if (!schema.args().empty()) {
out << "Arguments:" << std::endl;
for (const auto& arg : schema.args()) {

View File

@ -576,16 +576,16 @@ OpSchema::Cost PointwiseCostInference(
#ifndef CAFFE2_NO_OPERATOR_SCHEMA
#define OPERATOR_SCHEMA(name) \
CAFFE2_EXPORT void CAFFE2_PLEASE_ADD_OPERATOR_SCHEMA_FOR_##name(){}; \
static OpSchema* CAFFE_ANONYMOUS_VARIABLE(name) CAFFE2_UNUSED = \
#define OPERATOR_SCHEMA(name) \
C10_EXPORT void CAFFE2_PLEASE_ADD_OPERATOR_SCHEMA_FOR_##name(){}; \
static OpSchema* CAFFE_ANONYMOUS_VARIABLE(name) CAFFE2_UNUSED = \
&OpSchemaRegistry::NewSchema(#name, __FILE__, __LINE__)
#else // CAFFE2_NO_OPERATOR_SCHEMA
#define OPERATOR_SCHEMA(name) \
CAFFE2_EXPORT void CAFFE2_PLEASE_ADD_OPERATOR_SCHEMA_FOR_##name(){}; \
static OpSchema* CAFFE_ANONYMOUS_VARIABLE(name) CAFFE2_UNUSED = \
#define OPERATOR_SCHEMA(name) \
C10_EXPORT void CAFFE2_PLEASE_ADD_OPERATOR_SCHEMA_FOR_##name(){}; \
static OpSchema* CAFFE_ANONYMOUS_VARIABLE(name) CAFFE2_UNUSED = \
1 ? nullptr : &OpSchemaRegistry::NewSchema(#name, __FILE__, __LINE__)
#endif // CAFFE2_NO_OPERATOR_SCHEMA

View File

@ -14,7 +14,7 @@
namespace caffe2 {
template <class Context>
class CAFFE2_EXPORT QTensor {
class C10_EXPORT QTensor {
public:
QTensor() {}
virtual ~QTensor() {}

View File

@ -100,7 +100,7 @@ class Registry {
CaffeMap<SrcType, string> help_message_;
std::mutex register_mutex_;
AT_DISABLE_COPY_AND_ASSIGN(Registry);
C10_DISABLE_COPY_AND_ASSIGN(Registry);
};
template <class SrcType, class ObjectPtrType, class... Args>
@ -142,16 +142,16 @@ class Registerer {
* declaration, as well as creating a convenient typename for its corresponding
* registerer.
*/
#define CAFFE_DECLARE_TYPED_REGISTRY( \
RegistryName, SrcType, ObjectType, PtrType, ...) \
CAFFE2_EXPORT Registry<SrcType, PtrType<ObjectType>, ##__VA_ARGS__>* \
RegistryName(); \
typedef Registerer<SrcType, PtrType<ObjectType>, ##__VA_ARGS__> \
#define CAFFE_DECLARE_TYPED_REGISTRY( \
RegistryName, SrcType, ObjectType, PtrType, ...) \
C10_EXPORT Registry<SrcType, PtrType<ObjectType>, ##__VA_ARGS__>* \
RegistryName(); \
typedef Registerer<SrcType, PtrType<ObjectType>, ##__VA_ARGS__> \
Registerer##RegistryName;
#define CAFFE_DEFINE_TYPED_REGISTRY( \
RegistryName, SrcType, ObjectType, PtrType, ...) \
CAFFE2_EXPORT Registry<SrcType, PtrType<ObjectType>, ##__VA_ARGS__>* \
C10_EXPORT Registry<SrcType, PtrType<ObjectType>, ##__VA_ARGS__>* \
RegistryName() { \
static Registry<SrcType, PtrType<ObjectType>, ##__VA_ARGS__>* registry = \
new Registry<SrcType, PtrType<ObjectType>, ##__VA_ARGS__>(); \

View File

@ -41,7 +41,7 @@ class Timer {
protected:
std::chrono::time_point<clock> start_time_;
AT_DISABLE_COPY_AND_ASSIGN(Timer);
C10_DISABLE_COPY_AND_ASSIGN(Timer);
};
}

View File

@ -328,7 +328,7 @@ class CAFFE2_API Workspace {
std::mutex thread_pool_creation_mutex_;
std::shared_ptr<Bookkeeper> bookkeeper_;
AT_DISABLE_COPY_AND_ASSIGN(Workspace);
C10_DISABLE_COPY_AND_ASSIGN(Workspace);
};
} // namespace caffe2

View File

@ -34,7 +34,7 @@ class CreateDBOp final : public Operator<Context> {
string db_name_;
uint32_t num_shards_;
uint32_t shard_id_;
AT_DISABLE_COPY_AND_ASSIGN(CreateDBOp);
C10_DISABLE_COPY_AND_ASSIGN(CreateDBOp);
};
} // namespace caffe2

View File

@ -51,7 +51,7 @@ class LevelDBTransaction : public Transaction {
leveldb::DB* db_;
std::unique_ptr<leveldb::WriteBatch> batch_;
AT_DISABLE_COPY_AND_ASSIGN(LevelDBTransaction);
C10_DISABLE_COPY_AND_ASSIGN(LevelDBTransaction);
};
class LevelDB : public DB {

View File

@ -114,7 +114,7 @@ class LMDBTransaction final : public Transaction {
MDB_dbi mdb_dbi_;
MDB_txn* mdb_txn_;
AT_DISABLE_COPY_AND_ASSIGN(LMDBTransaction);
C10_DISABLE_COPY_AND_ASSIGN(LMDBTransaction);
};
class LMDB : public DB {

View File

@ -60,7 +60,7 @@ class ProtoDBTransaction : public Transaction {
TensorProtos* proto_;
std::unordered_set<string> existing_names_;
AT_DISABLE_COPY_AND_ASSIGN(ProtoDBTransaction);
C10_DISABLE_COPY_AND_ASSIGN(ProtoDBTransaction);
};
class ProtoDB : public DB {

View File

@ -58,7 +58,7 @@ class PrimitiveWrapper {
private:
dnnPrimitive_t primitive_ = 0;
AT_DISABLE_COPY_AND_ASSIGN(PrimitiveWrapper);
C10_DISABLE_COPY_AND_ASSIGN(PrimitiveWrapper);
};
template <typename T>
@ -138,7 +138,7 @@ class LayoutWrapper {
private:
dnnLayout_t layout_ = 0;
AT_DISABLE_COPY_AND_ASSIGN(LayoutWrapper);
C10_DISABLE_COPY_AND_ASSIGN(LayoutWrapper);
};
/**
@ -557,7 +557,7 @@ class MKLMemory {
// The primitive to use to convert from internal layout to user layout
PrimitiveWrapper<T> convert_out_;
AT_DISABLE_COPY_AND_ASSIGN(MKLMemory);
C10_DISABLE_COPY_AND_ASSIGN(MKLMemory);
};
template <typename T>
@ -575,7 +575,7 @@ class MKLWorkspace {
private:
void* buffer_;
AT_DISABLE_COPY_AND_ASSIGN(MKLWorkspace);
C10_DISABLE_COPY_AND_ASSIGN(MKLWorkspace);
};
} // namespace mkl

View File

@ -57,7 +57,7 @@ class GLNet : public NetBase {
vector<unique_ptr<OperatorBase>> operators_;
AT_DISABLE_COPY_AND_ASSIGN(GLNet);
C10_DISABLE_COPY_AND_ASSIGN(GLNet);
};
} // namespace caffe2

View File

@ -112,7 +112,7 @@ class SqueezeOp : public Operator<Context> {
vector<int> dims_;
public:
AT_DISABLE_COPY_AND_ASSIGN(SqueezeOp);
C10_DISABLE_COPY_AND_ASSIGN(SqueezeOp);
};
} // namespace caffe2
#endif // CAFFE2_OPERATORS_EXPAND_SQUEEZE_DIMS_OP_H_

View File

@ -221,7 +221,7 @@ class PartitionOp : public PartitionOpBase {
return true;
}
AT_DISABLE_COPY_AND_ASSIGN(PartitionOp);
C10_DISABLE_COPY_AND_ASSIGN(PartitionOp);
};
class LengthsPartitionOp : public PartitionOpBase {
@ -302,7 +302,7 @@ class LengthsPartitionOp : public PartitionOpBase {
return true;
}
AT_DISABLE_COPY_AND_ASSIGN(LengthsPartitionOp);
C10_DISABLE_COPY_AND_ASSIGN(LengthsPartitionOp);
vector<int32_t*> out_length_;
};

View File

@ -302,7 +302,7 @@ class SliceGradientOp<CUDAContext> : public Operator<CUDAContext> {
ends_(this->template GetRepeatedArgument<int64_t>("ends")),
statically_inited_(false) {}
AT_DISABLE_COPY_AND_ASSIGN(SliceGradientOp);
C10_DISABLE_COPY_AND_ASSIGN(SliceGradientOp);
bool RunOnDevice() override {
if (InputSize() == 4) {

View File

@ -249,7 +249,7 @@ class SliceOp : public Operator<Context> {
output, data, starts_host_, ends_host_, &context_);
}
AT_DISABLE_COPY_AND_ASSIGN(SliceOp);
C10_DISABLE_COPY_AND_ASSIGN(SliceOp);
protected:
std::vector<int64_t> starts_;
@ -269,7 +269,7 @@ class SliceGradientOp : public Operator<Context> {
ends_(this->template GetRepeatedArgument<int64_t>("ends")),
statically_inited_(false) {}
AT_DISABLE_COPY_AND_ASSIGN(SliceGradientOp);
C10_DISABLE_COPY_AND_ASSIGN(SliceGradientOp);
bool RunOnDevice() override {
if (InputSize() == 4) {

View File

@ -37,7 +37,7 @@ CAFFE2_API void fuseConvBN(repr::NNModule* nn, caffe2::Workspace* ws);
// \param postprocess Functor to postprocess the conv node,
// attaching additional attributes if necessary
template <typename OperationT, typename ActivationT>
CAFFE2_EXPORT void fuseActivation(
C10_EXPORT void fuseActivation(
repr::NNModule* nn,
std::function<bool(const OperationT& conv)> should_fuse,
std::function<void(repr::NNGraph::NodeRef conv_node)> postprocess) {

View File

@ -8,7 +8,7 @@ namespace opt {
using namespace nom;
CAFFE2_EXPORT void sinkMaxPool(nom::repr::NNModule* nn) {
C10_EXPORT void sinkMaxPool(nom::repr::NNModule* nn) {
for (auto max_pool_node :
repr::nn::nodeIterator<repr::MaxPool>(nn->dataFlow)) {
if (repr::nn::getInputs(max_pool_node).size() != 1) {

View File

@ -43,7 +43,7 @@ void addObjectMethods(pybind11::module& m);
// Get current workspace
Workspace* GetCurrentWorkspace();
class CAFFE2_EXPORT BlobFetcherBase {
class C10_EXPORT BlobFetcherBase {
public:
struct FetchedBlob {
pybind11::object obj;
@ -60,7 +60,7 @@ class BlobFeederBase {
Feed(const DeviceOption& option, PyArrayObject* array, Blob* blob) = 0;
};
CAFFE2_EXPORT CAFFE_DECLARE_TYPED_REGISTRY(
C10_EXPORT CAFFE_DECLARE_TYPED_REGISTRY(
BlobFetcherRegistry,
TypeIdentifier,
BlobFetcherBase,

View File

@ -32,7 +32,7 @@ class CreateBlobsQueueDBOp : public Operator<CPUContext> {
}
private:
AT_DISABLE_COPY_AND_ASSIGN(CreateBlobsQueueDBOp);
C10_DISABLE_COPY_AND_ASSIGN(CreateBlobsQueueDBOp);
};
REGISTER_CPU_OPERATOR(CreateBlobsQueueDB, CreateBlobsQueueDBOp<CPUContext>);

File diff suppressed because it is too large Load Diff

View File

@ -3,7 +3,7 @@
namespace caffe2 {
CAFFE2_EXPORT void ArgumentToAttributeProto(
C10_EXPORT void ArgumentToAttributeProto(
const Argument& arg,
::torch::AttributeProto* attr) {
CAFFE_ENFORCE(arg.has_name());
@ -29,7 +29,7 @@ CAFFE2_EXPORT void ArgumentToAttributeProto(
}
}
CAFFE2_EXPORT void AttributeProtoToArgument(
C10_EXPORT void AttributeProtoToArgument(
const ::torch::AttributeProto& attr,
Argument* arg) {
CAFFE_ENFORCE(attr.has_name());
@ -94,7 +94,7 @@ CAFFE2_EXPORT void AttributeProtoToArgument(
}
}
CAFFE2_EXPORT void OperatorDefToNodeProto(
C10_EXPORT void OperatorDefToNodeProto(
const OperatorDef& def,
::torch::NodeProto* node) {
node->mutable_input()->CopyFrom(def.input());
@ -141,7 +141,7 @@ CAFFE2_EXPORT void OperatorDefToNodeProto(
}
}
CAFFE2_EXPORT void NodeProtoToOperatorDef(
C10_EXPORT void NodeProtoToOperatorDef(
const ::torch::NodeProto& node,
OperatorDef* def) {
def->mutable_input()->CopyFrom(node.input());

View File

@ -21,11 +21,11 @@ using ::google::protobuf::MessageLite;
namespace caffe2 {
CAFFE2_EXPORT std::string DeviceTypeName(const int32_t& d) {
C10_EXPORT std::string DeviceTypeName(const int32_t& d) {
return at::DeviceTypeName(static_cast<at::DeviceType>(d));
}
CAFFE2_EXPORT int DeviceId(const DeviceOption& option) {
C10_EXPORT int DeviceId(const DeviceOption& option) {
switch (option.device_type()) {
case PROTO_CPU:
return option.numa_node_id();
@ -40,7 +40,7 @@ CAFFE2_EXPORT int DeviceId(const DeviceOption& option) {
}
}
CAFFE2_EXPORT bool IsSameDevice(const DeviceOption& lhs, const DeviceOption& rhs) {
C10_EXPORT bool IsSameDevice(const DeviceOption& lhs, const DeviceOption& rhs) {
return (
lhs.device_type() == rhs.device_type() &&
lhs.cuda_gpu_id() == rhs.cuda_gpu_id() &&
@ -49,7 +49,7 @@ CAFFE2_EXPORT bool IsSameDevice(const DeviceOption& lhs, const DeviceOption& rhs
lhs.numa_node_id() == rhs.numa_node_id());
}
CAFFE2_EXPORT bool ReadStringFromFile(const char* filename, string* str) {
C10_EXPORT bool ReadStringFromFile(const char* filename, string* str) {
std::ifstream ifs(filename, std::ios::in);
if (!ifs) {
VLOG(1) << "File cannot be opened: " << filename
@ -64,7 +64,7 @@ CAFFE2_EXPORT bool ReadStringFromFile(const char* filename, string* str) {
return true;
}
CAFFE2_EXPORT bool WriteStringToFile(const string& str, const char* filename) {
C10_EXPORT bool WriteStringToFile(const string& str, const char* filename) {
std::ofstream ofs(filename, std::ios::out | std::ios::trunc);
if (!ofs.is_open()) {
VLOG(1) << "File cannot be created: " << filename
@ -102,11 +102,13 @@ class IfstreamInputStream : public ::google::protobuf::io::CopyingInputStream {
};
} // namespace
CAFFE2_EXPORT string ProtoDebugString(const MessageLite& proto) {
C10_EXPORT string ProtoDebugString(const MessageLite& proto) {
return proto.SerializeAsString();
}
CAFFE2_EXPORT bool ParseProtoFromLargeString(const string& str, MessageLite* proto) {
C10_EXPORT bool ParseProtoFromLargeString(
const string& str,
MessageLite* proto) {
::google::protobuf::io::ArrayInputStream input_stream(str.data(), str.size());
::google::protobuf::io::CodedInputStream coded_stream(&input_stream);
// Set PlanDef message size limit to 2G.
@ -114,7 +116,9 @@ CAFFE2_EXPORT bool ParseProtoFromLargeString(const string& str, MessageLite* pro
return proto->ParseFromCodedStream(&coded_stream);
}
CAFFE2_EXPORT bool ReadProtoFromBinaryFile(const char* filename, MessageLite* proto) {
C10_EXPORT bool ReadProtoFromBinaryFile(
const char* filename,
MessageLite* proto) {
::google::protobuf::io::CopyingInputStreamAdaptor stream(
new IfstreamInputStream(filename));
stream.SetOwnsCopyingStream(true);
@ -125,7 +129,7 @@ CAFFE2_EXPORT bool ReadProtoFromBinaryFile(const char* filename, MessageLite* pr
return proto->ParseFromCodedStream(&coded_stream);
}
CAFFE2_EXPORT void WriteProtoToBinaryFile(
C10_EXPORT void WriteProtoToBinaryFile(
const MessageLite& /*proto*/,
const char* /*filename*/) {
LOG(FATAL) << "Not implemented yet.";
@ -144,16 +148,16 @@ using ::google::protobuf::io::CodedOutputStream;
using ::google::protobuf::Message;
namespace TextFormat {
CAFFE2_EXPORT bool ParseFromString(const string& spec, Message* proto) {
C10_EXPORT bool ParseFromString(const string& spec, Message* proto) {
return ::google::protobuf::TextFormat::ParseFromString(spec, proto);
}
} // namespace TextFormat
CAFFE2_EXPORT string ProtoDebugString(const Message& proto) {
C10_EXPORT string ProtoDebugString(const Message& proto) {
return proto.ShortDebugString();
}
CAFFE2_EXPORT bool ParseProtoFromLargeString(const string& str, Message* proto) {
C10_EXPORT bool ParseProtoFromLargeString(const string& str, Message* proto) {
::google::protobuf::io::ArrayInputStream input_stream(str.data(), str.size());
::google::protobuf::io::CodedInputStream coded_stream(&input_stream);
// Set PlanDef message size limit to 2G.
@ -161,7 +165,7 @@ CAFFE2_EXPORT bool ParseProtoFromLargeString(const string& str, Message* proto)
return proto->ParseFromCodedStream(&coded_stream);
}
CAFFE2_EXPORT bool ReadProtoFromTextFile(const char* filename, Message* proto) {
C10_EXPORT bool ReadProtoFromTextFile(const char* filename, Message* proto) {
int fd = open(filename, O_RDONLY);
CAFFE_ENFORCE_NE(fd, -1, "File not found: ", filename);
FileInputStream* input = new FileInputStream(fd);
@ -171,7 +175,9 @@ CAFFE2_EXPORT bool ReadProtoFromTextFile(const char* filename, Message* proto) {
return success;
}
CAFFE2_EXPORT void WriteProtoToTextFile(const Message& proto, const char* filename) {
C10_EXPORT void WriteProtoToTextFile(
const Message& proto,
const char* filename) {
int fd = open(filename, O_WRONLY | O_CREAT | O_TRUNC, 0644);
FileOutputStream* output = new FileOutputStream(fd);
CAFFE_ENFORCE(google::protobuf::TextFormat::Print(proto, output));
@ -179,7 +185,9 @@ CAFFE2_EXPORT void WriteProtoToTextFile(const Message& proto, const char* filena
close(fd);
}
CAFFE2_EXPORT bool ReadProtoFromBinaryFile(const char* filename, MessageLite* proto) {
C10_EXPORT bool ReadProtoFromBinaryFile(
const char* filename,
MessageLite* proto) {
#if defined (_MSC_VER) // for MSC compiler binary flag needs to be specified
int fd = open(filename, O_RDONLY | O_BINARY);
#else
@ -198,7 +206,9 @@ CAFFE2_EXPORT bool ReadProtoFromBinaryFile(const char* filename, MessageLite* pr
return success;
}
CAFFE2_EXPORT void WriteProtoToBinaryFile(const MessageLite& proto, const char* filename) {
C10_EXPORT void WriteProtoToBinaryFile(
const MessageLite& proto,
const char* filename) {
int fd = open(filename, O_WRONLY | O_CREAT | O_TRUNC, 0644);
CAFFE_ENFORCE_NE(
fd, -1, "File cannot be created: ", filename, " error number: ", errno);
@ -213,8 +223,7 @@ CAFFE2_EXPORT void WriteProtoToBinaryFile(const MessageLite& proto, const char*
#endif // CAFFE2_USE_LITE_PROTO
CAFFE2_EXPORT ArgumentHelper::ArgumentHelper(const OperatorDef& def) {
C10_EXPORT ArgumentHelper::ArgumentHelper(const OperatorDef& def) {
for (auto& arg : def.arg()) {
if (arg_map_.count(arg.name())) {
if (arg.SerializeAsString() != arg_map_[arg.name()].SerializeAsString()) {
@ -235,7 +244,7 @@ CAFFE2_EXPORT ArgumentHelper::ArgumentHelper(const OperatorDef& def) {
}
}
CAFFE2_EXPORT ArgumentHelper::ArgumentHelper(const NetDef& netdef) {
C10_EXPORT ArgumentHelper::ArgumentHelper(const NetDef& netdef) {
for (auto& arg : netdef.arg()) {
CAFFE_ENFORCE(
arg_map_.count(arg.name()) == 0,
@ -245,7 +254,7 @@ CAFFE2_EXPORT ArgumentHelper::ArgumentHelper(const NetDef& netdef) {
}
}
CAFFE2_EXPORT bool ArgumentHelper::HasArgument(const string& name) const {
C10_EXPORT bool ArgumentHelper::HasArgument(const string& name) const {
return arg_map_.count(name);
}
@ -267,41 +276,42 @@ std::ostream& operator<<(std::ostream& output, const NetDef& n) {
return output;
}
#define INSTANTIATE_GET_SINGLE_ARGUMENT( \
T, fieldname, enforce_lossless_conversion) \
template <> \
CAFFE2_EXPORT T ArgumentHelper::GetSingleArgument<T>( \
const string& name, const T& default_value) const { \
if (arg_map_.count(name) == 0) { \
VLOG(1) << "Using default parameter value " << default_value \
<< " for parameter " << name; \
return default_value; \
} \
CAFFE_ENFORCE( \
arg_map_.at(name).has_##fieldname(), \
"Argument ", \
name, \
" does not have the right field: expected field " #fieldname); \
auto value = arg_map_.at(name).fieldname(); \
if (enforce_lossless_conversion) { \
auto supportsConversion = \
SupportsLosslessConversion<decltype(value), T>(value); \
CAFFE_ENFORCE( \
supportsConversion, \
"Value", \
value, \
" of argument ", \
name, \
"cannot be represented correctly in a target type"); \
} \
return static_cast<T>(value); \
} \
template <> \
CAFFE2_EXPORT bool ArgumentHelper::HasSingleArgumentOfType<T>(const string& name) const { \
if (arg_map_.count(name) == 0) { \
return false; \
} \
return arg_map_.at(name).has_##fieldname(); \
#define INSTANTIATE_GET_SINGLE_ARGUMENT( \
T, fieldname, enforce_lossless_conversion) \
template <> \
C10_EXPORT T ArgumentHelper::GetSingleArgument<T>( \
const string& name, const T& default_value) const { \
if (arg_map_.count(name) == 0) { \
VLOG(1) << "Using default parameter value " << default_value \
<< " for parameter " << name; \
return default_value; \
} \
CAFFE_ENFORCE( \
arg_map_.at(name).has_##fieldname(), \
"Argument ", \
name, \
" does not have the right field: expected field " #fieldname); \
auto value = arg_map_.at(name).fieldname(); \
if (enforce_lossless_conversion) { \
auto supportsConversion = \
SupportsLosslessConversion<decltype(value), T>(value); \
CAFFE_ENFORCE( \
supportsConversion, \
"Value", \
value, \
" of argument ", \
name, \
"cannot be represented correctly in a target type"); \
} \
return static_cast<T>(value); \
} \
template <> \
C10_EXPORT bool ArgumentHelper::HasSingleArgumentOfType<T>( \
const string& name) const { \
if (arg_map_.count(name) == 0) { \
return false; \
} \
return arg_map_.at(name).has_##fieldname(); \
}
INSTANTIATE_GET_SINGLE_ARGUMENT(float, f, false)
@ -321,7 +331,7 @@ INSTANTIATE_GET_SINGLE_ARGUMENT(NetDef, n, false)
#define INSTANTIATE_GET_REPEATED_ARGUMENT( \
T, fieldname, enforce_lossless_conversion) \
template <> \
CAFFE2_EXPORT vector<T> ArgumentHelper::GetRepeatedArgument<T>( \
C10_EXPORT vector<T> ArgumentHelper::GetRepeatedArgument<T>( \
const string& name, const std::vector<T>& default_value) const { \
if (arg_map_.count(name) == 0) { \
return default_value; \
@ -358,14 +368,14 @@ INSTANTIATE_GET_REPEATED_ARGUMENT(string, strings, false)
INSTANTIATE_GET_REPEATED_ARGUMENT(NetDef, nets, false)
#undef INSTANTIATE_GET_REPEATED_ARGUMENT
#define CAFFE2_MAKE_SINGULAR_ARGUMENT(T, fieldname) \
template <> \
CAFFE2_EXPORT Argument MakeArgument(const string& name, const T& value) { \
Argument arg; \
arg.set_name(name); \
arg.set_##fieldname(value); \
return arg; \
}
#define CAFFE2_MAKE_SINGULAR_ARGUMENT(T, fieldname) \
template <> \
C10_EXPORT Argument MakeArgument(const string& name, const T& value) { \
Argument arg; \
arg.set_name(name); \
arg.set_##fieldname(value); \
return arg; \
}
CAFFE2_MAKE_SINGULAR_ARGUMENT(bool, i)
CAFFE2_MAKE_SINGULAR_ARGUMENT(float, f)
@ -375,28 +385,29 @@ CAFFE2_MAKE_SINGULAR_ARGUMENT(string, s)
#undef CAFFE2_MAKE_SINGULAR_ARGUMENT
template <>
CAFFE2_EXPORT bool ArgumentHelper::RemoveArgument(OperatorDef& def, int index);
C10_EXPORT bool ArgumentHelper::RemoveArgument(OperatorDef& def, int index);
template <>
bool ArgumentHelper::RemoveArgument(NetDef& def, int index);
template <>
CAFFE2_EXPORT Argument MakeArgument(const string& name, const MessageLite& value) {
C10_EXPORT Argument MakeArgument(const string& name, const MessageLite& value) {
Argument arg;
arg.set_name(name);
arg.set_s(value.SerializeAsString());
return arg;
}
#define CAFFE2_MAKE_REPEATED_ARGUMENT(T, fieldname) \
template <> \
CAFFE2_EXPORT Argument MakeArgument(const string& name, const vector<T>& value) {\
Argument arg; \
arg.set_name(name); \
for (const auto& v : value) { \
arg.add_##fieldname(v); \
} \
return arg; \
}
#define CAFFE2_MAKE_REPEATED_ARGUMENT(T, fieldname) \
template <> \
C10_EXPORT Argument MakeArgument( \
const string& name, const vector<T>& value) { \
Argument arg; \
arg.set_name(name); \
for (const auto& v : value) { \
arg.add_##fieldname(v); \
} \
return arg; \
}
CAFFE2_MAKE_REPEATED_ARGUMENT(float, floats)
CAFFE2_MAKE_REPEATED_ARGUMENT(int, ints)
@ -404,7 +415,7 @@ CAFFE2_MAKE_REPEATED_ARGUMENT(int64_t, ints)
CAFFE2_MAKE_REPEATED_ARGUMENT(string, strings)
#undef CAFFE2_MAKE_REPEATED_ARGUMENT
CAFFE2_EXPORT bool HasOutput(const OperatorDef& op, const std::string& output) {
C10_EXPORT bool HasOutput(const OperatorDef& op, const std::string& output) {
for (const auto& outp : op.output()) {
if (outp == output) {
return true;
@ -413,7 +424,7 @@ CAFFE2_EXPORT bool HasOutput(const OperatorDef& op, const std::string& output) {
return false;
}
CAFFE2_EXPORT bool HasInput(const OperatorDef& op, const std::string& input) {
C10_EXPORT bool HasInput(const OperatorDef& op, const std::string& input) {
for (const auto& inp : op.input()) {
if (inp == input) {
return true;
@ -423,7 +434,7 @@ CAFFE2_EXPORT bool HasInput(const OperatorDef& op, const std::string& input) {
}
// Return the argument index or -1 if it does not exist.
CAFFE2_EXPORT int GetArgumentIndex(
C10_EXPORT int GetArgumentIndex(
const google::protobuf::RepeatedPtrField<Argument>& args,
const string& name) {
int index = 0;
@ -436,7 +447,9 @@ CAFFE2_EXPORT int GetArgumentIndex(
return -1;
}
CAFFE2_EXPORT const Argument& GetArgument(const OperatorDef& def, const string& name) {
C10_EXPORT const Argument& GetArgument(
const OperatorDef& def,
const string& name) {
int index = GetArgumentIndex(def.arg(), name);
if (index != -1) {
return def.arg(index);
@ -449,7 +462,7 @@ CAFFE2_EXPORT const Argument& GetArgument(const OperatorDef& def, const string&
}
}
CAFFE2_EXPORT const Argument& GetArgument(const NetDef& def, const string& name) {
C10_EXPORT const Argument& GetArgument(const NetDef& def, const string& name) {
int index = GetArgumentIndex(def.arg(), name);
if (index != -1) {
return def.arg(index);
@ -462,7 +475,7 @@ CAFFE2_EXPORT const Argument& GetArgument(const NetDef& def, const string& name)
}
}
CAFFE2_EXPORT bool GetFlagArgument(
C10_EXPORT bool GetFlagArgument(
const google::protobuf::RepeatedPtrField<Argument>& args,
const string& name,
bool default_value) {
@ -476,21 +489,19 @@ CAFFE2_EXPORT bool GetFlagArgument(
return default_value;
}
CAFFE2_EXPORT bool GetFlagArgument(
C10_EXPORT bool GetFlagArgument(
const OperatorDef& def,
const string& name,
bool default_value) {
return GetFlagArgument(def.arg(), name, default_value);
}
CAFFE2_EXPORT bool GetFlagArgument(
const NetDef& def,
const string& name,
bool default_value) {
C10_EXPORT bool
GetFlagArgument(const NetDef& def, const string& name, bool default_value) {
return GetFlagArgument(def.arg(), name, default_value);
}
CAFFE2_EXPORT Argument* GetMutableArgument(
C10_EXPORT Argument* GetMutableArgument(
const string& name,
const bool create_if_missing,
OperatorDef* def) {

View File

@ -194,7 +194,7 @@ CAFFE2_API bool HasInput(const OperatorDef& op, const std::string& input);
* does not copy the operator def, so one would need to make sure that the
* lifetime of the OperatorDef object outlives that of the ArgumentHelper.
*/
class CAFFE2_EXPORT ArgumentHelper {
class C10_EXPORT ArgumentHelper {
public:
template <typename Def>
static bool HasArgument(const Def& def, const string& name) {

View File

@ -360,7 +360,7 @@ class WorkersPool {
counter_to_decrement_when_ready_.Wait();
}
AT_DISABLE_COPY_AND_ASSIGN(WorkersPool);
C10_DISABLE_COPY_AND_ASSIGN(WorkersPool);
std::vector<std::unique_ptr<Worker, AlignedDeleter<Worker>>> workers_;
// The BlockingCounter used to wait for the workers.
BlockingCounter counter_to_decrement_when_ready_;

View File

@ -26,7 +26,7 @@ class ZmqContext {
private:
void* ptr_;
AT_DISABLE_COPY_AND_ASSIGN(ZmqContext);
C10_DISABLE_COPY_AND_ASSIGN(ZmqContext);
};
class ZmqMessage {
@ -48,7 +48,7 @@ class ZmqMessage {
private:
zmq_msg_t msg_;
AT_DISABLE_COPY_AND_ASSIGN(ZmqMessage);
C10_DISABLE_COPY_AND_ASSIGN(ZmqMessage);
};
class ZmqSocket {

View File

@ -67,7 +67,7 @@ class RocksDBTransaction : public Transaction {
rocksdb::DB* db_;
std::unique_ptr<rocksdb::WriteBatch> batch_;
AT_DISABLE_COPY_AND_ASSIGN(RocksDBTransaction);
C10_DISABLE_COPY_AND_ASSIGN(RocksDBTransaction);
};
class RocksDB : public DB {