-
Notifications
You must be signed in to change notification settings - Fork 98
Feat/conv 1 d #1907
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
base: conv
Are you sure you want to change the base?
Feat/conv 1 d #1907
Changes from 1 commit
a59f27c
c629e5b
630a24d
74009f8
83c52a8
f34972b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,10 +24,25 @@ namespace conv { | |
|
||
template <typename ValueType> | ||
void conv(std::shared_ptr<const DefaultExecutor> exec, | ||
const matrix::Conv<ValueType>* kernel, | ||
const matrix::Dense<ValueType>* b, matrix::Dense<ValueType>* x) | ||
const array<ValueType>& kernel, const matrix::Dense<ValueType>* b, | ||
matrix::Dense<ValueType>* x) | ||
{ | ||
GKO_NOT_IMPLEMENTED; | ||
const auto b_size = b->get_size(); // (N, 1) | ||
const auto x_size = x->get_size(); // (N + K - 1, 1) | ||
const auto kernel_size = kernel.get_size(); // K | ||
const auto* kernel_ptr = kernel.get_const_data(); // pointer to kernel data | ||
|
||
for (int i = 0; i < x_size[0]; ++i) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. it seems not to be correct. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I updated it according to what torch does, it should work fine now c629e5b There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. you need to use size_t to deal from the dense size There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I changed it to size_t in 630a24d, does size_t allow negative values? I am currently using There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I tend to go by the rule of thumb: if you ever need to use a subtraction (even if you think the values will never become negative), you should use a signed type, so I would agree with using |
||
ValueType sum = zero<ValueType>(); | ||
for (int j = 0; j < kernel_size; ++j) { | ||
int b_idx = i - j; | ||
if (b_idx >= 0 && b_idx < b_size[0]) { | ||
sum += | ||
kernel_ptr[j] * b->at(b_idx, 0); // direct pointer access | ||
} | ||
} | ||
x->at(i, 0) = sum; | ||
} | ||
} | ||
|
||
GKO_INSTANTIATE_FOR_EACH_VALUE_TYPE(GKO_DECLARE_CONV_KERNEL); | ||
|
Uh oh!
There was an error while loading. Please reload this page.