import numpy as np
bin = np.fromfile("abc.bin", dtype=np.uint8) # 读取二进制,按一维数组存放
bin.tofile("abc.bin") # 按二进制保存
## 数组
arr = np.array([[1,2],[3,4]], dtype = float) # 创建数组,元素指定,shape为(2,2)
empty = np.empty((4,3,28,28), dtype = int) # 创建数组,shape为(4,3,28,28)
zeros = np.zeros((4,3,28,28)) # 创建数组,初始化为全0
ones = np.ones((4,3,28,28)) # 创建数组,初始化为全1
fives = np.fill((4,3,28,28), 5.0) # 创建数组,初始化为全5.0
x = np.arange(5) # 创建数组[0,1,2,3,4]
ones_2 = np.reshape((2,6,28,28)) # reshape
ones.size #元素个数
ones.dtype #元素类型
ones.shape
a = x[1:3] #从索引1开始,到3为止,不包括索引3. = [1,2]
a = x[1:] # = [1,2,3,4]
np.transpose(ones, (0,2,3,1)) #维度转置, shape=(4,28,28,3)
np.expand_dims(x, axis = 0) #维度扩充,shape=(1, 5)
参考 Tracepoints
include/trace/events/sample.h
#undef TRACE_SYSTEM
#define TRACE_SYSTEM sample
#if !defined(_TRACE_SUBSYS_H) || defined(TRACE_HEADER_MULTI_READ)
#define _TRACE_SUBSYS_H
#include <linux/tracepoint.h>
DECLARE_TRACE(sample_event,
TP_PROTO(int firstarg, struct task_struct *p),
TP_ARGS(firstarg, p));
#endif /* _TRACE_SUBSYS_H */
/* This part must be outside protection */
#include <trace/define_trace.h>
REGISTER_OP("Conv2D")
.Input("input: T")
.Input("filter: T")
.Output("output: T")
.Attr("T: {half, bfloat16, float, double}")
.Attr("strides: list(int)")
.Attr("use_cudnn_on_gpu: bool = true")
.Attr(GetPaddingAttrString())
.Attr(GetConvnetDataFormatAttrString())
.Attr("dilations: list(int) = [1, 1, 1, 1]")
.SetShapeFn(shape_inference::Conv2DShape);