Skip to content

Commit

Permalink
Address code quality warnings (4/N: readability-named-parameter) (#33)
Browse files Browse the repository at this point in the history
Summary: Pull Request resolved: #33

Reviewed By: EscapeZero

Differential Revision: D59278420

fbshipit-source-id: 433f3fd9e26fbe4c1dbfc1af4be0a3a0969bab60
  • Loading branch information
jeongseok-meta authored and facebook-github-bot committed Jul 2, 2024
1 parent 4452ba7 commit 3a6bef1
Show file tree
Hide file tree
Showing 23 changed files with 86 additions and 68 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class MultiposeSolverFunctionT : public SolverFunctionT<T> {
size_t& actualRows) final;

void updateParameters(Eigen::VectorX<T>& parameters, const Eigen::VectorX<T>& gradient) final;
void setEnabledParameters(const ParameterSet&) final;
void setEnabledParameters(const ParameterSet& parameterSet) final;

void addErrorFunction(size_t frame, SkeletonErrorFunctionT<T>* errorFunction);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class SequenceSolverFunctionT : public SolverFunctionT<T> {
size_t& actualRows) final;

void updateParameters(Eigen::VectorX<T>& parameters, const Eigen::VectorX<T>& gradient) final;
void setEnabledParameters(const ParameterSet&) final;
void setEnabledParameters(const ParameterSet& parameterSet) final;

ParameterSet getUniversalParameterSet() const {
return universalParameters_;
Expand Down
4 changes: 2 additions & 2 deletions momentum/character_solver/aim_error_function.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ class AimDistErrorFunctionT : public ConstraintErrorFunctionT<T, AimDataT<T>, 3,
void evalFunction(
size_t constrIndex,
const JointStateT<T>& state,
Vector3<T>&,
Vector3<T>& f,
optional_ref<std::array<Vector3<T>, 2>> v = {},
optional_ref<std::array<Eigen::Matrix3<T>, 2>> dfdv = {}) const final;
};
Expand Down Expand Up @@ -105,7 +105,7 @@ class AimDirErrorFunctionT : public ConstraintErrorFunctionT<T, AimDataT<T>, 3,
void evalFunction(
size_t constrIndex,
const JointStateT<T>& state,
Vector3<T>&,
Vector3<T>& f,
optional_ref<std::array<Vector3<T>, 2>> v = {},
optional_ref<std::array<Eigen::Matrix3<T>, 2>> dfdv = {}) const final;
};
Expand Down
2 changes: 1 addition & 1 deletion momentum/character_solver/constraint_error_function-inl.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ ConstraintErrorFunctionT<T, Data, FuncDim, NumVec, NumPos>::ConstraintErrorFunct

template <typename T, class Data, size_t FuncDim, size_t NumVec, size_t NumPos>
double ConstraintErrorFunctionT<T, Data, FuncDim, NumVec, NumPos>::getError(
const ModelParametersT<T>&,
const ModelParametersT<T>& /* params */,
const SkeletonStateT<T>& state) {
MT_PROFILE_EVENT("Constraint: getError");

Expand Down
6 changes: 3 additions & 3 deletions momentum/character_solver/model_parameters_error_function.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ ModelParametersErrorFunctionT<T>::ModelParametersErrorFunctionT(
template <typename T>
double ModelParametersErrorFunctionT<T>::getError(
const ModelParametersT<T>& parameters,
const SkeletonStateT<T>&) {
const SkeletonStateT<T>& /* state */) {
// ignore if we don't have any reasonable data
if (targetParameters_.size() != parameters.size() || targetWeights_.size() != parameters.size()) {
return 0.0;
Expand All @@ -64,7 +64,7 @@ double ModelParametersErrorFunctionT<T>::getError(
template <typename T>
double ModelParametersErrorFunctionT<T>::getGradient(
const ModelParametersT<T>& parameters,
const SkeletonStateT<T>&,
const SkeletonStateT<T>& /* state */,
Ref<Eigen::VectorX<T>> gradient) {
// ignore if we don't have any reasonable data
if (targetParameters_.size() != parameters.size() || targetWeights_.size() != parameters.size()) {
Expand Down Expand Up @@ -92,7 +92,7 @@ size_t ModelParametersErrorFunctionT<T>::getJacobianSize() const {
template <typename T>
double ModelParametersErrorFunctionT<T>::getJacobian(
const ModelParametersT<T>& parameters,
const SkeletonStateT<T>&,
const SkeletonStateT<T>& /* state */,
Ref<Eigen::MatrixX<T>> jacobian,
Ref<Eigen::VectorX<T>> residual,
int& usedRows) {
Expand Down
2 changes: 1 addition & 1 deletion momentum/character_solver/normal_error_function.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ class NormalErrorFunctionT : public ConstraintErrorFunctionT<T, NormalDataT<T>,
void evalFunction(
size_t constrIndex,
const JointStateT<T>& state,
Vector<T, 1>&,
Vector<T, 1>& f,
optional_ref<std::array<Vector3<T>, 2>> v = {},
optional_ref<std::array<Eigen::Matrix<T, 1, 3>, 2>> dfdv = {}) const final;
};
Expand Down
2 changes: 1 addition & 1 deletion momentum/character_solver/plane_error_function.h
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ class PlaneErrorFunctionT : public ConstraintErrorFunctionT<T, PlaneDataT<T>, 1>
size_t constrIndex,
const JointStateT<T>& state,
Vector<T, 1>& f,
optional_ref<std::array<Vector3<T>, 1>> = {},
optional_ref<std::array<Vector3<T>, 1>> v = {},
optional_ref<std::array<Eigen::Matrix<T, 1, 3>, 1>> /*dfdv*/ = {}) const final;

private:
Expand Down
6 changes: 3 additions & 3 deletions momentum/character_solver/pose_prior_error_function.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,15 +86,15 @@ double PosePriorErrorFunctionT<T>::logProbability(const ModelParametersT<T>& par
template <typename T>
double PosePriorErrorFunctionT<T>::getError(
const ModelParametersT<T>& params,
const SkeletonStateT<T>&) {
const SkeletonStateT<T>& /* state */) {
// return error
return -logProbability(params) * kPosePriorWeight * this->weight_;
}

template <typename T>
double PosePriorErrorFunctionT<T>::getGradient(
const ModelParametersT<T>& params,
const SkeletonStateT<T>&,
const SkeletonStateT<T>& /* state */,
Eigen::Ref<Eigen::VectorX<T>> gradient) {
MT_PROFILE_EVENT("PosePrior: getGradient");

Expand Down Expand Up @@ -145,7 +145,7 @@ size_t PosePriorErrorFunctionT<T>::getJacobianSize() const {
template <typename T>
double PosePriorErrorFunctionT<T>::getJacobian(
const ModelParametersT<T>& params,
const SkeletonStateT<T>&,
const SkeletonStateT<T>& /* state */,
Eigen::Ref<Eigen::MatrixX<T>> jacobian,
Eigen::Ref<Eigen::VectorX<T>> residual,
int& usedRows) {
Expand Down
6 changes: 3 additions & 3 deletions momentum/character_solver/position_error_function.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,9 @@ class PositionErrorFunctionT : public ConstraintErrorFunctionT<T, PositionDataT<
void evalFunction(
size_t constrIndex,
const JointStateT<T>& state,
Vector3<T>&,
optional_ref<std::array<Vector3<T>, 1>> = {},
optional_ref<std::array<Matrix3<T>, 1>> /*dfdv*/ = {}) const final;
Vector3<T>& f,
optional_ref<std::array<Vector3<T>, 1>> v = {},
optional_ref<std::array<Matrix3<T>, 1>> dfdv = {}) const final;
};

} // namespace momentum
10 changes: 6 additions & 4 deletions momentum/character_solver/simd_normal_error_function.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,9 @@ SimdNormalErrorFunction::SimdNormalErrorFunction(
SimdNormalErrorFunction::SimdNormalErrorFunction(const Character& character, size_t maxThreads)
: SimdNormalErrorFunction(character.skeleton, character.parameterTransform, maxThreads) {}

double SimdNormalErrorFunction::getError(const ModelParameters&, const SkeletonState& state) {
double SimdNormalErrorFunction::getError(
const ModelParameters& /* params */,
const SkeletonState& state) {
if (constraints_ == nullptr) {
return 0.0f;
}
Expand Down Expand Up @@ -172,7 +174,7 @@ double SimdNormalErrorFunction::getError(const ModelParameters&, const SkeletonS
}

double SimdNormalErrorFunction::getGradient(
const ModelParameters&,
const ModelParameters& /* params */,
const SkeletonState& state,
Ref<VectorXf> gradient) {
if (constraints_ == nullptr) {
Expand Down Expand Up @@ -291,7 +293,7 @@ __vectorcall DRJIT_INLINE void jacobian_jointParams_to_modelParams(
}

double SimdNormalErrorFunction::getJacobian(
const ModelParameters&,
const ModelParameters& /* params */,
const SkeletonState& state,
Ref<MatrixXf> jacobian,
Ref<VectorXf> residual,
Expand Down Expand Up @@ -449,7 +451,7 @@ inline double __vectorcall sum8(const __m256 x) {
}

double SimdNormalErrorFunctionAVX::getJacobian(
const ModelParameters&,
const ModelParameters& /* params */,
const SkeletonState& state,
Ref<MatrixXf> jacobian,
Ref<VectorXf> residual,
Expand Down
4 changes: 2 additions & 2 deletions momentum/character_solver/simd_normal_error_function.h
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ class SimdNormalErrorFunction : public SkeletonErrorFunction {
Ref<VectorXf> gradient) final;

double getJacobian(
const ModelParameters&,
const ModelParameters& params,
const SkeletonState& state,
Ref<MatrixXf> jacobian,
Ref<VectorXf> residual,
Expand Down Expand Up @@ -135,7 +135,7 @@ class SimdNormalErrorFunctionAVX : public SimdNormalErrorFunction {
: SimdNormalErrorFunction(character, maxThreads) {}

double getJacobian(
const ModelParameters&,
const ModelParameters& params,
const SkeletonState& state,
Ref<MatrixXf> jacobian,
Ref<VectorXf> residual,
Expand Down
16 changes: 10 additions & 6 deletions momentum/character_solver/simd_plane_error_function.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,9 @@ SimdPlaneErrorFunction::SimdPlaneErrorFunction(const Character& character, size_
// Do nothing
}

double SimdPlaneErrorFunction::getError(const ModelParameters&, const SkeletonState& state) {
double SimdPlaneErrorFunction::getError(
const ModelParameters& /* params */,
const SkeletonState& state) {
if (constraints_ == nullptr) {
return 0.0f;
}
Expand Down Expand Up @@ -164,7 +166,7 @@ double SimdPlaneErrorFunction::getError(const ModelParameters&, const SkeletonSt
}

double SimdPlaneErrorFunction::getGradient(
const ModelParameters&,
const ModelParameters& /* params */,
const SkeletonState& state,
Ref<VectorXf> gradient) {
if (constraints_ == nullptr) {
Expand Down Expand Up @@ -312,7 +314,7 @@ __vectorcall DRJIT_INLINE void jacobian_jointParams_to_modelParams(
}

double SimdPlaneErrorFunction::getJacobian(
const ModelParameters&,
const ModelParameters& /* params */,
const SkeletonState& state,
Ref<MatrixXf> jacobian,
Ref<VectorXf> residual,
Expand Down Expand Up @@ -494,7 +496,9 @@ SimdPlaneErrorFunctionAVX::SimdPlaneErrorFunctionAVX(const Character& character,
// Do nothing
}

double SimdPlaneErrorFunctionAVX::getError(const ModelParameters&, const SkeletonState& state) {
double SimdPlaneErrorFunctionAVX::getError(
const ModelParameters& /* params */,
const SkeletonState& state) {
// do all summations in double to prevent rounding errors
double error = 0.0;
if (constraints_ == nullptr) {
Expand Down Expand Up @@ -558,7 +562,7 @@ double SimdPlaneErrorFunctionAVX::getError(const ModelParameters&, const Skeleto
}

double SimdPlaneErrorFunctionAVX::getGradient(
const ModelParameters&,
const ModelParameters& /* params */,
const SkeletonState& state,
Ref<VectorXf> gradient) {
if (constraints_ == nullptr) {
Expand Down Expand Up @@ -760,7 +764,7 @@ double SimdPlaneErrorFunctionAVX::getGradient(
}

double SimdPlaneErrorFunctionAVX::getJacobian(
const ModelParameters&,
const ModelParameters& /* params */,
const SkeletonState& state,
Ref<MatrixXf> jacobian,
Ref<VectorXf> residual,
Expand Down
4 changes: 2 additions & 2 deletions momentum/character_solver/simd_plane_error_function.h
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ class SimdPlaneErrorFunction : public SkeletonErrorFunction {
Ref<VectorXf> gradient) override;

double getJacobian(
const ModelParameters&,
const ModelParameters& params,
const SkeletonState& state,
Ref<MatrixXf> jacobian,
Ref<VectorXf> residual,
Expand Down Expand Up @@ -140,7 +140,7 @@ class SimdPlaneErrorFunctionAVX : public SimdPlaneErrorFunction {
Ref<VectorXf> gradient) final;

double getJacobian(
const ModelParameters&,
const ModelParameters& params,
const SkeletonState& state,
Ref<MatrixXf> jacobian,
Ref<VectorXf> residual,
Expand Down
16 changes: 10 additions & 6 deletions momentum/character_solver/simd_position_error_function.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,9 @@ SimdPositionErrorFunction::SimdPositionErrorFunction(const Character& character,
// Do nothing
}

double SimdPositionErrorFunction::getError(const ModelParameters&, const SkeletonState& state) {
double SimdPositionErrorFunction::getError(
const ModelParameters& /* params */,
const SkeletonState& state) {
if (constraints_ == nullptr) {
return 0.0f;
}
Expand Down Expand Up @@ -161,7 +163,7 @@ double SimdPositionErrorFunction::getError(const ModelParameters&, const Skeleto
}

double SimdPositionErrorFunction::getGradient(
const ModelParameters&,
const ModelParameters& /* params */,
const SkeletonState& state,
Ref<VectorXf> gradient) {
if (constraints_ == nullptr) {
Expand Down Expand Up @@ -307,7 +309,7 @@ __vectorcall DRJIT_INLINE void jacobian_jointParams_to_modelParams(
}

double SimdPositionErrorFunction::getJacobian(
const ModelParameters&,
const ModelParameters& /* params */,
const SkeletonState& state,
Ref<MatrixXf> jacobian,
Ref<VectorXf> residual,
Expand Down Expand Up @@ -544,7 +546,9 @@ SimdPositionErrorFunctionAVX::SimdPositionErrorFunctionAVX(
// Do nothing
}

double SimdPositionErrorFunctionAVX::getError(const ModelParameters&, const SkeletonState& state) {
double SimdPositionErrorFunctionAVX::getError(
const ModelParameters& /* params */,
const SkeletonState& state) {
double error = 0.0;

if (constraints_ == nullptr) {
Expand Down Expand Up @@ -610,7 +614,7 @@ double SimdPositionErrorFunctionAVX::getError(const ModelParameters&, const Skel
}

double SimdPositionErrorFunctionAVX::getGradient(
const ModelParameters&,
const ModelParameters& /* params */,
const SkeletonState& state,
Ref<VectorXf> gradient) {
if (constraints_ == nullptr) {
Expand Down Expand Up @@ -799,7 +803,7 @@ double SimdPositionErrorFunctionAVX::getGradient(
}

double SimdPositionErrorFunctionAVX::getJacobian(
const ModelParameters&,
const ModelParameters& /* params */,
const SkeletonState& state,
Ref<MatrixXf> jacobian,
Ref<VectorXf> residual,
Expand Down
4 changes: 2 additions & 2 deletions momentum/character_solver/simd_position_error_function.h
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ class SimdPositionErrorFunction : public SkeletonErrorFunction {
Ref<VectorXf> gradient) override;

double getJacobian(
const ModelParameters&,
const ModelParameters& /* params */,
const SkeletonState& state,
Ref<MatrixXf> jacobian,
Ref<VectorXf> residual,
Expand Down Expand Up @@ -138,7 +138,7 @@ class SimdPositionErrorFunctionAVX : public SimdPositionErrorFunction {
Ref<VectorXf> gradient) final;

double getJacobian(
const ModelParameters&,
const ModelParameters& params,
const SkeletonState& state,
Ref<MatrixXf> jacobian,
Ref<VectorXf> residual,
Expand Down
24 changes: 15 additions & 9 deletions momentum/character_solver/skeleton_error_function.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,27 +42,33 @@ class SkeletonErrorFunctionT {
enabledParameters_ = ps;
}

virtual double getError(const ModelParametersT<T>&, const SkeletonStateT<T>&) {
virtual double getError(
const ModelParametersT<T>& /* params */,
const SkeletonStateT<T>& /* state */) {
return 0.0f;
};

virtual double
getGradient(const ModelParametersT<T>&, const SkeletonStateT<T>&, Eigen::Ref<Eigen::VectorX<T>>) {
virtual double getGradient(
const ModelParametersT<T>& /* params */,
const SkeletonStateT<T>& /* state */,
Eigen::Ref<Eigen::VectorX<T>> /* gradient */) {
return 0.0f;
};

virtual double getJacobian(
const ModelParametersT<T>&,
const SkeletonStateT<T>&,
Eigen::Ref<Eigen::MatrixX<T>>,
Eigen::Ref<Eigen::VectorX<T>>,
const ModelParametersT<T>& /* params */,
const SkeletonStateT<T>& /* state */,
Eigen::Ref<Eigen::MatrixX<T>> /* jacobian */,
Eigen::Ref<Eigen::VectorX<T>> /* residual */,
int& usedRows) {
usedRows = 0;
return 0.0f;
};

virtual void
getHessian(const ModelParametersT<T>&, const SkeletonStateT<T>&, Eigen::Ref<Eigen::MatrixX<T>>) {
virtual void getHessian(
const ModelParametersT<T>& /* params */,
const SkeletonStateT<T>& /* state */,
Eigen::Ref<Eigen::MatrixX<T>> /* hessian */) {
throw;
return;
};
Expand Down
2 changes: 1 addition & 1 deletion momentum/character_solver/vertex_error_function.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ class VertexErrorFunctionT : public SkeletonErrorFunctionT<T> {
Eigen::Ref<Eigen::VectorX<T>> gradient) final;

double getJacobian(
const ModelParametersT<T>&,
const ModelParametersT<T>& params,
const SkeletonStateT<T>& state,
Eigen::Ref<Eigen::MatrixX<T>> jacobian,
Eigen::Ref<Eigen::VectorX<T>> residual,
Expand Down
Loading

0 comments on commit 3a6bef1

Please sign in to comment.