Skip to content
Open
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
24 changes: 13 additions & 11 deletions csrc/base.h
Original file line number Diff line number Diff line change
Expand Up @@ -281,24 +281,26 @@ SPECIALIZE_PRINTER(VoidStar);
SPECIALIZE_PRINTER(uint32_t);
SPECIALIZE_PRINTER(int64_t);
SPECIALIZE_PRINTER(uint64_t);
SPECIALIZE_PRINTER(DataType);
SPECIALIZE_PRINTER(MemoryType);
SPECIALIZE_PRINTER(UnaryOpType);

SPECIALIZE_PRINTER(BinaryOpType);
SPECIALIZE_PRINTER(TernaryOpType);
SPECIALIZE_PRINTER(LoadStoreOpType);
SPECIALIZE_PRINTER(CircularBufferLoopStage);
SPECIALIZE_PRINTER(tma::TensorMapInterleave);
SPECIALIZE_PRINTER(tma::TensorMapL2Promotion);
SPECIALIZE_PRINTER(tma::TensorMapFloatOOBFill);
SPECIALIZE_PRINTER(DataType);
SPECIALIZE_PRINTER(LoadStoreOpType);
SPECIALIZE_PRINTER(MemoryType);
SPECIALIZE_PRINTER(MmaInputSmemSwizzle);
SPECIALIZE_PRINTER(SwizzleType);
SPECIALIZE_PRINTER(ParallelType);
SPECIALIZE_PRINTER(SwizzleMode);
SPECIALIZE_PRINTER(SwizzleType);
SPECIALIZE_PRINTER(TernaryOpType);
SPECIALIZE_PRINTER(UnaryOpType);
SPECIALIZE_PRINTER(std::optional<bool>);
SPECIALIZE_PRINTER(std::vector<int64_t>);
SPECIALIZE_PRINTER(std::vector<int>);
SPECIALIZE_PRINTER(std::vector<uint32_t>);
SPECIALIZE_PRINTER(std::vector<int64_t>);
SPECIALIZE_PRINTER(std::vector<uint64_t>);
SPECIALIZE_PRINTER(std::optional<bool>);
SPECIALIZE_PRINTER(tma::TensorMapFloatOOBFill);
SPECIALIZE_PRINTER(tma::TensorMapInterleave);
SPECIALIZE_PRINTER(tma::TensorMapL2Promotion);

#undef SPECIALIZE_PRINTER

Expand Down
7 changes: 7 additions & 0 deletions csrc/multidevice/propagation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#include <unordered_map>
#include <vector>

#include "base.h"
#include "ir/interface_nodes.h"
#include "ir/internal_base_nodes.h"
#include "ir/internal_nodes.h"
Expand Down Expand Up @@ -255,6 +256,12 @@ void shardLoopLike(
TensorView* tv,
const std::unordered_set<ParallelType>& selected_parallel_types,
PropagateDirection direction) {
if (isDebugDumpEnabled(DebugDumpOption::TransformPropagator)) {
debug() << "Propagating shardings from " << ref->toString() << " to "
<< tv->toString() << " in " << direction << " for "
<< toDelimitedString(selected_parallel_types) << std::endl;
}

std::unordered_set<IterDomain*> device_or_stream_ids;
const std::unordered_map<IterDomain*, IterDomain*> ref2target =
getRef2TargetMap(ref, tv, direction);
Expand Down
1 change: 0 additions & 1 deletion csrc/preseg_passes/propagate_shardings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
#include "ir/iostream.h"
#include "ir/utils.h"
#include "multidevice/propagation.h"
#include "multidevice/utils.h"
#include "scheduler/utils.h"

namespace nvfuser::preseg_passes {
Expand Down
16 changes: 16 additions & 0 deletions csrc/scheduler/utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,22 @@
#include <type.h>
#include <val_graph_visitor.h>

namespace nvfuser {

std::ostream& operator<<(std::ostream& os, PropagateDirection direction) {
switch (direction) {
case PropagateDirection::kForward:
os << "Forward";
break;
case PropagateDirection::kBackward:
os << "Backward";
break;
}
return os;
}
Comment on lines +48 to +58
Copy link
Contributor

Choose a reason for hiding this comment

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

switch statement lacks a default case for defensive programming

Suggested change
std::ostream& operator<<(std::ostream& os, PropagateDirection direction) {
switch (direction) {
case PropagateDirection::kForward:
os << "Forward";
break;
case PropagateDirection::kBackward:
os << "Backward";
break;
}
return os;
}
std::ostream& operator<<(std::ostream& os, PropagateDirection direction) {
switch (direction) {
case PropagateDirection::kForward:
os << "Forward";
break;
case PropagateDirection::kBackward:
os << "Backward";
break;
default:
NVF_ERROR(false, "Invalid PropagateDirection");
}
return os;
}

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

PropagateDirection is an enum class, so most modern compilers (GCC, Clang, MSVC) can perform exhaustion checks.


} // namespace nvfuser

namespace nvfuser::scheduler_utils {

// Minimal PTX code for a no-op kernel, used for occupancy queries
Expand Down
2 changes: 2 additions & 0 deletions csrc/scheduler/utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ class HeuristicDataCache;
//! BoundedDirectionalTransformPropagator.
enum class PropagateDirection { kBackward = 0, kForward };

std::ostream& operator<<(std::ostream& os, PropagateDirection direction);

namespace scheduler_utils {

// Assume any only half of the register file is available to spend on buffers,
Expand Down