浏览代码

[memory] Fix for tensors not being disposed of. (#2541)

* [memory] Fix for tensors not being disposed of.

* Fix member name.
/develop-gpu-test
GitHub 5 年前
当前提交
9358fd4f
共有 2 个文件被更改,包括 4 次插入1 次删除
  1. 2
      UnitySDK/Assets/ML-Agents/Scripts/InferenceBrain/ApplierImpl.cs
  2. 3
      UnitySDK/Assets/ML-Agents/Scripts/InferenceBrain/GeneratorImpl.cs

2
UnitySDK/Assets/ML-Agents/Scripts/InferenceBrain/ApplierImpl.cs


{
actions[ii, actionIndex] = outputTensor.data[ii, 0];
}
actionProbs.data.Dispose();
outputTensor.data.Dispose();
}
var agentIndex = 0;
foreach (var agent in agentInfo.Keys)

3
UnitySDK/Assets/ML-Agents/Scripts/InferenceBrain/GeneratorImpl.cs


public void Generate(TensorProxy tensorProxy, int batchSize, Dictionary<Agent, AgentInfo> agentInfo)
{
tensorProxy.data?.Dispose();
tensorProxy.data = _allocator.Alloc(new TensorShape(1,1));
tensorProxy.data[0] = batchSize;
}

public void Generate(TensorProxy tensorProxy, int batchSize, Dictionary<Agent, AgentInfo> agentInfo)
{
tensorProxy.shape = new long[0];
tensorProxy.data?.Dispose();
tensorProxy.data[0] = 1;
}
}

正在加载...
取消
保存