-
-
Notifications
You must be signed in to change notification settings - Fork 1k
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
Write a utility function to make a shallow copy of an SGObject #5058
Comments
you mean like this? template<typename T>
std::shared_ptr<SGObject> make_shallow_copy(std::shared_ptr<T> obj){
return obj->clone(ParameterProperties::ALL
^ ParameterProperties::MODEL ^ ParameterProperties::READONLY);
} |
yup, and then find places where you can use it. You could also use the |
|
@karlnapf are those the flags you would expect a shallow copy to use? |
yes, see in the xvalidation code. |
I am new to open source development. |
Hello! I looked at the source code, and SGObject is still missing the make_shallow_copy() method. I would like to work on this! |
^ following the previous comment... I am trying to run some python example, but I was not able to find shogun.py, as listed in https://github.com/shogun-toolbox/shogun/blob/develop/doc/readme/INTERFACES.md. thanks! |
hi @yiransii, you need to enable python interfaces, like this |
@gf712 @LiuYuHui Thanks! However, I am still having dependency issues. Namely, my machine has Eigen3.3.8, but seems like shogun only supports version <= 3.3.7 but eigen 3.3.7 source repo is no longer available (https://bitbucket.org/eigen/eigen/get/3.3.7.tar.bz2) Any workaround this? Thanks!
|
@yiransii you can use this link, https://gitlab.com/libeigen/eigen/-/releases/3.3.7 |
Sounds fun! (and stale), Imma do it! |
Help me out a litlte, so the problem is the current copy method, copies everything which may or may not be required. So we'd like to use ParameterProperties as flags to pick and choose what we want to copy? If that's the case In the header file template<T>
std::shared_ptr<SGObject> sparse_copy(std::shared_ptr<T> obj, ParameterProperties pp = ParameterProperties::ALL
> ^ ParameterProperties::MODEL ^ ParameterProperties::READONLY); In source template<T>
std::shared_ptr<SGObject> SGObject::sparse_copy(std::shared<T> obj, ParameterProperties pp)
{
return obj->make_clone(pp);
} |
Usually
SGObject
s are stored inshared_ptr
, so when we perform a copy we just increment the control block refcount. We have a clone method to perform deep cloning, but this means we might be copying features, labels and weights, which is not always needed. This can be avoided by passing the respective ParameterProperties to themake_clone
function, so it would be good to havemake_shallow_copy
free function that sets these flags automatically (something likeParameterProperties::ALL ^ ParameterProperties::MODEL ^ ParameterProperties::READONLY
), and then just have something likemake_shallow_copy(obj)
.The text was updated successfully, but these errors were encountered: