diff --git a/src/node_operators_binary.h b/src/node_operators_binary.h index 38d9df4d..b80e6834 100644 --- a/src/node_operators_binary.h +++ b/src/node_operators_binary.h @@ -13,7 +13,17 @@ struct BinaryNodeOp : public Node { : Node(args...), a_(a), b_(b) {} void backward_numeric() { - backward(); + using namespace std; + cerr << "BinaryNodeOp::" << typeid(*this).name() << "::backward_numeric" << endl; + cerr << "BEFORE:" << endl; + cerr << "a_->grad()=" << a_->grad().Debug() << endl; + cerr << "b_->grad()=" << b_->grad().Debug() << endl; + cerr << "adj_=" << adj_.Debug() << endl; + backward(); + cerr << "AFTER:" << endl; + cerr << "a_->grad()=" << a_->grad().Debug() << endl; + cerr << "b_->grad()=" << b_->grad().Debug() << endl; + cerr << "adj_=" << adj_.Debug() << endl; } }; diff --git a/src/node_operators_unary.h b/src/node_operators_unary.h index f810fe21..b7959f8d 100644 --- a/src/node_operators_unary.h +++ b/src/node_operators_unary.h @@ -12,7 +12,15 @@ struct UnaryNodeOp : public Node { args...), a_(a) {} void backward_numeric() { + using namespace std; + cerr << "BinaryNodeOp::" << typeid(*this).name() << "::backward_numeric" << endl; + cerr << "BEFORE:" << endl; + cerr << "a_->grad()=" << a_->grad().Debug() << endl; + cerr << "adj_=" << adj_.Debug() << endl; backward(); + cerr << "AFTER:" << endl; + cerr << "a_->grad()=" << a_->grad().Debug() << endl; + cerr << "adj_=" << adj_.Debug() << endl; } }; diff --git a/src/tensor.h b/src/tensor.h index 3540bfdd..1ffcf0e1 100644 --- a/src/tensor.h +++ b/src/tensor.h @@ -405,17 +405,12 @@ class Tensor { */ std::string Debug() const { - return pimpl_->Debug(); - } - - /** - * @brief Print Tensor data on CPU (?) (const). - */ - void Print() const { - for (int i = 0; i < size(); ++i) { - std::cerr << (*this)[i] << " "; - } - std::cerr << std::endl; + if (!pimpl_) { + return "Not yet set"; + } + else { + return pimpl_->Debug(); + } } //void Load(const std::string &path);