产品 |
是否支持 |
---|---|
√ |
|
√ |
|
x |
|
x |
|
√ |
|
√ |
|
x |
针对
针对
Profiler类的构造函数,用于局部打开Profiling功能,例如仅采集TensorFlow网络中局部子图的性能数据,或采集指定step的性能数据。
1 2 3 4 5 6 7 | def __init__( self, *, level: str = "L0", aic_metrics: str = "", output_path: str = "" ) |
参数名 |
输入/输出 |
描述 |
---|---|---|
level |
输入 |
开启Profiler的级别,用于控制采集性能数据的范围。
默认值:L0。 |
aic_metrics |
输入 |
当level配置为“L1”或“L2”时,可通过此参数采集AI Core和AI Vector Core硬件相关的性能指标,包含如下取值:
关于每一种取值包含的详细采集项及其含义可参见《性能调优工具用户指南》中的“性能数据文件参考 > op_summary(算子详细信息)”章节。 默认值为“PipeUtilization”。 |
output_path |
输入 |
Profiling采集结果文件保存路径。该参数指定的目录需要在启动训练的环境上(容器或Host侧)提前创建且运行用户具有读写权限,支持配置为绝对路径或相对路径(相对执行命令行时的当前路径)。路径中不能包含特殊字符:"\n"、"\f"、"\r"、"\b"、"\t"、"\v"、"\u007F"。
默认值为空。此参数配置为空时,采集结果文件保存在当前目录下。 |
无
1 2 3 | with profiler.Profiler(level="L1", aic_metrics="ArithmeticUtilization", output_path = "./"): with profiler.Profiler(level="L1", aic_metrics="ArithmeticUtilization", output_path = "./"): sess.run(add) |
1 2 3 4 5 6 7 8 9 10 11 | import tensorflow as tf from npu_bridge.npu_init import * ...... a = tf.placeholder(tf.int32, (None,None)) b = tf.constant([[1,2],[2,3]], dtype=tf.int32, shape=(2,2)) add = tf.add(a, b) with tf.Session(config=session_config, graph=g) as sess: with profiler.Profiler(level="L1", aic_metrics=str("ArithmeticUtilization"), output_path = "./"): result=sess.run(add, feed_dict={a: [[-20, 2],[1,3]],c: [[1],[-21]]}) |