Skip to content

set_epsilon should not take a reference #187

@zcbenz

Description

@zcbenz

Layernorm_attributes&
set_epsilon(std::shared_ptr<Tensor_attributes>& value) {
inputs[Layernorm_attributes::input_names::EPSILON] = value;
return *this;
}

By taking a reference as parameter it would not be possible to pass rvalue, i.e. convenient code like below won't compile:

auto options = fe::graph::Rmsnorm_attributes()
    .set_epsilon(create_epsilon_tensor())

If the purpose is to avoid copy, the code should take const reference or use move semantics:

 Layernorm_attributes& 
 set_epsilon(std::shared_ptr<Tensor_attributes> value) { 
     inputs.emplace(Layernorm_attributes::input_names::EPSILON, std::move(value));
     return *this; 
 } 

There are also other cases need fixes:
https://github.com/search?q=repo%3ANVIDIA%2Fcudnn-frontend+%22%28std%3A%3Ashared_ptr%3CTensor_attributes%3E%26%22+path%3Agraph_properties.h&type=code

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions