最近,在看TensoFlow源码时,看到链式编程的代码,贴出来一点:
#include "tensorflow/core/framework/common_shape_fns.h"
#include "tensorflow/core/framework/numeric_op.h"
#include "tensorflow/core/framework/op.h"
#include "tensorflow/core/framework/shape_inference.h"
namespace tensorflow {
REGISTER_OP("Invert")
.Input("x: T")
.Output("y: T")
.Attr("T: {int8, int16, int32, int64, uint8, uint16, uint32, uint64}")
.SetShapeFn(shape_inference::UnchangedShape);
#define BINARY_BITWISE() \
Input("x: T") \
.Input("y: T") \
.Output("z: T") \
.Attr("T: {int8, int16, int32, int64, uint8, uint16, uint32, uint64}") \
.SetShapeFn(shape_inference::BroadcastBinaryOpShapeFn)
#define BINARY_BITWISE_COMMUTATIVE()

本文介绍了链式编程的概念,通过举例展示了链式编程在jQuery中的应用,并分享了一个简单的C++链式编程实现。讨论了链式编程的优缺点,如代码简洁、可读性强,但也指出其可能对程序员的业务能力要求较高,不利于调试。
最低0.47元/天 解锁文章
1470





