Lunderberg commented on code in PR #16827:
URL: https://github.com/apache/tvm/pull/16827#discussion_r1548760451
##########
src/relax/op/op_common.h:
##########
@@ -239,52 +239,91 @@ InferLayoutOutput InferLayoutUnaryEwise(const Call& call,
const Map<String, Array<String>>&
desired_layouts,
const VarLayoutMap& var_layout_map);
+/*!
+ * \brief Get the element dtype from StructInfo
+ *
+ * \param sinfo The StructInfo to expect
+ * \return The inferred element dtype.
+ * \throw Throw exception if the StructInfo doesn't have an element type.
+ */
+inline DataType GetElementDType(const StructInfo& sinfo) {
+ if (const auto* prim = sinfo.as<PrimStructInfoNode>()) {
+ return prim->dtype;
+ } else if (const auto* tensor = sinfo.as<TensorStructInfoNode>()) {
+ return tensor->dtype;
+ } else if (sinfo.as<ObjectStructInfoNode>()) {
+ return DataType::Void();
Review Comment:
True. Currently, `FInferStructInfo` is called prior to `FNormalize`, so
inference could be inspecting an expression that hasn't yet been normalized.
This was useful for providing `FNormalize` for `R.Prim` (if `PrimStructInfo`
contains a known value, in-line that value), but I'm wondering if we should
re-visit that.
--
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]