@@ -14,6 +14,8 @@ lit_config.load_config(config, site_cfg)
|
||||
print("CUDA " + config.cuda_version + " will be used for testing.")
|
||||
|
||||
config.excludes = ['cmdparser.hpp']
|
||||
config.excludes.append('spatial_batch_norm_op.h')
|
||||
config.excludes.append('common_cudnn.h')
|
||||
|
||||
if config.cuda_version_major == 7 and config.cuda_version_minor == 0:
|
||||
config.excludes.append('headers_test_09.cu')
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
#ifndef CAFFE2_CORE_COMMON_CUDNN_H_
|
||||
#define CAFFE2_CORE_COMMON_CUDNN_H_
|
||||
|
||||
#include <array>
|
||||
#include <mutex>
|
||||
|
||||
#endif // CAFFE2_CORE_COMMON_CUDNN_H_
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
#ifndef CAFFE2_OPERATORS_SPATIAL_BATCH_NORM_OP_H_
|
||||
#define CAFFE2_OPERATORS_SPATIAL_BATCH_NORM_OP_H_
|
||||
|
||||
#include <algorithm>
|
||||
#include <array>
|
||||
#include <functional>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
namespace caffe2 {
|
||||
|
||||
} // namespace caffe2
|
||||
|
||||
#endif // CAFFE2_OPERATORS_SPATIAL_BATCH_NORM_OP_H_
|
||||
@@ -0,0 +1,12 @@
|
||||
// RUN: %run_test hipify "%s" "%t" %hipify_args "-roc" %clang_args
|
||||
|
||||
// NOTE: Nonworking code just for conversion testing
|
||||
|
||||
// CHECK: #include <hip/hip_runtime.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <math.h>
|
||||
// CHECK: #include "caffe2/operators/hip/spatial_batch_norm_op_miopen.hip"
|
||||
#include "caffe2/operators/spatial_batch_norm_op.h"
|
||||
// CHECK: #include "caffe2/core/hip/common_miopen.h"
|
||||
#include "caffe2/core/common_cudnn.h"
|
||||
@@ -0,0 +1,103 @@
|
||||
// RUN: %run_test hipify "%s" "%t" %hipify_args "-roc" %clang_args
|
||||
|
||||
// NOTE: Nonworking code just for conversion testing
|
||||
|
||||
// CHECK: #include <hip/hip_runtime.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <math.h>
|
||||
#include <string>
|
||||
|
||||
namespace caffe2 {
|
||||
|
||||
// Operator Definition.
|
||||
struct OperatorDef {
|
||||
int input = 1;
|
||||
int output = 2;
|
||||
int name = 3;
|
||||
};
|
||||
|
||||
class OperatorBase;
|
||||
class Workspace;
|
||||
|
||||
template <class T>
|
||||
class Observable {
|
||||
public:
|
||||
Observable() = default;
|
||||
|
||||
Observable(Observable&&) = default;
|
||||
Observable& operator =(Observable&&) = default;
|
||||
|
||||
virtual ~Observable() = default;
|
||||
};
|
||||
|
||||
template <class T>
|
||||
class ObserverBase {
|
||||
public:
|
||||
explicit ObserverBase(T* subject) : subject_(subject) {}
|
||||
|
||||
virtual void Start() {}
|
||||
virtual void Stop() {}
|
||||
|
||||
virtual std::string debugInfo() {
|
||||
return "Not implemented.";
|
||||
}
|
||||
|
||||
virtual ~ObserverBase() noexcept {};
|
||||
|
||||
T* subject() const {
|
||||
return subject_;
|
||||
}
|
||||
|
||||
protected:
|
||||
T* subject_;
|
||||
};
|
||||
|
||||
typedef ObserverBase<OperatorBase> OperatorObserver;
|
||||
|
||||
class OperatorBase : public Observable<OperatorBase> {
|
||||
public:
|
||||
explicit OperatorBase(const OperatorDef& operator_def, Workspace* ws);
|
||||
virtual ~OperatorBase() noexcept {}
|
||||
};
|
||||
|
||||
template <class Context>
|
||||
class Operator : public OperatorBase {
|
||||
public:
|
||||
explicit Operator(const OperatorDef& operator_def, Workspace* ws)
|
||||
: OperatorBase(operator_def, ws), context_(operator_def.device_option()) {
|
||||
context_.SwitchToDevice();
|
||||
}
|
||||
~Operator() noexcept override {}
|
||||
};
|
||||
|
||||
template <class Context>
|
||||
class DummyEmptyOp : public Operator<Context> {
|
||||
public:
|
||||
DummyEmptyOp(const OperatorDef& def, Workspace* ws)
|
||||
: Operator<Context>(def, ws) {}
|
||||
|
||||
bool RunOnDevice() final { return true; }
|
||||
};
|
||||
|
||||
|
||||
class CUDAContext {
|
||||
public:
|
||||
CUDAContext();
|
||||
virtual ~CUDAContext() noexcept {}
|
||||
};
|
||||
|
||||
#define REGISTER_CUDA_OPERATOR(name, ...) \
|
||||
void CAFFE2_PLEASE_ADD_OPERATOR_SCHEMA_FOR_##name(); \
|
||||
static void CAFFE_ANONYMOUS_VARIABLE_CUDA##name() { \
|
||||
CAFFE2_PLEASE_ADD_OPERATOR_SCHEMA_FOR_##name(); \
|
||||
}
|
||||
|
||||
#define REGISTER_CUDA_OPERATOR_CREATOR(key, ...)
|
||||
|
||||
// CHECK: REGISTER_HIP_OPERATOR(Operator, DummyEmptyOp<HIPContext>);
|
||||
REGISTER_CUDA_OPERATOR(Operator, DummyEmptyOp<CUDAContext>);
|
||||
// CHECK: REGISTER_HIP_OPERATOR_CREATOR(Operator, DummyEmptyOp<HIPContext>);
|
||||
REGISTER_CUDA_OPERATOR_CREATOR(Operator, DummyEmptyOp<CUDAContext>);
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user