forked from jiuyuan/InfiniTensor
code format fix
This commit is contained in:
parent
7167badbb7
commit
f2f149861a
|
@ -553,14 +553,14 @@ class SquaredDifferenceCnnl : public BangKernelWithoutConfig {
|
|||
CNNL_DTYPE_FLOAT, 4, dim_array));
|
||||
|
||||
size_t wsSize;
|
||||
cnnlGetSquaredDifferenceWorkspaceSize(context->cnnlHandle(), aDesc, bDesc, cDesc,
|
||||
&wsSize);
|
||||
cnnlGetSquaredDifferenceWorkspaceSize(context->cnnlHandle(), aDesc,
|
||||
bDesc, cDesc, &wsSize);
|
||||
|
||||
BangPtr wsData = context->getWorkspace(wsSize);
|
||||
|
||||
cnnlStatus_t stat =
|
||||
cnnlSquaredDifference(context->cnnlHandle(), aDesc, aData, bDesc, bData,
|
||||
cDesc, cData, wsData, wsSize);
|
||||
cnnlSquaredDifference(context->cnnlHandle(), aDesc, aData, bDesc,
|
||||
bData, cDesc, cData, wsData, wsSize);
|
||||
if (stat != CNNL_STATUS_SUCCESS)
|
||||
return;
|
||||
|
||||
|
@ -675,8 +675,8 @@ REGISTER_KERNEL(Device::BANG, OpType::FloorDivTrunc, DataType::Float32,
|
|||
FloorDivTruncCnnl, "FloorDivTrunc_cnnl_BANG_Float32");
|
||||
REGISTER_KERNEL(Device::BANG, OpType::FloorMod, DataType::Float32, FloorModCnnl,
|
||||
"FloorMod_cnnl_BANG_Float32");
|
||||
REGISTER_KERNEL(Device::BANG, OpType::SquaredDifference, DataType::Float32, SquaredDifferenceCnnl,
|
||||
"SquaredDifference_cnnl_BANG_Float32");
|
||||
REGISTER_KERNEL(Device::BANG, OpType::SquaredDifference, DataType::Float32,
|
||||
SquaredDifferenceCnnl, "SquaredDifference_cnnl_BANG_Float32");
|
||||
// REGISTER_KERNEL(Device::BANG, OpType::FloorModTrunc, DataType::Float32,
|
||||
// FloorModTruncCnnl,
|
||||
// "FloorModTrunc_cnnl_BANG_Float32");
|
||||
|
|
|
@ -16,26 +16,26 @@ class poolingCnnl : public BangKernelWithoutConfig {
|
|||
const auto [ph, pw, sh, sw, dh, dw] = op->getPadStrideDilation();
|
||||
|
||||
// get inputs
|
||||
int inArray[4] = {n,c,h,w};
|
||||
int inArray[4] = {n, c, h, w};
|
||||
cnnlTensorDescriptor_t inDesc;
|
||||
checkCnnlError(cnnlCreateTensorDescriptor(&inDesc));
|
||||
checkCnnlError(cnnlSetTensorDescriptor(
|
||||
inDesc, CNNL_LAYOUT_NCHW, CNNL_DTYPE_FLOAT, 4, inArray));
|
||||
checkCnnlError(cnnlSetTensorDescriptor(inDesc, CNNL_LAYOUT_NCHW,
|
||||
CNNL_DTYPE_FLOAT, 4, inArray));
|
||||
|
||||
// get maxpool descriptor
|
||||
cnnlPoolingDescriptor_t poolingDesc;
|
||||
checkCnnlError(cnnlCreatePoolingDescriptor(&poolingDesc));
|
||||
checkCnnlError(cnnlSetPooling2dDescriptor_v2(
|
||||
poolingDesc, getPoolingMode(), CNNL_NOT_PROPAGATE_NAN, kh, kw, ph, ph,
|
||||
pw, pw, sh, sw, dh, dw, false));
|
||||
poolingDesc, getPoolingMode(), CNNL_NOT_PROPAGATE_NAN, kh, kw, ph,
|
||||
ph, pw, pw, sh, sw, dh, dw, false));
|
||||
|
||||
// get outputs
|
||||
auto outVec = op->getOutput()->getDims();
|
||||
int outArray[4] = {outVec[0], outVec[1],outVec[2], outVec[3]};
|
||||
int outArray[4] = {outVec[0], outVec[1], outVec[2], outVec[3]};
|
||||
cnnlTensorDescriptor_t outDesc;
|
||||
checkCnnlError(cnnlCreateTensorDescriptor(&outDesc));
|
||||
checkCnnlError(cnnlSetTensorDescriptor(outDesc, CNNL_LAYOUT_NCHW,
|
||||
CNNL_DTYPE_FLOAT, 4, outArray));
|
||||
CNNL_DTYPE_FLOAT, 4, outArray));
|
||||
size_t wsSize;
|
||||
cnnlGetPoolingWorkspaceSize(context->cnnlHandle(), getPoolingMode(),
|
||||
outVec[3], outVec[2], &wsSize);
|
||||
|
|
|
@ -35,8 +35,8 @@ class SplitCnnl : public BangKernelWithoutConfig {
|
|||
}
|
||||
int dim_array[4] = {dim[0], dim[1], dim[2], dim[3]};
|
||||
checkCnnlError(cnnlCreateTensorDescriptor(&desc));
|
||||
checkCnnlError(cnnlSetTensorDescriptor(
|
||||
desc, CNNL_LAYOUT_NCHW, CNNL_DTYPE_FLOAT, 4, dim_array));
|
||||
checkCnnlError(cnnlSetTensorDescriptor(desc, CNNL_LAYOUT_NCHW,
|
||||
CNNL_DTYPE_FLOAT, 4, dim_array));
|
||||
cnnlTensorDescriptor_t descArray[num];
|
||||
for (int i = 0; i < num; ++i) {
|
||||
checkCnnlError(cnnlCreateTensorDescriptor(&descArray[i]));
|
||||
|
@ -50,8 +50,8 @@ class SplitCnnl : public BangKernelWithoutConfig {
|
|||
BangPtr wsData = context->getWorkspace(wsSize);
|
||||
|
||||
cnnlStatus_t stat =
|
||||
cnnlSplit(context->cnnlHandle(), num, axis, desc, inputData,
|
||||
wsData, wsSize, descArray, argv);
|
||||
cnnlSplit(context->cnnlHandle(), num, axis, desc, inputData, wsData,
|
||||
wsSize, descArray, argv);
|
||||
if (stat != CNNL_STATUS_SUCCESS)
|
||||
return;
|
||||
|
||||
|
|
|
@ -10,7 +10,7 @@ namespace infini {
|
|||
|
||||
template <class T>
|
||||
void testPooling(const std::function<void(void *, size_t, DataType)> &generator,
|
||||
const Shape &shape) {
|
||||
const Shape &shape) {
|
||||
// Runtime
|
||||
Runtime cpuRuntime = CpuRuntimeObj::getInstance();
|
||||
auto bangRuntime = make_ref<BangRuntimeObj>();
|
||||
|
@ -23,7 +23,7 @@ void testPooling(const std::function<void(void *, size_t, DataType)> &generator,
|
|||
// GPU
|
||||
Graph bangGraph = make_ref<GraphObj>(bangRuntime);
|
||||
auto inputGpu = bangGraph->cloneTensor(inputCpu);
|
||||
auto gpuOp = bangGraph->addOp<T>(inputGpu, nullptr, 3,3,1,1,1,1,2,2);
|
||||
auto gpuOp = bangGraph->addOp<T>(inputGpu, nullptr, 3, 3, 1, 1, 1, 1, 2, 2);
|
||||
bangGraph->dataMalloc();
|
||||
bangRuntime->run(bangGraph);
|
||||
auto outputGpu = gpuOp->getOutput();
|
||||
|
|
|
@ -10,7 +10,7 @@ namespace infini {
|
|||
|
||||
template <class T>
|
||||
void testRound(const std::function<void(void *, size_t, DataType)> &generator,
|
||||
const Shape &shape) {
|
||||
const Shape &shape) {
|
||||
// Runtime
|
||||
Runtime cpuRuntime = CpuRuntimeObj::getInstance();
|
||||
auto bangRuntime = make_ref<BangRuntimeObj>();
|
||||
|
|
|
@ -10,7 +10,7 @@ namespace infini {
|
|||
|
||||
template <class T>
|
||||
void testSplit(const std::function<void(void *, size_t, DataType)> &generator,
|
||||
const Shape &shape) {
|
||||
const Shape &shape) {
|
||||
// Runtime
|
||||
Runtime cpuRuntime = CpuRuntimeObj::getInstance();
|
||||
auto bangRuntime = make_ref<BangRuntimeObj>();
|
||||
|
@ -23,8 +23,7 @@ void testSplit(const std::function<void(void *, size_t, DataType)> &generator,
|
|||
// GPU
|
||||
Graph bangGraph = make_ref<GraphObj>(bangRuntime);
|
||||
auto inputGpu1 = bangGraph->cloneTensor(inputCpu1);
|
||||
auto gpuOp =
|
||||
bangGraph->addOp<T>(inputGpu1, std::nullopt, 3, 3);
|
||||
auto gpuOp = bangGraph->addOp<T>(inputGpu1, std::nullopt, 3, 3);
|
||||
bangGraph->dataMalloc();
|
||||
bangRuntime->run(bangGraph);
|
||||
auto o0Cpu = gpuOp->getOutput(0)->clone(cpuRuntime);
|
||||
|
|
|
@ -10,7 +10,7 @@ namespace infini {
|
|||
|
||||
template <class T>
|
||||
void testSquare(const std::function<void(void *, size_t, DataType)> &generator,
|
||||
const Shape &shape) {
|
||||
const Shape &shape) {
|
||||
// Runtime
|
||||
Runtime cpuRuntime = CpuRuntimeObj::getInstance();
|
||||
auto bangRuntime = make_ref<BangRuntimeObj>();
|
||||
|
|
|
@ -9,8 +9,9 @@
|
|||
namespace infini {
|
||||
|
||||
template <class T>
|
||||
void testSquaredDifference(const std::function<void(void *, size_t, DataType)> &generator,
|
||||
const Shape &shape) {
|
||||
void testSquaredDifference(
|
||||
const std::function<void(void *, size_t, DataType)> &generator,
|
||||
const Shape &shape) {
|
||||
// Runtime
|
||||
Runtime cpuRuntime = CpuRuntimeObj::getInstance();
|
||||
auto bangRuntime = make_ref<BangRuntimeObj>();
|
||||
|
@ -40,7 +41,8 @@ void testSquaredDifference(const std::function<void(void *, size_t, DataType)> &
|
|||
}
|
||||
|
||||
TEST(cnnl_SquaredDifference, run) {
|
||||
testSquaredDifference<SquaredDifferenceObj>(IncrementalGenerator(), Shape{1, 2, 2, 3});
|
||||
testSquaredDifference<SquaredDifferenceObj>(IncrementalGenerator(),
|
||||
Shape{1, 2, 2, 3});
|
||||
}
|
||||
|
||||
} // namespace infini
|
||||
|
|
Loading…
Reference in New Issue