Merge branch 'develop' of https://github.com/PaddlePaddle/Paddle into improve_pruning
commit
1a82e7da9e
@ -1,2 +1,7 @@
|
||||
RNN Models
|
||||
==========
|
||||
|
||||
.. toctree::
|
||||
:maxdepth: 1
|
||||
|
||||
rnn_config_en.rst
|
||||
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,21 @@
|
||||
cmake_minimum_required(VERSION 3.0)
|
||||
|
||||
get_filename_component(PARENT_DIR ${CMAKE_CURRENT_SOURCE_DIR} DIRECTORY)
|
||||
get_filename_component(PARENT_DIR ${PARENT_DIR} DIRECTORY)
|
||||
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${PARENT_DIR}/cmake")
|
||||
|
||||
project(cxx_go C Go)
|
||||
|
||||
include(golang)
|
||||
include(flags)
|
||||
|
||||
set(MASTER_LIB_NAME "paddle_master")
|
||||
go_library(${MASTER_LIB_NAME} SHARED)
|
||||
|
||||
if(PROJ_ROOT)
|
||||
add_custom_command(OUTPUT ${PROJ_ROOT}/python/paddle/v2/master/lib${MASTER_LIB_NAME}.so
|
||||
COMMAND rm ${CMAKE_CURRENT_BINARY_DIR}/lib${MASTER_LIB_NAME}.h
|
||||
COMMAND cp ${CMAKE_CURRENT_BINARY_DIR}/lib${MASTER_LIB_NAME}.so ${PROJ_ROOT}/python/paddle/v2/master/
|
||||
DEPENDS ${MASTER_LIB_NAME})
|
||||
add_custom_target(paddle_master_shared ALL DEPENDS ${PROJ_ROOT}/python/paddle/v2/master/lib${MASTER_LIB_NAME}.so)
|
||||
endif(PROJ_ROOT)
|
@ -0,0 +1,110 @@
|
||||
package main
|
||||
|
||||
/*
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#define PADDLE_MASTER_OK 0
|
||||
#define PADDLE_MASTER_ERROR -1
|
||||
|
||||
typedef int paddle_master_client;
|
||||
*/
|
||||
import "C"
|
||||
|
||||
import (
|
||||
"sync"
|
||||
"unsafe"
|
||||
|
||||
"github.com/PaddlePaddle/Paddle/go/master"
|
||||
log "github.com/sirupsen/logrus"
|
||||
)
|
||||
|
||||
var nullPtr = unsafe.Pointer(uintptr(0))
|
||||
var mu sync.Mutex
|
||||
var handleMap = make(map[C.paddle_master_client]*master.Client)
|
||||
var curHandle C.paddle_master_client
|
||||
|
||||
func add(c *master.Client) C.paddle_master_client {
|
||||
mu.Lock()
|
||||
defer mu.Unlock()
|
||||
client := curHandle
|
||||
curHandle++
|
||||
handleMap[client] = c
|
||||
return client
|
||||
}
|
||||
|
||||
func get(client C.paddle_master_client) *master.Client {
|
||||
mu.Lock()
|
||||
defer mu.Unlock()
|
||||
return handleMap[client]
|
||||
}
|
||||
|
||||
func remove(client C.paddle_master_client) *master.Client {
|
||||
mu.Lock()
|
||||
defer mu.Unlock()
|
||||
h := handleMap[client]
|
||||
delete(handleMap, client)
|
||||
return h
|
||||
}
|
||||
|
||||
type addresser string
|
||||
|
||||
func (a addresser) Address() string {
|
||||
return string(a)
|
||||
}
|
||||
|
||||
//export paddle_new_master_client
|
||||
func paddle_new_master_client(addr *C.char, bufSize int) C.paddle_master_client {
|
||||
a := C.GoString(addr)
|
||||
c := master.NewClient(addresser(a), bufSize)
|
||||
return add(c)
|
||||
}
|
||||
|
||||
//export paddle_release_master_client
|
||||
func paddle_release_master_client(client C.paddle_master_client) {
|
||||
remove(client)
|
||||
}
|
||||
|
||||
//export paddle_set_dataset
|
||||
func paddle_set_dataset(client C.paddle_master_client, path **C.char, size C.int) C.int {
|
||||
c := get(client)
|
||||
var paths []string
|
||||
for i := 0; i < int(size); i++ {
|
||||
ptr := (**C.char)(unsafe.Pointer(uintptr(unsafe.Pointer(path)) + uintptr(i)*unsafe.Sizeof(*path)))
|
||||
str := C.GoString(*ptr)
|
||||
paths = append(paths, str)
|
||||
}
|
||||
err := c.SetDataset(paths)
|
||||
if err != nil {
|
||||
log.Errorln(err)
|
||||
return C.PADDLE_MASTER_ERROR
|
||||
}
|
||||
|
||||
return C.PADDLE_MASTER_OK
|
||||
}
|
||||
|
||||
//export paddle_next_record
|
||||
func paddle_next_record(client C.paddle_master_client, record **C.uchar) C.int {
|
||||
c := get(client)
|
||||
r := c.NextRecord()
|
||||
if len(r) == 0 {
|
||||
*record = (*C.uchar)(nullPtr)
|
||||
return 0
|
||||
}
|
||||
|
||||
size := C.size_t(len(r))
|
||||
*record = (*C.uchar)(C.malloc(size))
|
||||
C.memcpy(unsafe.Pointer(*record), unsafe.Pointer(&r[0]), size)
|
||||
return C.int(size)
|
||||
}
|
||||
|
||||
//export mem_free
|
||||
func mem_free(p unsafe.Pointer) {
|
||||
// "free" may be a better name for this function, but doing so
|
||||
// will cause calling any function of this library from Python
|
||||
// ctypes hanging.
|
||||
C.free(p)
|
||||
}
|
||||
|
||||
func main() {}
|
@ -0,0 +1,121 @@
|
||||
package master
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"net"
|
||||
"net/http"
|
||||
"net/rpc"
|
||||
"os"
|
||||
"strconv"
|
||||
"strings"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
log "github.com/sirupsen/logrus"
|
||||
|
||||
"github.com/PaddlePaddle/Paddle/go/connection"
|
||||
"github.com/PaddlePaddle/recordio"
|
||||
)
|
||||
|
||||
const (
|
||||
totalTask = 20
|
||||
chunkPerTask = 10
|
||||
)
|
||||
|
||||
func init() {
|
||||
log.SetLevel(log.ErrorLevel)
|
||||
}
|
||||
|
||||
type TestAddresser string
|
||||
|
||||
func (a TestAddresser) Address() string {
|
||||
return string(a)
|
||||
}
|
||||
|
||||
func TestGetFinishTask(t *testing.T) {
|
||||
const path = "/tmp/master_client_test_0"
|
||||
|
||||
l, err := net.Listen("tcp", ":0")
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
ss := strings.Split(l.Addr().String(), ":")
|
||||
p, err := strconv.Atoi(ss[len(ss)-1])
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
go func(l net.Listener) {
|
||||
s := NewService(chunkPerTask, time.Second, 1)
|
||||
server := rpc.NewServer()
|
||||
err := server.Register(s)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
mux := http.NewServeMux()
|
||||
mux.Handle(rpc.DefaultRPCPath, server)
|
||||
err = http.Serve(l, mux)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}(l)
|
||||
|
||||
f, err := os.Create(path)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
for i := 0; i < totalTask*chunkPerTask; i++ {
|
||||
w := recordio.NewWriter(f, -1, -1)
|
||||
w.Write(nil)
|
||||
// call Close to force RecordIO writing a chunk.
|
||||
w.Close()
|
||||
}
|
||||
f.Close()
|
||||
|
||||
// Manually intialize client to avoid calling c.getRecords()
|
||||
c := &Client{}
|
||||
c.conn = connection.New()
|
||||
go c.monitorMaster(TestAddresser(fmt.Sprintf(":%d", p)))
|
||||
c.SetDataset([]string{path})
|
||||
|
||||
checkOnePass := func(i int) {
|
||||
var tasks []Task
|
||||
for idx := 0; idx < totalTask; idx++ {
|
||||
task, err := c.getTask()
|
||||
if err != nil {
|
||||
t.Fatalf("Error: %v, pass: %d\n", err, i)
|
||||
}
|
||||
tasks = append(tasks, task)
|
||||
}
|
||||
|
||||
_, err = c.getTask()
|
||||
if err == nil {
|
||||
t.Fatalf("Should get error, pass: %d\n", i)
|
||||
}
|
||||
|
||||
err = c.taskFinished(tasks[0].ID)
|
||||
if err != nil {
|
||||
t.Fatalf("Error: %v, pass: %d\n", err, i)
|
||||
}
|
||||
tasks = tasks[1:]
|
||||
task, err := c.getTask()
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
tasks = append(tasks, task)
|
||||
|
||||
for _, task := range tasks {
|
||||
err = c.taskFinished(task.ID)
|
||||
if err != nil {
|
||||
t.Fatalf("Error: %v, pass: %d\n", err, i)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for i := 0; i < 10; i++ {
|
||||
checkOnePass(i)
|
||||
}
|
||||
}
|
@ -0,0 +1,146 @@
|
||||
/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License. */
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "Function.h"
|
||||
|
||||
namespace paddle {
|
||||
|
||||
/*
|
||||
* \brief Based on the ConvFunctionBase class, the forward calculation,
|
||||
* backward input calculation and backward filter calculation
|
||||
* of convolution operations can be implemented.
|
||||
*
|
||||
* Arguments of forward and backward calculation:
|
||||
* 1. Forward calculation of convolution.
|
||||
* inputs = {INPUT, FILTER}, outputs = {OUTPUT}
|
||||
* The first and second input arguments are input image and filter data.
|
||||
* The output argument is output image.
|
||||
*
|
||||
* 2. Backward input calculation of convolution.
|
||||
* inputs = {OUTPUT_GRAD, FILTER}, outputs = {INPUT_GRAD}
|
||||
* The first and second input arguments are output grad image
|
||||
* and filter data.
|
||||
* The output argument is input grad image.
|
||||
*
|
||||
* 3. Backward filter calculation of convolution.
|
||||
* inputs = {OUTPUT_GRAD, INPUT}, outputs = {FILTER_GRAD}
|
||||
* The first and second input arguments are output grad image
|
||||
* and input image.
|
||||
* The output argument is filter grad.
|
||||
*
|
||||
* Arguments format of input, filter and output:
|
||||
* 1. Input image, output image, input image gradient, output image gradient
|
||||
* are all NCHW format. Where N is batch size, C is the number of channels,
|
||||
* H and W is the height and width of image or image gradient.
|
||||
*
|
||||
* 2. The format of the filter data is MCHW, where M is the number of output
|
||||
* image channels, C is the number of input image channels,
|
||||
* H and W is height and width of filter.
|
||||
*
|
||||
* If `groups` is greater than 1, the filter's data format should be GMCHW,
|
||||
* where G is the `groups`, and G * M is the number of output image
|
||||
* channels, G * C is the number of input image channels,
|
||||
* H and W is height and width of filter.
|
||||
*/
|
||||
class ConvFunctionBase : public FunctionBase {
|
||||
public:
|
||||
void init(const FuncConfig& config) override {
|
||||
// function arguments
|
||||
strides_ = config.get<std::vector<size_t>>("strides");
|
||||
paddings_ = config.get<std::vector<size_t>>("paddings");
|
||||
groups_ = config.get<size_t>("groups");
|
||||
|
||||
// number of inputs and outputs
|
||||
numInputs_ = 2;
|
||||
numOutputs_ = 1;
|
||||
}
|
||||
|
||||
virtual void calc(const BufferArgs& inputs, const BufferArgs& outputs) {}
|
||||
|
||||
// input can be INPUT and INPUT_GRAD
|
||||
// filter can be FILTER and FILTER_GRAD
|
||||
// output can be OUTPUT and OUTPUT_GRAD
|
||||
void check(const TensorShape& input,
|
||||
const TensorShape& filter,
|
||||
const TensorShape& output) {
|
||||
// inputs and outputs arguments should be 4-dimensional.
|
||||
CHECK_EQ(input.ndims(), (size_t)4);
|
||||
CHECK_EQ(output.ndims(), (size_t)4);
|
||||
// The batchSize of the input needs to be equal to
|
||||
// the batchSize of the output.
|
||||
CHECK_EQ(input[0], output[0]);
|
||||
|
||||
if (filter.ndims() == (size_t)4) {
|
||||
// If the filter's dimension is 4, groups convolution is not supported.
|
||||
CHECK_EQ(groups_, (size_t)1);
|
||||
// The input and output channel dimensions are the second and first
|
||||
// dimensions of the filter shape.
|
||||
CHECK_EQ(input[1], filter[1]);
|
||||
CHECK_EQ(output[1], filter[0]);
|
||||
} else {
|
||||
// filter argument should be 5-dimensional.
|
||||
CHECK_EQ(filter.ndims(), (size_t)5);
|
||||
// The first dimension of the filter is the size of the group
|
||||
CHECK_EQ(filter[0], groups_);
|
||||
// The input and output channel dimensions are the third and second
|
||||
// dimensions of the filter shape.
|
||||
CHECK_EQ(input[1], filter[2] * groups_);
|
||||
CHECK_EQ(output[1], filter[1] * groups_);
|
||||
}
|
||||
}
|
||||
|
||||
protected:
|
||||
size_t getFilterHeight(const TensorShape& filter) const {
|
||||
return filter[filter.ndims() - 2];
|
||||
}
|
||||
|
||||
size_t getFilterWidth(const TensorShape& filter) const {
|
||||
return filter[filter.ndims() - 1];
|
||||
}
|
||||
|
||||
std::vector<size_t> strides_;
|
||||
std::vector<size_t> paddings_;
|
||||
|
||||
/// Group size, refer to grouped convolution in
|
||||
/// Alex Krizhevsky's paper: when group=2, the first half of the
|
||||
/// filters are only connected to the first half of the input channels,
|
||||
/// and the second half only connected to the second half.
|
||||
size_t groups_;
|
||||
|
||||
inline int strideH() const { return strides_[0]; }
|
||||
|
||||
inline int strideW() const { return strides_[1]; }
|
||||
|
||||
inline int paddingH() const { return paddings_[0]; }
|
||||
|
||||
inline int paddingW() const { return paddings_[1]; }
|
||||
|
||||
// A temporary memory in convolution calculation.
|
||||
MemoryHandlePtr memory_;
|
||||
|
||||
template <DeviceType Device>
|
||||
void resizeBuffer(size_t newSize) {
|
||||
if (!memory_ || newSize * sizeof(real) > memory_->getAllocSize()) {
|
||||
if (Device == DEVICE_TYPE_CPU) {
|
||||
memory_ = std::make_shared<CpuMemoryHandle>(newSize * sizeof(real));
|
||||
} else {
|
||||
memory_ = std::make_shared<GpuMemoryHandle>(newSize * sizeof(real));
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace paddle
|
@ -0,0 +1,210 @@
|
||||
/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License. */
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
#include <memory>
|
||||
#include "Function.h"
|
||||
#include "FunctionTest.h"
|
||||
|
||||
namespace paddle {
|
||||
|
||||
enum TestType {
|
||||
kForwardTest = 0,
|
||||
kBackwardInputTest = 1,
|
||||
kBackwardFilterTest = 2,
|
||||
};
|
||||
|
||||
template <DeviceType DType1, DeviceType DType2>
|
||||
class ConvolutionTest {
|
||||
public:
|
||||
ConvolutionTest(const std::string& conv1,
|
||||
const std::string& conv2,
|
||||
TestType type,
|
||||
std::string algo = "auto") {
|
||||
for (size_t batchSize : {1, 32}) {
|
||||
for (size_t inputSize : {7, 14, 54}) {
|
||||
for (size_t filterSize : {1, 3, 5}) {
|
||||
for (size_t inputChannels : {3, 64}) {
|
||||
for (size_t outputChannels : {3, 64, 128}) {
|
||||
if (inputChannels < outputChannels) break;
|
||||
for (size_t stride : {1, 2}) {
|
||||
for (size_t padding : {0, 1}) {
|
||||
if (padding >= filterSize) break;
|
||||
size_t outputSize =
|
||||
(inputSize - filterSize + 2 * padding + stride) / stride;
|
||||
VLOG(3) << " batchSize=" << batchSize
|
||||
<< " inputChannels=" << inputChannels
|
||||
<< " inputHeight=" << inputSize
|
||||
<< " inputWidth=" << inputSize
|
||||
<< " outputChannels=" << outputChannels
|
||||
<< " filterHeight=" << filterSize
|
||||
<< " filterWidth=" << filterSize
|
||||
<< " outputHeight=" << outputSize
|
||||
<< " outputWidth=" << outputSize
|
||||
<< " stride=" << stride << " padding=" << padding;
|
||||
|
||||
std::vector<size_t> paddings = {padding, padding};
|
||||
std::vector<size_t> strides = {stride, stride};
|
||||
Compare2Function<DType1, DType2> test(
|
||||
conv1,
|
||||
conv2,
|
||||
FuncConfig()
|
||||
.set("paddings", paddings)
|
||||
.set("strides", strides)
|
||||
.set("groups", (size_t)1)
|
||||
.set("algo", algo));
|
||||
|
||||
TensorShape input{
|
||||
batchSize, inputChannels, inputSize, inputSize};
|
||||
TensorShape filter{
|
||||
outputChannels, inputChannels, filterSize, filterSize};
|
||||
TensorShape output{
|
||||
batchSize, outputChannels, outputSize, outputSize};
|
||||
|
||||
if (type == kForwardTest) {
|
||||
test.addInputs(BufferArg(VALUE_TYPE_FLOAT, input));
|
||||
test.addInputs(BufferArg(VALUE_TYPE_FLOAT, filter));
|
||||
test.addOutputs(BufferArg(VALUE_TYPE_FLOAT, output));
|
||||
test.run();
|
||||
} else if (type == kBackwardInputTest) {
|
||||
test.addInputs(BufferArg(VALUE_TYPE_FLOAT, output));
|
||||
test.addInputs(BufferArg(VALUE_TYPE_FLOAT, filter));
|
||||
test.addOutputs(BufferArg(VALUE_TYPE_FLOAT, input), ADD_TO);
|
||||
test.run();
|
||||
} else if (type == kBackwardFilterTest) {
|
||||
test.addInputs(BufferArg(VALUE_TYPE_FLOAT, output));
|
||||
test.addInputs(BufferArg(VALUE_TYPE_FLOAT, input));
|
||||
test.addOutputs(BufferArg(VALUE_TYPE_FLOAT, filter));
|
||||
test.run();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// Mainly used to test cases where the height and width (input, filter)
|
||||
// are not equal.
|
||||
template <DeviceType DType1, DeviceType DType2>
|
||||
class ConvolutionTest2 {
|
||||
public:
|
||||
ConvolutionTest2(const std::string& conv1,
|
||||
const std::string& conv2,
|
||||
TestType type,
|
||||
std::string algo = "auto") {
|
||||
for (size_t batchSize : {16}) {
|
||||
for (size_t inputHeight : {7, 31}) {
|
||||
for (size_t inputWidth : {10, 54}) {
|
||||
for (size_t filterHeight : {1, 5}) {
|
||||
for (size_t filterWidth : {3, 7}) {
|
||||
for (size_t inputChannels : {7}) {
|
||||
for (size_t outputChannels : {32}) {
|
||||
size_t stride = 1;
|
||||
size_t padding = 0;
|
||||
size_t outputHeight =
|
||||
(inputHeight - filterHeight + 2 * padding + stride) /
|
||||
stride;
|
||||
size_t outputWidth =
|
||||
(inputWidth - filterWidth + 2 * padding + stride) /
|
||||
stride;
|
||||
VLOG(3) << " batchSize=" << batchSize
|
||||
<< " inputChannels=" << inputChannels
|
||||
<< " inputHeight=" << inputHeight
|
||||
<< " inputWidth=" << inputWidth
|
||||
<< " outputChannels=" << outputChannels
|
||||
<< " filterHeight=" << filterHeight
|
||||
<< " filterWidth=" << filterWidth
|
||||
<< " outputHeight=" << outputHeight
|
||||
<< " outputWidth=" << outputWidth
|
||||
<< " stride=" << stride << " padding=" << padding;
|
||||
|
||||
std::vector<size_t> paddings = {padding, padding};
|
||||
std::vector<size_t> strides = {stride, stride};
|
||||
Compare2Function<DType1, DType2> test(
|
||||
conv1,
|
||||
conv2,
|
||||
FuncConfig()
|
||||
.set("paddings", paddings)
|
||||
.set("strides", strides)
|
||||
.set("groups", (size_t)1)
|
||||
.set("algo", algo));
|
||||
|
||||
TensorShape input{
|
||||
batchSize, inputChannels, inputHeight, inputWidth};
|
||||
TensorShape filter{
|
||||
outputChannels, inputChannels, filterHeight, filterWidth};
|
||||
TensorShape output{
|
||||
batchSize, outputChannels, outputHeight, outputWidth};
|
||||
|
||||
if (type == kForwardTest) {
|
||||
test.addInputs(BufferArg(VALUE_TYPE_FLOAT, input));
|
||||
test.addInputs(BufferArg(VALUE_TYPE_FLOAT, filter));
|
||||
test.addOutputs(BufferArg(VALUE_TYPE_FLOAT, output));
|
||||
test.run();
|
||||
} else if (type == kBackwardInputTest) {
|
||||
test.addInputs(BufferArg(VALUE_TYPE_FLOAT, output));
|
||||
test.addInputs(BufferArg(VALUE_TYPE_FLOAT, filter));
|
||||
test.addOutputs(BufferArg(VALUE_TYPE_FLOAT, input), ADD_TO);
|
||||
test.run();
|
||||
} else if (type == kBackwardFilterTest) {
|
||||
test.addInputs(BufferArg(VALUE_TYPE_FLOAT, output));
|
||||
test.addInputs(BufferArg(VALUE_TYPE_FLOAT, input));
|
||||
test.addOutputs(BufferArg(VALUE_TYPE_FLOAT, filter));
|
||||
test.run();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
TEST(Forward, GEMM) {
|
||||
ConvolutionTest<DEVICE_TYPE_CPU, DEVICE_TYPE_CPU> test(
|
||||
"NaiveConv-CPU", "GemmConv-CPU", kForwardTest);
|
||||
ConvolutionTest2<DEVICE_TYPE_CPU, DEVICE_TYPE_CPU> test2(
|
||||
"NaiveConv-CPU", "GemmConv-CPU", kForwardTest);
|
||||
}
|
||||
|
||||
#ifndef PADDLE_ONLY_CPU
|
||||
TEST(Forward, GEMM2) {
|
||||
ConvolutionTest<DEVICE_TYPE_CPU, DEVICE_TYPE_GPU> test(
|
||||
"GemmConv-CPU", "GemmConv-GPU", kForwardTest);
|
||||
ConvolutionTest2<DEVICE_TYPE_CPU, DEVICE_TYPE_GPU> test2(
|
||||
"GemmConv-CPU", "GemmConv-GPU", kForwardTest);
|
||||
}
|
||||
|
||||
TEST(BackwardInput, GEMM) {
|
||||
ConvolutionTest<DEVICE_TYPE_CPU, DEVICE_TYPE_GPU> test(
|
||||
"GemmConvGradInput-CPU", "GemmConvGradInput-GPU", kBackwardInputTest);
|
||||
ConvolutionTest2<DEVICE_TYPE_CPU, DEVICE_TYPE_GPU> test2(
|
||||
"GemmConvGradInput-CPU", "GemmConvGradInput-GPU", kBackwardInputTest);
|
||||
}
|
||||
|
||||
TEST(BackwardFilter, GEMM) {
|
||||
ConvolutionTest<DEVICE_TYPE_CPU, DEVICE_TYPE_GPU> test(
|
||||
"GemmConvGradFilter-CPU", "GemmConvGradFilter-GPU", kBackwardFilterTest);
|
||||
ConvolutionTest2<DEVICE_TYPE_CPU, DEVICE_TYPE_GPU> test2(
|
||||
"GemmConvGradFilter-CPU", "GemmConvGradFilter-GPU", kBackwardFilterTest);
|
||||
}
|
||||
#endif
|
||||
|
||||
} // namespace paddle
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in new issue