Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add api doc and update unittest. #43

Merged
merged 6 commits into from
Sep 15, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions paddle/fluid/operators/overlap_add_op.cc
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ class OverlapAddOp : public framework::OperatorWithKernel {
"Attribute(hop_length) of OverlapAddOp should be greater "
"than 0, but got %s.",
hop_length));

PADDLE_ENFORCE_EQ(
(axis == 0 || axis == -1), true,
platform::errors::InvalidArgument(
Expand All @@ -68,6 +69,13 @@ class OverlapAddOp : public framework::OperatorWithKernel {
end_axis = x_rank - 3;
}

PADDLE_ENFORCE_LE(
hop_length, frame_length,
platform::errors::InvalidArgument(
"Attribute(hop_length) of OverlapAddOp should be less or equal "
"than frame_length, but got hop_length(%s) > frame_length(%s).",
hop_length, frame_length));

const int seq_length = (n_frames - 1) * hop_length + frame_length;

// It won't go into for loop when x_rank == 2U.
Expand Down
24 changes: 12 additions & 12 deletions python/paddle/fluid/tests/unittests/test_overlap_add_op.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,10 +79,10 @@ def setUp(self):
self.outputs = {'Out': overlap_add(x=self.inputs['X'], **self.attrs)}

def initTestCase(self):
input_shape = (150, 30)
input_shape = (50, 3)
input_type = 'float64'
attrs = {
'hop_length': 20,
'hop_length': 4,
'axis': -1,
}
return input_shape, input_type, attrs
Expand All @@ -100,54 +100,54 @@ def test_check_grad_normal(self):

class TestCase1(TestOverlapAddOp):
def initTestCase(self):
input_shape = (30, 150)
input_shape = (3, 50)
input_type = 'float64'
attrs = {
'hop_length': 15,
'hop_length': 4,
'axis': 0,
}
return input_shape, input_type, attrs


class TestCase2(TestOverlapAddOp):
def initTestCase(self):
input_shape = (2, 250, 10)
input_shape = (2, 40, 5)
input_type = 'float64'
attrs = {
'hop_length': 50,
'hop_length': 10,
'axis': -1,
}
return input_shape, input_type, attrs


class TestCase3(TestOverlapAddOp):
def initTestCase(self):
input_shape = (10, 250, 2)
input_shape = (5, 40, 2)
input_type = 'float64'
attrs = {
'hop_length': 30,
'hop_length': 10,
'axis': 0,
}
return input_shape, input_type, attrs


class TestCase4(TestOverlapAddOp):
def initTestCase(self):
input_shape = (3, 5, 70, 20)
input_shape = (3, 5, 12, 8)
input_type = 'float64'
attrs = {
'hop_length': 27,
'hop_length': 5,
'axis': -1,
}
return input_shape, input_type, attrs


class TestCase5(TestOverlapAddOp):
def initTestCase(self):
input_shape = (20, 70, 5, 3)
input_shape = (8, 12, 5, 3)
input_type = 'float64'
attrs = {
'hop_length': 33,
'hop_length': 5,
'axis': 0,
}
return input_shape, input_type, attrs
Expand Down
Loading