Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 16 additions & 4 deletions nuTens/tensors/tensor.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -435,10 +435,7 @@ class Tensor

NT_PROFILE();

Tensor ret;
ret.setTensor(tensor);

return ret;
return Tensor(tensor);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

clang-tidy diagnostic

nuTens/tensors/tensor.hpp:438:16: warning: [modernize-return-braced-init-list]

avoid repeating the return type from the declaration; use a braced initializer list instead

        return Tensor(tensor);
               ^

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

clang-tidy diagnostic

nuTens/tensors/tensor.hpp:438:16: warning: [modernize-return-braced-init-list]

avoid repeating the return type from the declaration; use a braced initializer list instead

        return Tensor(tensor);
               ^

}

protected:
Expand Down Expand Up @@ -496,8 +493,21 @@ class Tensor
return indicesVec;
}

private:

/// Construct a nuTens tensor directly from a pytorch tensor
Tensor(const torch::Tensor &tensor)
:
_tensor(tensor),
_dType(dtypes::invScalarTypeMap(tensor.scalar_type())),
_device(dtypes::invDeviceTypeMap(tensor.device().type()))
{
NT_PROFILE();
}

protected:
torch::Tensor _tensor;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

clang-tidy diagnostic

nuTens/tensors/tensor.hpp:509:19: warning: [cppcoreguidelines-non-private-member-variables-in-classes]

member variable '_tensor' has protected visibility

    torch::Tensor _tensor;
                  ^

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

clang-tidy diagnostic

nuTens/tensors/tensor.hpp:509:19: warning: [cppcoreguidelines-non-private-member-variables-in-classes]

member variable '_tensor' has protected visibility

    torch::Tensor _tensor;
                  ^


#endif
};

Expand Down Expand Up @@ -528,6 +538,8 @@ template <typename Tdtype, int TnDims, dtypes::deviceType Tdevice> class Accesse
AccessedTensor(const torch::Tensor &tensor)
: _packedAccessor(tensor.packed_accessor32<Tdtype, TnDims>()), _accessor(tensor.accessor<Tdtype, TnDims>())
{
NT_PROFILE();

setTensor(tensor);
};

Expand Down
Loading
Loading