tqchen commented on code in PR #16815:
URL: https://github.com/apache/tvm/pull/16815#discussion_r1544095492
##########
src/runtime/relax_vm/cuda/cuda_graph_builtin.cc:
##########
@@ -31,6 +31,46 @@ namespace tvm {
namespace runtime {
namespace relax_vm {
+struct CUDAGraphCaptureKey {
+ int64_t index;
+ ShapeTuple shape_expr;
+
+ CUDAGraphCaptureKey(int64_t index, const Optional<ShapeTuple>& shape_expr) :
index(index) {
+ if (shape_expr) {
+ this->shape_expr = shape_expr.value();
+ }
+ }
+
+ bool operator==(const CUDAGraphCaptureKey& other) const {
+ return index == other.index && std::equal(shape_expr.begin(),
shape_expr.end(),
+ other.shape_expr.begin(),
other.shape_expr.end());
Review Comment:
need to compare the shape_expr.size not null first, then shape expr size
then content
##########
src/runtime/relax_vm/cuda/cuda_graph_builtin.cc:
##########
@@ -31,6 +31,46 @@ namespace tvm {
namespace runtime {
namespace relax_vm {
+struct CUDAGraphCaptureKey {
+ int64_t index;
+ ShapeTuple shape_expr;
+
+ CUDAGraphCaptureKey(int64_t index, const Optional<ShapeTuple>& shape_expr) :
index(index) {
+ if (shape_expr) {
+ this->shape_expr = shape_expr.value();
+ }
+ }
+
+ bool operator==(const CUDAGraphCaptureKey& other) const {
+ return index == other.index && std::equal(shape_expr.begin(),
shape_expr.end(),
+ other.shape_expr.begin(),
other.shape_expr.end());
+ }
+};
+
+} // namespace relax_vm
+} // namespace runtime
+} // namespace tvm
+
+namespace std {
+
+template <>
+struct hash<tvm::runtime::relax_vm::CUDAGraphCaptureKey> {
+ size_t operator()(const tvm::runtime::relax_vm::CUDAGraphCaptureKey& key)
const {
+ std::hash<int64_t> hash_fn;
Review Comment:
use https://github.com/apache/tvm/blob/main/src/support/utils.h#L196
##########
src/runtime/relax_vm/cuda/cuda_graph_builtin.cc:
##########
@@ -31,6 +31,46 @@ namespace tvm {
namespace runtime {
namespace relax_vm {
+struct CUDAGraphCaptureKey {
+ int64_t index;
+ ShapeTuple shape_expr;
+
+ CUDAGraphCaptureKey(int64_t index, const Optional<ShapeTuple>& shape_expr) :
index(index) {
+ if (shape_expr) {
+ this->shape_expr = shape_expr.value();
+ }
+ }
+
+ bool operator==(const CUDAGraphCaptureKey& other) const {
Review Comment:
Use explicit structural CudaCaptureKeyHash and CudaCaptureKeyEqual
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]