Skip to content

Commit

Permalink
[record-hessian]Delete unused variable and argument.
Browse files Browse the repository at this point in the history
Delete unused variable and argument.

ONE-DCO-1.0-Signed-off-by: Banseok Lee <[email protected]>
  • Loading branch information
BLee-bot committed Nov 6, 2024
1 parent e17c5b1 commit 9f0bdc8
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,7 @@ class HessianComputer

void unfold(std::vector<float> &buf, uint32_t input_n, uint32_t input_h, uint32_t input_w,
uint32_t input_c, uint32_t stride_h, uint32_t stride_w, uint32_t dilation_h,
uint32_t dilation_w, uint32_t kernel_oc, uint32_t kernel_h, uint32_t kernel_w,
uint32_t kernel_ic);
uint32_t dilation_w, uint32_t kernel_h, uint32_t kernel_w, uint32_t kernel_ic);

} // namespace record_hessian

Expand Down
8 changes: 3 additions & 5 deletions compiler/record-hessian/src/HessianComputer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,11 @@ namespace record_hessian
*/
void unfold(std::vector<float> &buf, uint32_t input_n, uint32_t input_h, uint32_t input_w,
uint32_t input_c, uint32_t stride_h, uint32_t stride_w, uint32_t dilation_h,
uint32_t dilation_w, uint32_t kernel_oc, uint32_t kernel_h, uint32_t kernel_w,
uint32_t kernel_ic)
uint32_t dilation_w, uint32_t kernel_h, uint32_t kernel_w, uint32_t kernel_ic)
{
assert(input_n > 0 && input_h > 0 && input_w > 0 && input_c > 0);
assert(stride_h > 0 && stride_w > 0);
assert(kernel_oc > 0 && kernel_h > 0 && kernel_w > 0 && kernel_ic > 0);
assert(kernel_h > 0 && kernel_w > 0 && kernel_ic > 0);

if (input_c != kernel_ic)
throw std::runtime_error("RecordHessian: Input channels do not match kernel channels.");
Expand Down Expand Up @@ -143,7 +142,6 @@ void HessianComputer::recordHessianForConv2D(const luci::CircleNode *node)
uint32_t dilation_h = circle_conv2d->dilation()->h();
uint32_t dilation_w = circle_conv2d->dilation()->w();

uint32_t kernel_oc = node_filter->dim(0).value();
uint32_t kernel_h = node_filter->dim(1).value();
uint32_t kernel_w = node_filter->dim(2).value();
uint32_t kernel_ic = node_filter->dim(3).value();
Expand All @@ -155,7 +153,7 @@ void HessianComputer::recordHessianForConv2D(const luci::CircleNode *node)
std::vector<float> buf(data, data + num_elements);

unfold(buf, input_n, input_h, input_w, input_c, stride_h, stride_w, dilation_h, dilation_w,
kernel_oc, kernel_h, kernel_w, kernel_ic);
kernel_h, kernel_w, kernel_ic);
assert(size_in_ch != 0);
uint32_t length = buf.size() / size_in_ch;

Expand Down
8 changes: 4 additions & 4 deletions compiler/record-hessian/src/HessianComputer.test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,10 +87,10 @@ TEST(HessianComputerTest, unfoldValidInput)
std::vector<float> buf = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0};
uint32_t input_n = 1, input_h = 2, input_w = 2, input_c = 2;
uint32_t stride_h = 1, stride_w = 1, dilation_h = 1, dilation_w = 1;
uint32_t kernel_oc = 1, kernel_h = 2, kernel_w = 2, kernel_ic = 2;
uint32_t kernel_h = 2, kernel_w = 2, kernel_ic = 2;

unfold(buf, input_n, input_h, input_w, input_c, stride_h, stride_w, dilation_h, dilation_w,
kernel_oc, kernel_h, kernel_w, kernel_ic);
kernel_h, kernel_w, kernel_ic);
std::vector<float> expected_output = {1.0, 3.0, 5.0, 7.0, 2.0, 4.0, 6.0, 8.0};

EXPECT_EQ(buf, expected_output);
Expand All @@ -101,8 +101,8 @@ TEST(HessianComputerTest, unfoldInvalidInput_NEG)
std::vector<float> buf = {1.0, 2.0, 3.0, 4.0};
uint32_t input_n = 1, input_h = 2, input_w = 2, input_c = 1;
uint32_t stride_h = 1, stride_w = 1, dilation_h = 1, dilation_w = 1;
uint32_t kernel_oc = 1, kernel_h = 2, kernel_w = 2, kernel_ic = 2;
uint32_t kernel_h = 2, kernel_w = 2, kernel_ic = 2;

EXPECT_ANY_THROW(unfold(buf, input_n, input_h, input_w, input_c, stride_h, stride_w, dilation_h,
dilation_w, kernel_oc, kernel_h, kernel_w, kernel_ic));
dilation_w, kernel_h, kernel_w, kernel_ic));
}

0 comments on commit 9f0bdc8

Please sign in to comment.