Skip to content
This repository has been archived by the owner on Nov 17, 2023. It is now read-only.

Check expected vs. actual Node inputs. Many operators non-compliant. #15834

Closed
wants to merge 1 commit into from
Closed
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
35 changes: 23 additions & 12 deletions src/operator/operator_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -359,6 +359,27 @@ inline bool dispatch_fallback(StorageTypeVector* stypes, DispatchMode* dispatch)
return true;
}

// quick helper to make node entries for a node
inline std::vector<nnvm::NodeEntry> CreateNodeEntries(
nnvm::NodePtr pNode,
const std::vector<nnvm::NodeEntry>* pOgrads = nullptr,
const std::vector<nnvm::NodeEntry>* pInputs = nullptr) {
if (pOgrads)
pNode->inputs.insert(pNode->inputs.end(), pOgrads->begin(), pOgrads->end());

if (pInputs)
pNode->inputs.insert(pNode->inputs.end(), pInputs->begin(), pInputs->end());

CHECK_EQ(pNode->inputs.size(), pNode->num_inputs()) <<
"Mismatch in number of created vs. expected node inputs.";

std::vector<nnvm::NodeEntry> ret;
for (uint32_t i = 0; i < pNode->num_outputs(); ++i)
ret.emplace_back(pNode, i, 0);

return ret;
}

// make a new node with operator op_name. Inputs are not filled.
inline nnvm::NodePtr MakeNode(
const char* op_name, const std::string& name,
Expand Down Expand Up @@ -395,11 +416,7 @@ inline std::vector<nnvm::NodeEntry> MakeGradNode(
const std::unordered_map<std::string, std::string>& dict) {
auto p = MakeNode(op_name, n->attrs.name + "_backward",
&inputs, &dict, &n);
std::vector<nnvm::NodeEntry> ret;
for (uint32_t i = 0; i < p->num_outputs(); ++i) {
ret.emplace_back(p, i, 0);
}
return ret;
return CreateNodeEntries(p);
}

// quick helper to make gradient nodes that simply pass back zero. could be used in output ops.
Expand Down Expand Up @@ -446,13 +463,7 @@ inline std::vector<nnvm::NodeEntry> MakeNonlossGradNode(
return MakeZeroGradNodes(n, ograds);
auto p = MakeNode(op_name, n->attrs.name + "_backward",
nullptr, &dict, &n);
p->inputs.insert(p->inputs.end(), ograds.begin(), ograds.end());
p->inputs.insert(p->inputs.end(), inputs.begin(), inputs.end());
std::vector<nnvm::NodeEntry> ret;
for (uint32_t i = 0; i < p->num_outputs(); ++i) {
ret.emplace_back(p, i, 0);
}
return ret;
return CreateNodeEntries(p, &ograds, &inputs);
}

/*! \brief Parse keyword arguments as PType arguments and save to parsed */
Expand Down
36 changes: 22 additions & 14 deletions tests/jenkins/run_test_ubuntu.sh
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,19 @@ cp make/config.mk .
echo "USE_CUDA=1" >> config.mk
echo "USE_CUDA_PATH=/usr/local/cuda" >> config.mk
echo "USE_CUDNN=1" >> config.mk
echo "DEV=1" >> config.mk
echo "USE_PROFILER=1" >> config.mk
echo "DEV=0" >> config.mk
echo "EXTRA_OPERATORS=example/ssd/operator" >> config.mk
echo "USE_CPP_PACKAGE=1" >> config.mk

# Settings suitable to rebuild MXNet within NVIDIA's container
echo "USE_MKLDNN=0" >> config.mk
echo "USE_LAPACK_PATH=/usr/lib/x86_64-linux-gnu" >> config.mk
echo "USE_BLAS=openblas" >> config.mk
echo "USE_HOROVOD=1" >> config.mk
echo "USE_MPI_PATH=/usr/local/mpi" >> config.mk
echo "USE_NCCL=1" >> config.mk

if [ "$WITH_CAFFE_PLUGIN" == "1" ]; then
echo "CAFFE_PATH = $(pwd)/caffe" >> config.mk
echo "MXNET_PLUGINS += plugin/caffe/caffe.mk" >> config.mk
Expand All @@ -53,20 +62,19 @@ make -j$(nproc)

export PYTHONPATH=${PWD}/python

if [ ! -x "$(which nosetests)" ]; then
pip install nose scipy
Copy link
Contributor

Choose a reason for hiding this comment

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

Installation exceeds the scope of this script IMO

fi
echo "BUILD python_test"
nosetests --verbose tests/python/unittest || exit 1
nosetests --verbose tests/python/gpu/test_operator_gpu.py || exit 1
nosetests --verbose tests/python/gpu/test_forward.py || exit 1
nosetests --verbose tests/python/gpu || exit 1
nosetests --verbose tests/python/train || exit 1

echo "BUILD python3_test"
nosetests3 --verbose tests/python/unittest || exit 1
nosetests3 --verbose tests/python/gpu/test_operator_gpu.py || exit 1
nosetests3 --verbose tests/python/gpu/test_forward.py || exit 1
nosetests3 --verbose tests/python/train || exit 1

echo "BUILD scala_test"
export PATH=$PATH:/opt/apache-maven/bin
cd scala-package
mvn integration-test || exit 1

if [ -x "$(which mvn)" ]; then
echo "BUILD scala_test"
export PATH=$PATH:/opt/apache-maven/bin
cd scala-package
mvn integration-test || exit 1
else
echo "No mvn, bypassing scala test."
fi