public WeightTensor CreateWeightTensor(int row, int column, int deviceId, bool cleanWeights = false) { var k = buffer.GetOrAdd(row, x => new ConcurrentDictionary <int, WeightTensorList>()); var mList = k.GetOrAdd(column, x => new WeightTensorList()); WeightTensor r; // lock (locker) // { // if (mList.index == mList.WeightTensors.Count) // { r = new WeightTensor(row, column, deviceId); mList.WeightTensors.Add(r); //} //else //{ // r = mList.WeightTensors[mList.index]; // r.ClearGradient(); //} //mList.index++; // } if (cleanWeights) { r.ClearWeight(); } return(r); }
public WeightTensor CreateWeightTensor(int row, int column, int deviceId, bool cleanWeights = false) { WeightTensor r = new WeightTensor(row, column, deviceId); if (cleanWeights) { r.ClearWeight(); } weights.Add(r); return(r); }
public WeightTensor CreateWeightTensor(long[] sizes, int deviceId, bool cleanWeights = false, string name = "") { WeightTensor r = new WeightTensor(sizes, deviceId, name); if (cleanWeights) { r.ClearWeight(); } weights.Add(r); return(r); }
public WeightTensor CreateWeightTensor(int row, int column, int deviceId, bool cleanWeights = false, string name = "", bool isTrainable = false) { WeightTensor r = new WeightTensor(new long[2] { row, column }, deviceId, name: name, isTrainable: isTrainable); if (cleanWeights) { r.ClearWeight(); } weights.Add(r); return(r); }