Add Inception-v3 model#1495
Conversation
|
@reyna-abhyankar Can you take care of the "implementation vs paper" checks for this PR? I'll work on getting the additional operators implemented |
lockshaw
left a comment
There was a problem hiding this comment.
Reviewed 5 of 7 files at r1, 34 of 39 files at r2, 17 of 17 files at r3, all commit messages.
Reviewable status: all files reviewed, 6 unresolved discussions (waiting on @Marsella8 and @reyna-abhyankar)
lib/models/include/models/inceptionv3.h line 5 at r1 (raw file):
#include "models/inceptionv3_config.dtg.h" #include "pcg/computation_graph.h"
Nothing in the .h needs the functions declared in computation_graph.h
Suggestion:
#include "pcg/computation_graph.dtg.h"lib/models/include/models/inceptionv3.h line 6 at r1 (raw file):
#include "models/inceptionv3_config.dtg.h" #include "pcg/computation_graph.h" #include "pcg/computation_graph_builder.h"
Move to .cc, nothing in the .h mentions ComputationGraphBuilder
lib/models/include/models/inceptionv3_config.struct.toml line 15 at r1 (raw file):
[[fields]] name = "input_height" type = "size_t"
Prefer ints for all of these
lib/models/src/models/inceptionv3.cc line 35 at r1 (raw file):
std::nullopt, 1, use_bias);
Argument name comments might be nice for some of these (like "1" and "std::nullopt")
Code quote:
std::nullopt,
1,
use_bias);lib/models/src/models/inceptionv3.cc line 130 at r1 (raw file):
branch3x3dbl = cgb.concat(2, {branch3x3dbl_1, branch3x3dbl_2}, 3); tensor_guid_t branch_pool = cgb.pool2d(input, 3, 3, 1, 1, 1, 1, PoolOp::AVG);
Honestly might not be the worst idea to add argument comments for all of these raw number parameters for readability. Right now even if I had the order memorized there are so many that it's visually difficult to pick out which is which
lib/models/test/src/models/inception_v3/inception_v3.cc line 15 at r2 (raw file):
SUBCASE("num layers") { // int result_num_layers = get_layers(result).size(); int correct_num_layers = -1;
Checks should be added before merge
reyna-abhyankar
left a comment
There was a problem hiding this comment.
Reviewed all commit messages.
Reviewable status: all files reviewed, 8 unresolved discussions (waiting on @Marsella8)
lib/models/src/models/inception_v3/inception_v3.cc line 154 at r3 (raw file):
tensor_guid_t const &input, size_t num_classes) { tensor_guid_t x = cgb.pool2d(input, 8, 8, 1, 1, 0, 0, PoolOp::AVG);
So technically the module is adaptive avg pool, which I think means it reduces any input to the specified output size. The point of this is to deal with variable size inputs, which only happens if the inception_aux = true. I think you can probably just handle this manually (i.e. if (aux_logits) { ...__size A__...} else { ...__size B__...})
lib/models/src/models/inception_v3/inception_v3.cc line 175 at r3 (raw file):
x = create_inception_module_c(cgb, x, 160); x = create_inception_module_c(cgb, x, 192);
Missing inception_aux: can add aux_logits in the config as such
https://github.com/pytorch/vision/blob/00e7fa164bfdfd302f0b471c18ce2fd6bd1a50bc/torchvision/models/inception.py#L78
https://pytorch.org/vision/0.8/_modules/torchvision/models/inception.html - is the code for the module
lockshaw
left a comment
There was a problem hiding this comment.
Reviewed 12 of 22 files at r4, 27 of 38 files at r6, 14 of 14 files at r7, all commit messages.
Reviewable status: all files reviewed, 2 unresolved discussions (waiting on @reyna-abhyankar)
lib/models/include/models/inceptionv3.h line 5 at r1 (raw file):
Previously, lockshaw (Colin Unger) wrote…
Nothing in the
.hneeds the functions declared incomputation_graph.h
Done.
lib/models/include/models/inceptionv3.h line 6 at r1 (raw file):
Previously, lockshaw (Colin Unger) wrote…
Move to
.cc, nothing in the.hmentionsComputationGraphBuilder
Done.
lib/models/include/models/inceptionv3_config.struct.toml line 15 at r1 (raw file):
Previously, lockshaw (Colin Unger) wrote…
Prefer
ints for all of these
Done.
lib/models/src/models/inceptionv3.cc line 35 at r1 (raw file):
Previously, lockshaw (Colin Unger) wrote…
Argument name comments might be nice for some of these (like "1" and "std::nullopt")
Done.
lib/models/src/models/inceptionv3.cc line 130 at r1 (raw file):
Previously, lockshaw (Colin Unger) wrote…
Honestly might not be the worst idea to add argument comments for all of these raw number parameters for readability. Right now even if I had the order memorized there are so many that it's visually difficult to pick out which is which
Done.
lib/models/src/models/inception_v3/inception_v3.cc line 154 at r3 (raw file):
Previously, reyna-abhyankar (Reyna Abhyankar) wrote…
So technically the module is adaptive avg pool, which I think means it reduces any input to the specified output size. The point of this is to deal with variable size inputs, which only happens if the
inception_aux = true. I think you can probably just handle this manually (i.e.if (aux_logits) { ...__size A__...} else { ...__size B__...})
Added (partial) adaptive avg pool support
lib/models/src/models/inception_v3/inception_v3.cc line 175 at r3 (raw file):
Previously, reyna-abhyankar (Reyna Abhyankar) wrote…
Missing
inception_aux: can addaux_logitsin the config as such
https://github.com/pytorch/vision/blob/00e7fa164bfdfd302f0b471c18ce2fd6bd1a50bc/torchvision/models/inception.py#L78https://pytorch.org/vision/0.8/_modules/torchvision/models/inception.html - is the code for the module
Done.
lib/models/test/src/models/inception_v3/inception_v3.cc line 15 at r2 (raw file):
Previously, lockshaw (Colin Unger) wrote…
Checks should be added before merge
Done.
lockshaw
left a comment
There was a problem hiding this comment.
Reviewed 23 of 23 files at r8, all commit messages.
Reviewable status: all files reviewed, 2 unresolved discussions (waiting on @reyna-abhyankar)
reyna-abhyankar
left a comment
There was a problem hiding this comment.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @Marsella8)
lib/op-attrs/src/op-attrs/ops/pool_2d.cc line 41 at r7 (raw file):
int stride_h = kernel_h; int stride_w = kernel_w;
On the stack overflow post, I'm seeing the following formula:
stride = ind // outd
kernel_size = ind - (outd-1)*stride
padding = 0
lockshaw
left a comment
There was a problem hiding this comment.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @reyna-abhyankar)
lib/op-attrs/src/op-attrs/ops/pool_2d.cc line 41 at r7 (raw file):
Previously, reyna-abhyankar (Reyna Abhyankar) wrote…
On the stack overflow post, I'm seeing the following formula:
stride = ind // outd kernel_size = ind - (outd-1)*stride padding = 0
ind - (outd - 1)*stride = ind - (outd - 1) * (ind / outd) = ind - ind + (ind /outd) = ind / outd = stride
reyna-abhyankar
left a comment
There was a problem hiding this comment.
Reviewable status: 68 of 69 files reviewed, all discussions resolved (waiting on @lockshaw)
lib/op-attrs/src/op-attrs/ops/pool_2d.cc line 41 at r7 (raw file):
Previously, lockshaw (Colin Unger) wrote…
ind - (outd - 1)*stride=ind - (outd - 1) * (ind / outd)=ind - ind + (ind /outd)=ind / outd=stride
Nice.
lockshaw
left a comment
There was a problem hiding this comment.
Reviewed 1 of 1 files at r9, all commit messages.
Reviewable status:complete! all files reviewed, all discussions resolved (waiting on @Marsella8)
lib/op-attrs/src/op-attrs/ops/pool_2d.cc line 41 at r7 (raw file):
Previously, reyna-abhyankar (Reyna Abhyankar) wrote…
Nice.
Added a comment documenting this.
Description of changes:
Related Issues:
Linked Issues:
Issues closed by this PR:
This change is