apeskov commented on a change in pull request #8054:
URL: https://github.com/apache/tvm/pull/8054#discussion_r633559740
##########
File path: src/target/source/codegen_metal.h
##########
@@ -51,12 +51,13 @@ class CodeGenMetal final : public CodeGenC {
void PrintVecElemStore(const std::string& vec, DataType t, int i, const
std::string& value) final;
// overload visitor
void VisitExpr_(const BroadcastNode* op, std::ostream& os) final; //
NOLINT(*)
- // overload visitor
void VisitExpr_(const CallNode* op, std::ostream& os) final; // NOLINT(*)
+ void VisitExpr_(const FloatImmNode* op, std::ostream& os) final;
// reuse parent's function.
using CodeGenC::PrintType;
private:
+ friend void PrintConst(const FloatImmNode* op, std::ostream& os,
CodeGenMetal* p);
Review comment:
Friend.. why not just class method?
##########
File path: src/target/source/intrin_rule_metal.cc
##########
@@ -90,6 +91,26 @@
TVM_REGISTER_OP("tir.cos").set_attr<FLowerIntrinsic>("metal.FLowerIntrinsic",
TVM_REGISTER_OP("tir.cosh")
.set_attr<FLowerIntrinsic>("metal.FLowerIntrinsic",
DispatchPureExtern<Direct>);
+// There is no erf function in Metal. When erf is used, we use fast_erf instead
+static PrimExpr DispatchFastErf(const PrimExpr& e) {
+ LOG(WARNING) << " Metal doesn't have built-in erf function. fast_erf will be
used instead.";
+ const CallNode* call = e.as<CallNode>();
+ ICHECK(call != nullptr);
+ ICHECK_EQ(call->args.size(), 1);
+ PrimExpr arg = call->args[0];
+ int bits = arg.dtype().bits();
+ bool isFloat = arg.dtype().is_float();
+ PrimExpr res;
+ if (isFloat && bits == 16)
+ res = topi::fast_erf_float_expr(arg, 16);
Review comment:
the same case `res = topi::fast_erf_float_expr(arg, bit);` , can be
merged
--
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.
For queries about this service, please contact Infrastructure at:
[email protected]