Skip to content

Commit 898a95b

Browse files
siyengarmeta-codesync[bot]
authored andcommitted
fix the record function inputs
Summary: When we changed the specialization https://www.internalfb.com/diff/D85831630 to take a single tensor vs only a vector of tensors, we forgot to change the record function to record the correct tensor. this fixes it. Reviewed By: tanquer Differential Revision: D86011890 fbshipit-source-id: 60ca6937240908344a642ce9cc51b234cb1d101d
1 parent 515ffb3 commit 898a95b

File tree

1 file changed

+15
-8
lines changed

1 file changed

+15
-8
lines changed

comms/torchcomms/ncclx/TorchWorkNCCLX.cpp

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -60,17 +60,24 @@ void TorchWorkNCCLX::recordFunctionStart(const std::string& coll_name) {
6060
if (!recordFunction_->isActive()) {
6161
return;
6262
}
63+
6364
// Passing input tensor to recordFunction allows for shape information in
6465
// profiling output.
65-
std::vector<c10::IValue> inputs;
66-
inputs.reserve(inputTensors_.size());
67-
for (const auto& tensor : inputTensors_) {
68-
inputs.emplace_back(tensor);
66+
if (!inputTensors_.empty()) {
67+
std::vector<c10::IValue> inputs;
68+
inputs.reserve(inputTensors_.size());
69+
for (const auto& tensor : inputTensors_) {
70+
inputs.emplace_back(tensor);
71+
}
72+
recordFunction_->before(
73+
coll_name,
74+
c10::ArrayRef<const c10::IValue>(inputs.data(), inputs.size()));
75+
} else if (inputTensor_.defined()) {
76+
recordFunction_->before(
77+
coll_name, c10::ArrayRef<const c10::IValue>(inputTensor_));
78+
} else {
79+
recordFunction_->before(coll_name, c10::ArrayRef<const c10::IValue>{});
6980
}
70-
// TODO: pass the collective name to be added
71-
recordFunction_->before(
72-
coll_name,
73-
c10::ArrayRef<const c10::IValue>(inputs.data(), inputs.size()));
7481
}
7582

7683
void TorchWorkNCCLX::recordStart(const std::string& coll_name) {

0 commit comments

Comments
 (0)