Activation layer insert to class constructor as input(what data-type(=class) should I choose)


I have questions while porting Swin-V2 model to c++ code with Libtorch.

I want to insert activation function to class constructor input, but I have no idea to know what data-type(class) should I write down.

Here is Python class
class Mlp(nn.Module):
def init(self, in_features, hidden_features=None, out_features=None, act_layer=nn.GELU, drop=0., norm_layer=None, mlpfp32=False):

Points are act_layer and norm_layer, they has a lot of variations. for example act_layer sometime it is RELU, sometime it is GELU.

Now, I don’t know what kind of data-type should I choose when I make the new class on C++.

Here is wrong case constructor on C++
MlpImpl(int64_t in_features, int64_t hidden_features, int64_t out_features, torch::nn::ModuleHolder act_layer, float drop = 0.0, torch::nn::Module norm_layer, bool mlpfp32 = false);

torch::nn::ModuleHolder is based on “auto”, that’s why I can’t use these.

Please let me know what data-type should I use.