TEST(Crop, real) { for (size_t numSamples : {5, 32}) { for (size_t channels : {5, 5, 32}) { for (size_t imgSizeH : {5, 33, 100}) { for (size_t imgSizeW : {5, 32, 96}) { VLOG(3) << " numSamples=" << numSamples << " channels=" << channels << " imgSizeH=" << imgSizeH << " imgSizeW=" << imgSizeW; for (bool test_grad : {false, true}) { CpuGpuFuncCompare compare( test_grad ? "CropGrad" : "Crop", FuncConfig() .set<std::vector<uint32_t>>("crop_corner", {0, 1, 1, 1}) .set<std::vector<uint32_t>>("crop_shape", {0, 2, 3, 3})); TensorShape inDims{numSamples, channels, imgSizeH, imgSizeW}; TensorShape outDims{numSamples, 2, 3, 3}; compare.addInputs( BufferArg(VALUE_TYPE_FLOAT, test_grad ? outDims : inDims)); compare.addOutputs(BufferArg(VALUE_TYPE_FLOAT, test_grad ? inDims : outDims, test_grad ? ADD_TO : ASSIGN_TO), test_grad ? ADD_TO : ASSIGN_TO); compare.run(); } } } } } }
TEST(CrossMapNormalGrad, real) { for (size_t numSamples : {5}) { for (size_t channels : {1, 5}) { for (size_t imgSizeH : {5, 33}) { for (size_t imgSizeW : {5, 32}) { for (size_t size : {1, 3}) { VLOG(3) << " numSamples=" << numSamples << " channels=" << channels << " imgSizeH=" << imgSizeH << " imgSizeW=" << imgSizeW << " size=" << size; CpuGpuFuncCompare test("CrossMapNormalGrad", FuncConfig() .set("size", size) .set("scale", (real)1.5) .set("pow", (real)0.5)); TensorShape shape{numSamples, channels, imgSizeH, imgSizeW}; test.addInputs(BufferArg(VALUE_TYPE_FLOAT, shape)); test.addInputs(BufferArg(VALUE_TYPE_FLOAT, shape)); test.addInputs(BufferArg(VALUE_TYPE_FLOAT, shape)); test.addInputs(BufferArg(VALUE_TYPE_FLOAT, shape)); test.addOutputs(BufferArg(VALUE_TYPE_FLOAT, shape)); // run Function test.run(); } } } } } }
TEST(BlockExpandBackward, real) { for (size_t batchSize : {5}) { for (size_t channels : {1, 5}) { for (size_t inputHeight : {5, 33}) { for (size_t inputWidth : {5, 32}) { for (size_t block : {1, 3, 5}) { for (size_t stride : {1, 2}) { for (size_t padding : {0, 1}) { // init Test object std::vector<size_t> strides = {stride, stride}; std::vector<size_t> paddings = {padding, padding}; std::vector<size_t> blocks = {block, block}; CpuGpuFuncCompare test("BlockExpandGrad", FuncConfig() .set("strides", strides) .set("paddings", paddings) .set("blocks", blocks)); size_t outputHeight = 1 + (inputHeight + 2 * padding - block + stride - 1) / stride; size_t outputWidth = 1 + (inputWidth + 2 * padding - block + stride - 1) / stride; TensorShape inputShape = TensorShape({batchSize, channels, inputHeight, inputWidth}); TensorShape outputShape = TensorShape({batchSize, outputHeight * outputWidth, channels * block * block}); test.addInputs(BufferArg(VALUE_TYPE_FLOAT, outputShape)); test.addOutputs(BufferArg(VALUE_TYPE_FLOAT, inputShape), ADD_TO); // run Function test.run(); } } } } } } } }