You see here, I use same code, It is just functional , sequential same , I think , you  can get some ideas In my repo

  
      github.com
  
  
    kerry-Cho/SemanticSegmentation-Libtorch/blob/c1b57b609c1cdd23a66286f0c8653a2a86bf2b6a/SemanticSegmentation-Libtorch/models/resnet.h#L150 6

	bool zero_init_residual,
	int64_t groups,
	int64_t width_per_group)
	: groups(groups),
	base_width(width_per_group),
	inplanes(64),
	conv1(torch::nn::Conv2dOptions(3, 64, 7).stride(2).padding(3).with_bias(
		false).dilation(1)),
	bn1(64),
	fc(512 * Block::expansion, num_classes),
	max_pool1(torch::max_pool2d, 3, 2, 1, 1, false) {


	_dilation = 1;


	layer1 = _make_layer(64, layers[0]);
	layer2 = _make_layer(128, layers[1], 2);
	layer3 = _make_layer(256, layers[2], 2, true);
	layer4 = _make_layer(512, layers[3], 2, true);


	register_module("conv1", conv1);
	register_module("bn1", bn1);